Ver Fonte

Don't loose precision when parsing image size on 32 bit machines. Presumably fixes #8979.

Signed-off-by: Recursive Madman <recursive.madman@gmx.de>
Recursive Madman há 10 anos atrás
pai
commit
5cd53195fd
1 ficheiros alterados com 4 adições e 1 exclusões
  1. 4 1
      image/image.go

+ 4 - 1
image/image.go

@@ -64,7 +64,10 @@ func LoadImage(root string) (*Image, error) {
 		// because a layer size of 0 (zero) is valid
 		img.Size = -1
 	} else {
-		size, err := strconv.Atoi(string(buf))
+		// Using Atoi here instead would temporarily convert the size to a machine
+		// dependent integer type, which causes images larger than 2^31 bytes to
+		// display negative sizes on 32-bit machines:
+		size, err := strconv.ParseInt(string(buf), 10, 64)
 		if err != nil {
 			return nil, err
 		}