Skip to content

Commit

Permalink
unix: fix trimmed socket opt string in GetsockoptString
Browse files Browse the repository at this point in the history
Fixes golang/go#63217

Change-Id: Ia1b0ae88b7e7a7c611067a0b30e454b66f45ce51
Reviewed-on: https://go-review.googlesource.com/c/sys/+/530897
Reviewed-by: Mauri de Souza Meneguzzo <[email protected]>
Reviewed-by: Cherry Mui <[email protected]>
Auto-Submit: Tobias Klauser <[email protected]>
LUCI-TryBot-Result: Go LUCI <[email protected]>
Reviewed-by: Heschi Kreinick <[email protected]>
Reviewed-by: Tobias Klauser <[email protected]>
  • Loading branch information
KSDaemon authored and gopherbot committed Nov 8, 2023
1 parent 9888904 commit e4099bf
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion unix/syscall_bsd.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ func GetsockoptString(fd, level, opt int) (string, error) {
if err != nil {
return "", err
}
return string(buf[:vallen-1]), nil
return ByteSliceToString(buf[:vallen]), nil
}

//sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
Expand Down
2 changes: 1 addition & 1 deletion unix/syscall_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ func GetsockoptString(fd, level, opt int) (string, error) {
return "", err
}
}
return string(buf[:vallen-1]), nil
return ByteSliceToString(buf[:vallen]), nil
}

func GetsockoptTpacketStats(fd, level, opt int) (*TpacketStats, error) {
Expand Down
2 changes: 1 addition & 1 deletion unix/syscall_solaris.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ func GetsockoptString(fd, level, opt int) (string, error) {
if err != nil {
return "", err
}
return string(buf[:vallen-1]), nil
return ByteSliceToString(buf[:vallen]), nil
}

const ImplementsGetwd = true
Expand Down
2 changes: 1 addition & 1 deletion unix/syscall_zos_s390x.go
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ func GetsockoptString(fd, level, opt int) (string, error) {
return "", err
}

return string(buf[:vallen-1]), nil
return ByteSliceToString(buf[:vallen]), nil
}

func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) {
Expand Down

0 comments on commit e4099bf

Please sign in to comment.