1
0
mirror of https://github.com/nmap/nmap.git synced 2025-12-07 13:11:28 +00:00

Be more robust in parsing /proc/net/route. Check for a missing interface

name. If the destination is missing, ignore that line and continue with
the next line rather than giving up on the whole file. Patch by Ankur
Nandwani.
This commit is contained in:
david
2009-09-07 22:04:56 +00:00
parent 45533e5972
commit 3833d31ed6

View File

@@ -3265,6 +3265,10 @@ static struct sys_route *getsysroutes_proc(FILE * routefp, int *howmany) {
continue; /* Deleted route -- any other valid reason for a route to start with an asterict? */
Strncpy(iface, p, sizeof(iface));
p = strtok(NULL, " \t\n");
if (!p) {
error("Could not find destination in /proc/net/route line");
continue;
}
endptr = NULL;
routes[numroutes].dest = strtoul(p, &endptr, 16);
if (!endptr || *endptr) {
@@ -3274,8 +3278,10 @@ static struct sys_route *getsysroutes_proc(FILE * routefp, int *howmany) {
/* Now for the gateway */
p = strtok(NULL, " \t\n");
if (!p)
break;
if (!p) {
error("Could not find gateway in /proc/net/route line");
continue;
}
endptr = NULL;
routes[numroutes].gw.s_addr = strtoul(p, &endptr, 16);
if (!endptr || *endptr) {