diff options
author | Armin Rigo <arigo@tunes.org> | 2008-01-23 14:07:13 (GMT) |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2008-01-23 14:07:13 (GMT) |
commit | 964ca4274f2a1bea783b52e74c71d2dcfdb4fafc (patch) | |
tree | e9f933ab201279e2da073f369bb708626f92e2b7 /Modules/socketmodule.c | |
parent | 501dbbfb70b123e34f764f50cfd0bf68098c95a0 (diff) | |
download | cpython-964ca4274f2a1bea783b52e74c71d2dcfdb4fafc.zip cpython-964ca4274f2a1bea783b52e74c71d2dcfdb4fafc.tar.gz cpython-964ca4274f2a1bea783b52e74c71d2dcfdb4fafc.tar.bz2 |
patch 1754489 by vlahan:
improve portability of address length calculation for AF_UNIX sockets
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r-- | Modules/socketmodule.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 88d2a70..d5114e8 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -1001,7 +1001,7 @@ makesockaddr(int sockfd, struct sockaddr *addr, int addrlen, int proto) struct sockaddr_un *a = (struct sockaddr_un *) addr; #ifdef linux if (a->sun_path[0] == 0) { /* Linux abstract namespace */ - addrlen -= (sizeof(*a) - sizeof(a->sun_path)); + addrlen -= offsetof(struct sockaddr_un, sun_path); return PyString_FromStringAndSize(a->sun_path, addrlen); } @@ -1207,7 +1207,7 @@ getsockaddrarg(PySocketSockObject *s, PyObject *args, #if defined(PYOS_OS2) *len_ret = sizeof(*addr); #else - *len_ret = len + sizeof(*addr) - sizeof(addr->sun_path); + *len_ret = len + offsetof(struct sockaddr_un, sun_path); #endif return 1; } |