Fix ParseUint to support all possible numbers

Fixes #461
This commit is contained in:
Erik Dubbelboer
2018-11-14 01:59:18 +08:00
parent 9d6d9b7cd5
commit 8a9bdc8177
5 changed files with 4 additions and 3 deletions
+2 -1
View File
@@ -183,7 +183,8 @@ func parseUintBuf(b []byte) (int, int, error) {
}
return v, i, nil
}
if i >= maxIntChars {
// Test for overflow.
if v*10 < v {
return -1, i, errTooLongInt
}
v = 10*v + int(k)
-1
View File
@@ -3,6 +3,5 @@
package fasthttp
const (
maxIntChars = 9
maxHexIntChars = 7
)
-1
View File
@@ -3,6 +3,5 @@
package fasthttp
const (
maxIntChars = 18
maxHexIntChars = 15
)
+1
View File
@@ -38,4 +38,5 @@ func TestParseUintSuccess(t *testing.T) {
testParseUintSuccess(t, "123", 123)
testParseUintSuccess(t, "1234567890", 1234567890)
testParseUintSuccess(t, "123456789012345678", 123456789012345678)
testParseUintSuccess(t, "9223372036854775807", 9223372036854775807)
}
+1
View File
@@ -176,6 +176,7 @@ func TestParseUintError(t *testing.T) {
// too big num
testParseUintError(t, "12345678901234567890")
testParseUintError(t, "1234567890123456789012")
}
func TestParseUfloatSuccess(t *testing.T) {