]> Cypherpunks repositories - gostls13.git/commitdiff
fmt.Scan: fix integer overflow on 32-bit machines
authorAnthony Martin <ality@pbrane.org>
Sun, 5 Sep 2010 22:04:53 +0000 (08:04 +1000)
committerRob Pike <r@golang.org>
Sun, 5 Sep 2010 22:04:53 +0000 (08:04 +1000)
R=r, rsc
CC=golang-dev
https://golang.org/cl/2144043

src/pkg/fmt/scan.go
src/pkg/fmt/scan_test.go

index afbbeb394805fe6b8101fce9a5f5f276578cecee..bd8af50069fbf3d088c296fed011a28b2ee36131 100644 (file)
@@ -740,7 +740,7 @@ func (s *ss) scanOne(verb int, field interface{}) {
        case *int32:
                *v = int32(s.scanInt(verb, 32))
        case *int64:
-               *v = s.scanInt(verb, intBits)
+               *v = s.scanInt(verb, 64)
        case *uint:
                *v = uint(s.scanUint(verb, intBits))
        case *uint8:
index 90927898978e29745f45c643b81d4e83ee4e8c37..569d2f55f398fe50a88c3cdad6e5f3cf06d3eb9e 100644 (file)
@@ -183,6 +183,9 @@ var scanTests = []ScanTest{
 
        // Custom scanner.
        ScanTest{"  vvv ", &xVal, Xs("vvv")},
+
+       // Fixed bugs
+       ScanTest{"2147483648\n", &int64Val, int64(2147483648)}, // was: integer overflow
 }
 
 var scanfTests = []ScanfTest{