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
The use of the [0] index is not compatible with an empty string.
However sometimes SETSOCKOPT with empty string is required, it would be nice to be able to do so without having to resort to use syscall.Syscall6 (for arm as an example) or whatever architecture dependent equivalent.
Thanks!
The text was updated successfully, but these errors were encountered:
Don't panic with "index out of range" on empty string argument.
Follows CL 170937 which did the sane for package syscall.
Updates golang/go#31277
Change-Id: I4feb796d0d58d3637428ae69997cfa3ec28a6b01
Reviewed-on: https://go-review.googlesource.com/c/sys/+/170957
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
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
)?Linux
What did you do?
syscall.SetsockoptString(1, 2, 3, "")
What did you expect to see?
It would be expected for an empty string to still allow the call.
What did you see instead?
panic: runtime error: index out of range
This happens because of the following code at https://golang.org/src/syscall/syscall_unix.go?s=7074:7137#L298:
The use of the
[0]
index is not compatible with an empty string.However sometimes SETSOCKOPT with empty string is required, it would be nice to be able to do so without having to resort to use syscall.Syscall6 (for arm as an example) or whatever architecture dependent equivalent.
Thanks!
The text was updated successfully, but these errors were encountered: