mirror of
https://github.com/rwinkhart/go-winio.git
synced 2026-09-05 16:47:31 -04:00
Allocate securityDescriptor in C memory
Signed-off-by: Darren Stahl <darst@microsoft.com>
This commit is contained in:
@@ -2,6 +2,9 @@
|
|||||||
|
|
||||||
package winio
|
package winio
|
||||||
|
|
||||||
|
// #include <stdlib.h>
|
||||||
|
import "C"
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"io"
|
"io"
|
||||||
@@ -21,7 +24,7 @@ import (
|
|||||||
|
|
||||||
type securityAttributes struct {
|
type securityAttributes struct {
|
||||||
Length uint32
|
Length uint32
|
||||||
SecurityDescriptor *byte
|
SecurityDescriptor unsafe.Pointer
|
||||||
InheritHandle uint32
|
InheritHandle uint32
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -231,12 +234,13 @@ func makeServerPipeHandle(path string, securityDescriptor []byte, c *PipeConfig,
|
|||||||
mode |= cPIPE_TYPE_MESSAGE
|
mode |= cPIPE_TYPE_MESSAGE
|
||||||
}
|
}
|
||||||
|
|
||||||
var sa securityAttributes
|
sa := &securityAttributes{}
|
||||||
sa.Length = uint32(unsafe.Sizeof(sa))
|
sa.Length = uint32(unsafe.Sizeof(*sa))
|
||||||
if securityDescriptor != nil {
|
if securityDescriptor != nil {
|
||||||
sa.SecurityDescriptor = &securityDescriptor[0]
|
sa.SecurityDescriptor = C.CBytes(securityDescriptor)
|
||||||
|
defer C.free(sa.SecurityDescriptor)
|
||||||
}
|
}
|
||||||
h, err := createNamedPipe(path, flags, mode, cPIPE_UNLIMITED_INSTANCES, uint32(c.OutputBufferSize), uint32(c.InputBufferSize), 0, &sa)
|
h, err := createNamedPipe(path, flags, mode, cPIPE_UNLIMITED_INSTANCES, uint32(c.OutputBufferSize), uint32(c.InputBufferSize), 0, sa)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, &os.PathError{Op: "open", Path: path, Err: err}
|
return 0, &os.PathError{Op: "open", Path: path, Err: err}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user