Skip to content

Commit 1df86e7

Browse files
authored
Set SOCK_CLOEXEC on netlink socket (#165)
Set `SOCK_CLOEXEC` when creating the socket to avoid leaking file descriptors. Signed-off-by: Noel Georgi <[email protected]>
1 parent f626137 commit 1df86e7

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ This project adheres to [Semantic Versioning](http://semver.org/).
1010
### Changed
1111

1212
- Fix panic in `parseSockaddr` for malformed socket address. [#152](https://github.com/elastic/go-libaudit/pull/152)
13+
- Set `SOCK_CLOEXEC` when creating the netlink socket to avoid leaking file descriptors. [#165](https://github.com/elastic/go-libaudit/pull/165)
1314

1415
### Removed
1516

netlink.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ type NetlinkClient struct {
7777
//
7878
// The returned NetlinkClient must be closed with Close() when finished.
7979
func NewNetlinkClient(proto int, groups uint32, readBuf []byte, resp io.Writer) (*NetlinkClient, error) {
80-
s, err := syscall.Socket(syscall.AF_NETLINK, syscall.SOCK_RAW, proto)
80+
s, err := syscall.Socket(syscall.AF_NETLINK, syscall.SOCK_RAW|syscall.SOCK_CLOEXEC, proto)
8181
if err != nil {
8282
return nil, err
8383
}

0 commit comments

Comments
 (0)