-
Notifications
You must be signed in to change notification settings - Fork 18k
strconv: index out of range in FormatFloat #52187
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The one-liner reproducer is |
friendly ping @remyoudompheng What is coming for this issue ? |
Interestingly there is no issue with valid uses of the package as show by this example: package main
import (
"strconv"
)
func main() {
x := 6.013470016999068e-154
println(strconv.FormatFloat(x, 'f', 0, 64))
println(strconv.FormatFloat(x, 'g', 0, 64))
println(strconv.FormatFloat(x, 'e', 0, 64))
println(strconv.FormatFloat(x, 'x', 0, 64))
} The issue was already present in Go 1.15 with the following panic message: The same message exists in Go 1.1 and probably even before (I am not able to run Go 1.0). |
Change https://go.dev/cl/402817 mentions this issue: |
Calling FormatFloat with an invalid value of fmt is expected to return a string containing '%' and the input fmt character. Since even before Go 1.0, the code has been panicking in the case where prec=0. Fixes golang#52187 Change-Id: I74fec601eedb7fe28efc5132c4253674661452aa Reviewed-on: https://go-review.googlesource.com/c/go/+/402817 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Run https://go.dev/play/p/tGb3ISbthgv
What did you expect to see?
The program finishing and printing somme dummy data
What did you see instead?
Found by https://github.com/catenacyber/ngolo-fuzzing on oss-fuzz
https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=46427
The text was updated successfully, but these errors were encountered: