Mercurial > cpython-lru_cache-weakref
diff Modules/socketmodule.c @ 17737:0ebfe9a1eb43 legacy-trunk
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.
PySocketSock_recvfrom(): Use PyString_AS_STRING() to get the data pointer
of a string we create ourselves; there is no need for the extra type
check from PyString_AsString().
This closes SF bug #416573.
| author | Fred Drake <fdrake@acm.org> |
|---|---|
| date | Wed, 09 May 2001 19:11:33 +0000 |
| parents | e1c507cdc6f1 |
| children | 3380279612a3 |
line wrap: on
line diff
--- a/Modules/socketmodule.c Wed May 09 18:53:51 2001 +0000 +++ b/Modules/socketmodule.c Wed May 09 19:11:33 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,7 +1362,8 @@ if (buf == NULL) return NULL; Py_BEGIN_ALLOW_THREADS - n = recvfrom(s->sock_fd, PyString_AsString(buf), len, flags, + memset(addrbuf, 0, addrlen); + n = recvfrom(s->sock_fd, PyString_AS_STRING(buf), len, flags, #ifndef MS_WINDOWS #if defined(PYOS_OS2) (struct sockaddr *)addrbuf, &addrlen
