1
0
mirror of https://github.com/nmap/nmap.git synced 2026-01-04 05:39:01 +00:00

Properly handle interfaces with NULL addresses

Some vsnprintf implementations (or perhaps some compiler options?) don't
like formatting NULL as %s, and will segfault (ran into this with
libstdc++ on Solaris). We don't get bug reports because at least some
(including mine on Ubuntu) will simply format it as "(null)".

This patch adds explicit checking for NULL to avoid the segfault
condition.
This commit is contained in:
dmiller
2014-06-26 02:53:57 +00:00
parent add985a2d1
commit a0a94f9303

View File

@@ -364,6 +364,7 @@ int print_iflist(void) {
struct sys_route *routes;
NmapOutputTable *Tbl = NULL;
char errstr[256];
const char *address = NULL;
errstr[0]='\0';
iflist = getinterfaces(&numifs, errstr, sizeof(errstr));
@@ -388,8 +389,10 @@ int print_iflist(void) {
Tbl->addItem(i + 1, devcol, false, iflist[i].devfullname);
Tbl->addItemFormatted(i + 1, shortdevcol, false, "(%s)",
iflist[i].devname);
fprintf(stderr,"dev %s, AF %d\n", iflist[i].devname, iflist[i].addr.ss_family);
address = inet_ntop_ez(&(iflist[i].addr), sizeof(iflist[i].addr));
Tbl->addItemFormatted(i + 1, ipcol, false, "%s/%d",
inet_ntop_ez(&(iflist[i].addr), sizeof(iflist[i].addr)),
address == NULL ? "(none)" : address,
iflist[i].netmask_bits);
if (iflist[i].device_type == devt_ethernet) {
Tbl->addItem(i + 1, typecol, false, "ethernet");