summaryrefslogtreecommitdiff
path: root/Modules
diff options
context:
space:
mode:
authorAntoine Pitrou <pitrou@free.fr>2017-05-03 00:22:28 +0200
committerGitHub <noreply@github.com>2017-05-03 00:22:28 +0200
commit0d9d61828bbd6cbc289489bf1d439fa91eca3743 (patch)
treeca5c576de6aed5c1014d0ea9a99f1601df91236f /Modules
parent360fb81367bb409bb7a1d261d88fcf82cee528f0 (diff)
downloadcpython-git-0d9d61828bbd6cbc289489bf1d439fa91eca3743.tar.gz
Backport bpo-30205 to 3.5 (#1404)
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 af6cc94415..47abe8d3f2 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1183,9 +1183,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 */