diff options
author | Georg Brandl <georg@python.org> | 2006-08-14 22:10:24 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-08-14 22:10:24 (GMT) |
commit | 9dc7b7ce82562c07fc7077124ef46ca15f5b9528 (patch) | |
tree | ef7a26b0b59d645282ec85a0e18880a8ed76abcc /Modules | |
parent | d76bd69712e04d496e88f878f13876ce9c1765b0 (diff) | |
download | cpython-9dc7b7ce82562c07fc7077124ef46ca15f5b9528.zip cpython-9dc7b7ce82562c07fc7077124ef46ca15f5b9528.tar.gz cpython-9dc7b7ce82562c07fc7077124ef46ca15f5b9528.tar.bz2 |
Patch #1511317: don't crash on invalid hostname info
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/socketmodule.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index bb99bde..f03b34c 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -3041,17 +3041,20 @@ gethost_common(struct hostent *h, struct sockaddr *addr, int alen, int af) if ((addr_list = PyList_New(0)) == NULL) goto err; - for (pch = h->h_aliases; *pch != NULL; pch++) { - int status; - tmp = PyString_FromString(*pch); - if (tmp == NULL) - goto err; - - status = PyList_Append(name_list, tmp); - Py_DECREF(tmp); - - if (status) - goto err; + /* SF #1511317: h_aliases can be NULL */ + if (h->h_aliases) { + for (pch = h->h_aliases; *pch != NULL; pch++) { + int status; + tmp = PyString_FromString(*pch); + if (tmp == NULL) + goto err; + + status = PyList_Append(name_list, tmp); + Py_DECREF(tmp); + + if (status) + goto err; + } } for (pch = h->h_addr_list; *pch != NULL; pch++) { |