提交 46ca9531 编写于 作者: D Davies Liu

validate content length

上级 b33b7a45
......@@ -88,6 +88,9 @@ func (c *COS) Copy(dst, src string) error {
func (c *COS) parseResult(resp *http.Response, out interface{}) error {
defer resp.Body.Close()
if resp.ContentLength <= 0 || resp.ContentLength > (1<<31) {
return fmt.Errorf("invalid content length: %d", resp.ContentLength)
}
data := make([]byte, resp.ContentLength)
if _, err := io.ReadFull(resp.Body, data); err != nil {
return err
......
......@@ -94,6 +94,9 @@ func (c *mss) List(prefix, marker string, limit int64) ([]*Object, error) {
if resp.StatusCode != 200 {
return nil, parseError(resp)
}
if resp.ContentLength <= 0 || resp.ContentLength > (1<<31) {
return nil, fmt.Errorf("invalid content length: %d", resp.ContentLength)
}
data := make([]byte, resp.ContentLength)
if _, err := io.ReadFull(resp.Body, data); err != nil {
return nil, err
......
......@@ -49,6 +49,9 @@ func (s *speedy) List(prefix, marker string, limit int64) ([]*Object, error) {
if resp.StatusCode != 200 {
return nil, parseError(resp)
}
if resp.ContentLength <= 0 || resp.ContentLength > (1<<31) {
return nil, fmt.Errorf("invalid content length: %d", resp.ContentLength)
}
data := make([]byte, resp.ContentLength)
if _, err := io.ReadFull(resp.Body, data); err != nil {
return nil, err
......
......@@ -54,6 +54,9 @@ func ufileSigner(req *http.Request, accessKey, secretKey, signName string) {
func (u *ufile) parseResp(resp *http.Response, out interface{}) error {
defer resp.Body.Close()
if resp.ContentLength <= 0 || resp.ContentLength > (1<<31) {
return fmt.Errorf("invalid content length: %d", resp.ContentLength)
}
data := make([]byte, resp.ContentLength)
if _, err := io.ReadFull(resp.Body, data); err != nil {
return err
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册