summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2001-07-23 01:30:10 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2001-07-23 01:30:10 (GMT)
commit9db2f571c382ce41c29a87aaf717549ed4fed701 (patch)
treef1c6e5e6a112761f021a7dabbcf8c76de161ffb2 /Modules
parentb5c61a899e9d86d16c94b249a4e87ba8dab5bf92 (diff)
downloadcpython-9db2f571c382ce41c29a87aaf717549ed4fed701.zip
cpython-9db2f571c382ce41c29a87aaf717549ed4fed701.tar.gz
cpython-9db2f571c382ce41c29a87aaf717549ed4fed701.tar.bz2
Instead of accessing ss_family, cast sockaddr_storage to sockaddr and access sa_family.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/socketmodule.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index b44e9b8..7fa8264 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1894,6 +1894,7 @@ PySocket_gethostbyname_ex(PyObject *self, PyObject *args)
char *name;
struct hostent *h;
struct sockaddr_storage addr;
+ struct sockaddr *sa;
PyObject *ret;
#ifdef HAVE_GETHOSTBYNAME_R
struct hostent hp_allocated;
@@ -1931,7 +1932,10 @@ PySocket_gethostbyname_ex(PyObject *self, PyObject *args)
h = gethostbyname(name);
#endif /* HAVE_GETHOSTBYNAME_R */
Py_END_ALLOW_THREADS
- ret = gethost_common(h, (struct sockaddr *)&addr, sizeof(addr), addr.ss_family);
+ /* Some C libraries would require addr.__ss_family instead of addr.ss_family.
+ Therefore, we cast the sockaddr_storage into sockaddr to access sa_family. */
+ sa = (struct sockaddr*)&addr;
+ ret = gethost_common(h, (struct sockaddr *)&addr, sizeof(addr), sa->sa_family);
#ifdef USE_GETHOSTBYNAME_LOCK
PyThread_release_lock(gethostbyname_lock);
#endif