mirror of
https://github.com/golang/sys.git
synced 2026-02-08 19:56:04 +03:00
unix: allow non-padded SockaddrIUCV
This was the intention from the start, but due to a logic error in the
handling of slices the implementation only handled minimum 8 character
strings.
This commit also improves the tests.
Change-Id: I6b0ed00bbd8a2faf90ca4a3ebe6218d3c5d6e8bf
GitHub-Last-Rev: 5b6dbc0682
GitHub-Pull-Request: golang/sys#77
Reviewed-on: https://go-review.googlesource.com/c/sys/+/248778
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
committed by
Matt Layher
parent
3ff754bf58
commit
cc1be6b9e0
@@ -902,10 +902,13 @@ func (sa *SockaddrIUCV) sockaddr() (unsafe.Pointer, _Socklen, error) {
|
||||
sa.raw.User_id[i] = ' '
|
||||
sa.raw.Name[i] = ' '
|
||||
}
|
||||
for i, b := range []byte(sa.UserID[:8]) {
|
||||
if len(sa.UserID) > 8 || len(sa.Name) > 8 {
|
||||
return nil, 0, EINVAL
|
||||
}
|
||||
for i, b := range []byte(sa.UserID[:]) {
|
||||
sa.raw.User_id[i] = int8(b)
|
||||
}
|
||||
for i, b := range []byte(sa.Name[:8]) {
|
||||
for i, b := range []byte(sa.Name[:]) {
|
||||
sa.raw.Name[i] = int8(b)
|
||||
}
|
||||
return unsafe.Pointer(&sa.raw), SizeofSockaddrIUCV, nil
|
||||
|
||||
Reference in New Issue
Block a user