Commit 31f92309 authored by Georg Brandl's avatar Georg Brandl

Patch #1511317: don't crash on invalid hostname info

parent 530c1058
...@@ -3041,17 +3041,20 @@ gethost_common(struct hostent *h, struct sockaddr *addr, int alen, int af) ...@@ -3041,17 +3041,20 @@ gethost_common(struct hostent *h, struct sockaddr *addr, int alen, int af)
if ((addr_list = PyList_New(0)) == NULL) if ((addr_list = PyList_New(0)) == NULL)
goto err; goto err;
for (pch = h->h_aliases; *pch != NULL; pch++) { /* SF #1511317: h_aliases can be NULL */
int status; if (h->h_aliases) {
tmp = PyString_FromString(*pch); for (pch = h->h_aliases; *pch != NULL; pch++) {
if (tmp == NULL) int status;
goto err; tmp = PyString_FromString(*pch);
if (tmp == NULL)
status = PyList_Append(name_list, tmp); goto err;
Py_DECREF(tmp);
status = PyList_Append(name_list, tmp);
if (status) Py_DECREF(tmp);
goto err;
if (status)
goto err;
}
} }
for (pch = h->h_addr_list; *pch != NULL; pch++) { for (pch = h->h_addr_list; *pch != NULL; pch++) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment