Skip to content

Commit

Permalink
Merge pull request #311 from doronz88/bugfix/unix-sock
Browse files Browse the repository at this point in the history
structs: fix unix sockaddr struct
  • Loading branch information
doronz88 authored Nov 6, 2023
2 parents 605525f + 387bcd8 commit 7b1b87d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/rpcclient/rpcclient/darwin/structs.py
Original file line number Diff line number Diff line change
Expand Up @@ -485,7 +485,8 @@ def _encode(self, obj, context, path):

# we can't use sockaddr_un since the sun_path may contain utf8 invalid characters
sockaddr_un_raw = Struct(
'sun_family' / Default(Int16sl, AF_UNIX),
'sun_len' / Int8ul,
'sun_family' / Default(Int8ul, AF_UNIX),
'_sun_path' / Bytes(UNIX_PATH_MAX),
'sun_path' / Computed(lambda x: x._sun_path.split(b'\x00', 1)[0].decode())
)
Expand Down
5 changes: 3 additions & 2 deletions src/rpcclient/rpcclient/structs/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

from rpcclient.structs.consts import AF_INET, AF_INET6, AF_UNIX

UNIX_PATH_MAX = 108
UNIX_PATH_MAX = 104

u_char = Int8ul
uint8_t = Int8ul
Expand Down Expand Up @@ -36,7 +36,8 @@
)

sockaddr_un = Struct(
'sun_family' / Default(Int16sl, AF_UNIX),
'sun_len' / Default(Int8ul, 0),
'sun_family' / Default(Int8ul, AF_UNIX),
'sun_path' / PaddedString(UNIX_PATH_MAX, 'utf8'),
)

Expand Down

0 comments on commit 7b1b87d

Please sign in to comment.