diff options
author | Alastair Houghton <alastair@alastairs-place.net> | 2019-11-22 19:17:25 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-11-22 19:17:25 +0000 |
commit | 0a8caf4819a4a65b5fac652e01437b849ee0dd61 (patch) | |
tree | 058b6b67eacbbff9d123d20fdf13c55edfff03de | |
parent | 0441ead2f5a4d3c5cb524cb2503ea157328f3dc6 (diff) | |
parent | b5bf04316373de3909615ea692027117618662a0 (diff) | |
download | netifaces-git-0a8caf4819a4a65b5fac652e01437b849ee0dd61.tar.gz |
Merge pull request #42 from rajendra-dendukuri/segfault_ifaddresses
Fix segfault when trying to access netifaces.ifaddresses
-rw-r--r-- | netifaces.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/netifaces.c b/netifaces.c index fa18add..c73d14b 100644 --- a/netifaces.c +++ b/netifaces.c @@ -1024,7 +1024,7 @@ ifaddrs (PyObject *self, PyObject *args) char buffer[256]; PyObject *pyaddr = NULL, *netmask = NULL, *braddr = NULL, *flags = NULL; - if (strcmp (addr->ifa_name, ifname) != 0) + if (addr->ifa_name == NULL || strcmp (addr->ifa_name, ifname) != 0) continue; /* We mark the interface as found, even if there are no addresses; @@ -1357,6 +1357,9 @@ interfaces (PyObject *self) } for (addr = addrs; addr; addr = addr->ifa_next) { + if (addr->ifa_name == NULL) + continue; + if (!prev_name || strncmp (addr->ifa_name, prev_name, IFNAMSIZ) != 0) { PyObject *ifname = PyUnicode_FromString (addr->ifa_name); |