mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
[3.10] bpo-44493: Add missing terminated NUL in sockaddr_un's length (GH-26866) (GH-32140)
Add missing terminated NUL in sockaddr_un's length
- Linux: https://man7.org/linux/man-pages/man7/unix.7.html
- *BSD: SUN_LEN
(cherry picked from commit f6b3a07b7d
)
Co-authored-by: ty <zonyitoo@users.noreply.github.com>
Automerge-Triggered-By: GH:gpshead
This commit is contained in:
parent
9194a7b899
commit
5944807b09
2 changed files with 9 additions and 1 deletions
|
@ -1680,6 +1680,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 */
|
||||
|
@ -1691,10 +1693,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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue