[Python-checkins] r60214 - python/trunk/Modules/socketmodule.c

armin.rigo python-checkins at python.org
Wed Jan 23 15:07:13 CET 2008


Author: armin.rigo
Date: Wed Jan 23 15:07:13 2008
New Revision: 60214

Modified:
   python/trunk/Modules/socketmodule.c
Log:
patch 1754489 by vlahan:
improve portability of address length calculation for AF_UNIX sockets


Modified: python/trunk/Modules/socketmodule.c
==============================================================================
--- python/trunk/Modules/socketmodule.c	(original)
+++ python/trunk/Modules/socketmodule.c	Wed Jan 23 15:07:13 2008
@@ -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;
 	}


More information about the Python-checkins mailing list