-
Notifications
You must be signed in to change notification settings - Fork 18k
x/net/idna: ToASCII() mangles long strings #28233
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
Labels
Milestone
Comments
Change https://golang.org/cl/317731 mentions this issue: |
gopherbot
pushed a commit
to golang/text
that referenced
this issue
Oct 29, 2021
Prefer multiplication (int64(b)*int64(c) > MaxInt32) over division (b > MaxInt32/c) for overflow checking as it is a little faster on 386, and a LOT faster on amd64. For golang/go#28233. Change-Id: Ibf42529b93b699417781adc7eca6e66474f00bbf Reviewed-on: https://go-review.googlesource.com/c/text/+/317731 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Trust: Damien Neil <[email protected]>
Change https://golang.org/cl/360381 mentions this issue: |
gopherbot
pushed a commit
to golang/net
that referenced
this issue
Nov 4, 2021
CL 359634: use nontransitional processing in Go 1.18 CL 317731: fix int32 overflows Updates golang/go#46001 Updates golang/go#47510 Updates golang/go#28233 Change-Id: I2d9cdf5caa44f7c9b2834a256e7464b6edaae9ef Reviewed-on: https://go-review.googlesource.com/c/net/+/360381 Trust: Damien Neil <[email protected]> Run-TryBot: Damien Neil <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]>
N.B., this has been fixed in 77c473f for Go 1.18. |
Thanks @TimothyGu, I'll close this issue then. Please comment if we missed something here, or file a new issue if there's a new problem. |
xhit
pushed a commit
to xhit/text
that referenced
this issue
Oct 10, 2022
Prefer multiplication (int64(b)*int64(c) > MaxInt32) over division (b > MaxInt32/c) for overflow checking as it is a little faster on 386, and a LOT faster on amd64. For golang/go#28233. Change-Id: Ibf42529b93b699417781adc7eca6e66474f00bbf Reviewed-on: https://go-review.googlesource.com/c/text/+/317731 Run-TryBot: Ian Lance Taylor <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Trust: Damien Neil <[email protected]>
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Labels
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
)?What did you do?
Contrived test case:
What did you expect to see?
An error from
idna.ToASCII()
or the output that python3's punycode encoder produces.What did you see instead?
The overflow check here does not seem to catch the case where the wraparound is big enough that
delta + (m - n) * (h + 1) >= 0
.In the test case, it's
0 + (65535 - 128) * (65665 + 1) == 4295016062 % 2**32 == 48766
.Either the input should be rejected (reasonable, many other punycode encoders do) or it should use int64 arithmetic, like python3 does. Python may be an outlier; I'm not aware of other encoders that behave like that.
The text was updated successfully, but these errors were encountered: