Mercurial > cpython-lru_cache-weakref
diff Modules/socketmodule.c @ 44887:dfd21793a5b5 legacy-trunk
patch 1754489 by vlahan:
improve portability of address length calculation for AF_UNIX sockets
| author | Armin Rigo <arigo@tunes.org> |
|---|---|
| date | Wed, 23 Jan 2008 14:07:13 +0000 |
| parents | 3c9ccc32da9a |
| children | 21139ea59b6b |
line wrap: on
line diff
--- a/Modules/socketmodule.c Wed Jan 23 14:00:25 2008 +0000 +++ b/Modules/socketmodule.c Wed Jan 23 14:07:13 2008 +0000 @@ -1001,7 +1001,7 @@ 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 @@ #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; }
