mirror of
https://github.com/nmap/nmap.git
synced 2026-08-04 14:49:29 +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:
parent
add985a2d1
commit
a0a94f9303
1 changed files with 4 additions and 1 deletions
|
|
@ -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");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue