mirror of
https://github.com/rwinkhart/go-winio.git
synced 2026-09-06 09:07:18 -04:00
Switch from sycall to windows (#295)
Where ever possible, use `golang.org/x/sys/windows` instead of `syscall` (which has been deprecated since go1.11). Using `windows.LocalFree` requires using `unsafe.Pointer`, which ensures that the Go garbage collector does not try to free memory pre-maturely if it was previously declared as a pointer. Since `syscall.Handle` is part of API for `vhd` package, it was left unchanged. For security descriptor functions, switch to using `windows.SECURITY_DESCRIPTOR` to avoid unnecessary byte manipulation and panics due to missing input validation and error checking. Signed-off-by: Hamza El-Saawy <hamzaelsaawy@microsoft.com>
This commit is contained in:
+3
-3
@@ -114,7 +114,7 @@ func TestHvSockListenerAddresses(t *testing.T) {
|
||||
|
||||
ra := rawHvsockAddr{}
|
||||
sa := HvsockAddr{}
|
||||
u.Must(socket.GetSockName(windows.Handle(l.sock.handle), &ra))
|
||||
u.Must(socket.GetSockName(l.sock.handle, &ra))
|
||||
sa.fromRaw(&ra)
|
||||
u.Assert(sa == *addr, fmt.Sprintf("listener local addr give: %v; want: %v", sa, addr))
|
||||
}
|
||||
@@ -162,7 +162,7 @@ func TestHvSockAddresses(t *testing.T) {
|
||||
// {"server", sv.sock, _sla},
|
||||
}
|
||||
for _, tt := range localTests {
|
||||
u.Must(socket.GetSockName(windows.Handle(tt.giveSock.handle), &ra))
|
||||
u.Must(socket.GetSockName(tt.giveSock.handle, &ra))
|
||||
sa.fromRaw(&ra)
|
||||
if sa != tt.wantAddr {
|
||||
t.Errorf("%s local addr give: %v; want: %v", tt.name, sa, tt.wantAddr)
|
||||
@@ -177,7 +177,7 @@ func TestHvSockAddresses(t *testing.T) {
|
||||
{"server", sv},
|
||||
}
|
||||
for _, tt := range remoteTests {
|
||||
u.Must(socket.GetPeerName(windows.Handle(tt.giveConn.sock.handle), &ra))
|
||||
u.Must(socket.GetPeerName(tt.giveConn.sock.handle, &ra))
|
||||
sa.fromRaw(&ra)
|
||||
if sa != tt.giveConn.remote {
|
||||
t.Errorf("%s remote addr give: %v; want: %v", tt.name, sa, tt.giveConn.remote)
|
||||
|
||||
Reference in New Issue
Block a user