diff Modules/socketmodule.c @ 17738:820e5a0c3112 2.1

Three uses of makesockaddr() used sockaddr buffers that had not be cleared; this could cause invalid paths to be returned for AF_UNIX sockets on some platforms (including FreeBSD 4.2-RELEASE), appearantly because there is no assurance that the address will be nul-terminated when filled in by the kernel. This closes SF bug #416573.
author Fred Drake <fdrake@acm.org>
date Wed, 09 May 2001 19:13:40 +0000
parents e1c507cdc6f1
children d06446d4e78d
line wrap: on
line diff
--- a/Modules/socketmodule.c	Wed May 09 18:13:29 2001 +0000
+++ b/Modules/socketmodule.c	Wed May 09 19:13:40 2001 +0000
@@ -790,6 +790,7 @@
 		return NULL;
 	if (!getsockaddrlen(s, &addrlen))
 		return NULL;
+	memset(addrbuf, 0, addrlen);
 	Py_BEGIN_ALLOW_THREADS
 	newfd = accept(s->sock_fd, (struct sockaddr *) addrbuf, &addrlen);
 	Py_END_ALLOW_THREADS
@@ -1212,6 +1213,7 @@
 		return NULL;
 	if (!getsockaddrlen(s, &addrlen))
 		return NULL;
+	memset(addrbuf, 0, addrlen);
 	Py_BEGIN_ALLOW_THREADS
 	res = getpeername(s->sock_fd, (struct sockaddr *) addrbuf, &addrlen);
 	Py_END_ALLOW_THREADS
@@ -1360,6 +1362,7 @@
 	if (buf == NULL)
 		return NULL;
 	Py_BEGIN_ALLOW_THREADS
+	memset(addrbuf, 0, addrlen);
 	n = recvfrom(s->sock_fd, PyString_AsString(buf), len, flags,
 #ifndef MS_WINDOWS
 #if defined(PYOS_OS2)