summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorAntoine Pitrou <pitrou@free.fr>2017-05-02 22:14:29 (GMT)
committerGitHub <noreply@github.com>2017-05-02 22:14:29 (GMT)
commit0c2ff0898db2db9cd9c643dfadbff11761bacf5f (patch)
tree088ce426f1f31178b6a3e1c7f1db78b3074c9bb3 /Modules
parent4dae0d111dd7bb34ec730eea2327a3219acff211 (diff)
downloadcpython-0c2ff0898db2db9cd9c643dfadbff11761bacf5f.zip
cpython-0c2ff0898db2db9cd9c643dfadbff11761bacf5f.tar.gz
cpython-0c2ff0898db2db9cd9c643dfadbff11761bacf5f.tar.bz2
Backport bpo-30205 to 3.6 (#1403)
Diffstat (limited to 'Modules')
-rw-r--r--Modules/socketmodule.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index f3654c9..42aec59 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1212,9 +1212,9 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto)
{
struct sockaddr_un *a = (struct sockaddr_un *) addr;
#ifdef __linux__
- if (a->sun_path[0] == 0) { /* Linux abstract namespace */
- addrlen -= offsetof(struct sockaddr_un, sun_path);
- return PyBytes_FromStringAndSize(a->sun_path, addrlen);
+ size_t linuxaddrlen = addrlen - offsetof(struct sockaddr_un, sun_path);
+ if (linuxaddrlen > 0 && a->sun_path[0] == 0) { /* Linux abstract namespace */
+ return PyBytes_FromStringAndSize(a->sun_path, linuxaddrlen);
}
else
#endif /* linux */