You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
and they parse an integer value from &s[i0]. Especially since the majority of callers use i0==0, it seems like it would be simpler / more idiomatic to just have the caller pass s[i0:] as an argument.
In particular, dtoi theoretically supports parsing negative integers, except it looks for the '-' character at s[0], not s[i0].
https://golang.org/cl/27206 fixed the dtoi function such that
it now properly parses negative number. Ironically, this causes
several other functions that depended on dtoi to now (incorrectly)
parse negative numbers.
For example, ParseCIDR("-1.0.0.0/32") used to be rejected prior to the
above CL, but is now accepted even though it is an invalid CIDR notation.
This CL fixes that regression.
We fix this by removing the signed parsing logic entirely from dtoi.
It was introduced relatively recently in https://golang.org/cl/12447
to fix a bug where an invalid port was improperly being parsed as OK.
It seems to me that the fix in that CL to the port handling logic was
sufficient such that a change to dtoi was unnecessary.
Updates #16350
Change-Id: I414bb1aa27d0a226ebd4b05a09cb40d784691b43
Reviewed-on: https://go-review.googlesource.com/28414
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Mikio Hara <mikioh.mikioh@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
These internal helpers have signatures like:
and they parse an integer value from
&s[i0]
. Especially since the majority of callers usei0==0
, it seems like it would be simpler / more idiomatic to just have the caller passs[i0:]
as an argument.In particular, dtoi theoretically supports parsing negative integers, except it looks for the
'-'
character ats[0]
, nots[i0]
./cc @bradfitz @dpiddy
The text was updated successfully, but these errors were encountered: