-
Notifications
You must be signed in to change notification settings - Fork 18.8k
Closed
Labels
Milestone
Description
I’m going over some code in the standard library to see what it is doing in various edge cases. I’m going to report any findings where erroneous input does not cause an error or where the docs are subtly different from what the real thing does.
I believe it is best to fix those things, however minor they appear, for the sake of improving robustness and security. Please let me know if the standard library is not supposed to perform thorough input validation and expects the caller to do so.
What version of Go are you using (go version)?
go version go1.8.3 windows/amd64- Version 1.8 on the playground
What operating system and processor architecture are you using (go env)?
λ go env
set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=D:\Cache\Go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GCCGO=gccgo
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1
set PKG_CONFIG=pkg-config
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2What did you do?
Pass a negative bitSize and a "minus zero" string to strconv.ParseInt():
i, err := strconv.ParseInt("-0", 10, -1)
fmt.Println(i, err)This prints:
0 <nil>
See the runnable code on the Go Play Space or Go Playground.
What did you expect to see?
Expected ParseInt() to return an error. It does return an error for other input strings:
i, err := strconv.ParseInt("0", 10, -1) // -1, strconv.ParseInt: parsing "0": value out of rangeWhat did you see instead?
No error, err was nil.
Reactions are currently unavailable