diff options
author | Ivan Mironov <mironov.ivan@gmail.com> | 2020-04-23 18:08:07 +0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-23 15:08:07 +0200 |
commit | 3e27d8ebad7a69e49e447c7d0511dda63a9fbabb (patch) | |
tree | 505579f8a264a70147f0d9e27b16f480f7787590 /bytesconv_64_test.go | |
parent | Only base64 the proxy auth once (diff) | |
download | fasthttp-3e27d8ebad7a69e49e447c7d0511dda63a9fbabb.tar.gz fasthttp-3e27d8ebad7a69e49e447c7d0511dda63a9fbabb.tar.bz2 fasthttp-3e27d8ebad7a69e49e447c7d0511dda63a9fbabb.zip |
Fix integer overflow handling in parseUintBuf() (#789)
* Add more tests for parseUintBuf()
* Fix integer overflow handling in parseUintBuf()
Diffstat (limited to 'bytesconv_64_test.go')
-rw-r--r-- | bytesconv_64_test.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/bytesconv_64_test.go b/bytesconv_64_test.go index 1ba3237..d65f34f 100644 --- a/bytesconv_64_test.go +++ b/bytesconv_64_test.go @@ -39,6 +39,15 @@ func TestReadHexIntSuccess(t *testing.T) { testReadHexIntSuccess(t, "7ffffffffffffff", 0x7ffffffffffffff) } +func TestParseUintError64(t *testing.T) { + t.Parallel() + + // Overflow by last digit: 2 ** 64 / 2 * 10 ** n + testParseUintError(t, "9223372036854775808") + testParseUintError(t, "92233720368547758080") + testParseUintError(t, "922337203685477580800") +} + func TestParseUintSuccess(t *testing.T) { t.Parallel() @@ -46,5 +55,7 @@ func TestParseUintSuccess(t *testing.T) { testParseUintSuccess(t, "123", 123) testParseUintSuccess(t, "1234567890", 1234567890) testParseUintSuccess(t, "123456789012345678", 123456789012345678) + + // Max supported value: 2 ** 64 / 2 - 1 testParseUintSuccess(t, "9223372036854775807", 9223372036854775807) } |