diff options
author | ty <zonyitoo@users.noreply.github.com> | 2022-03-27 20:22:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-03-27 20:22:22 (GMT) |
commit | f6b3a07b7df60dc04d0260169ffef6e9796a2124 (patch) | |
tree | 637ec249702ec8780825ad01f7ba3cd1a90c3696 /Modules/socketmodule.c | |
parent | 58448cbd96f77ebc6fca1f8030bedc7744eb66ef (diff) | |
download | cpython-f6b3a07b7df60dc04d0260169ffef6e9796a2124.zip cpython-f6b3a07b7df60dc04d0260169ffef6e9796a2124.tar.gz cpython-f6b3a07b7df60dc04d0260169ffef6e9796a2124.tar.bz2 |
bpo-44493: Add missing terminated NUL in sockaddr_un's length (GH-26866)
Add missing terminated NUL in sockaddr_un's length
- Linux: https://man7.org/linux/man-pages/man7/unix.7.html
- *BSD: SUN_LEN
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r-- | Modules/socketmodule.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 7f7af18..c7bc10b 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -1689,6 +1689,8 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, "AF_UNIX path too long"); goto unix_out; } + + *len_ret = path.len + offsetof(struct sockaddr_un, sun_path); } else #endif /* linux */ @@ -1700,10 +1702,13 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, goto unix_out; } addr->sun_path[path.len] = 0; + + /* including the tailing NUL */ + *len_ret = path.len + offsetof(struct sockaddr_un, sun_path) + 1; } addr->sun_family = s->sock_family; memcpy(addr->sun_path, path.buf, path.len); - *len_ret = path.len + offsetof(struct sockaddr_un, sun_path); + retval = 1; unix_out: PyBuffer_Release(&path); |