mirror of
https://github.com/nmap/nmap.git
synced 2026-10-20 19:01:56 +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:
parent
45533e5972
commit
3833d31ed6
1 changed files with 8 additions and 2 deletions
10
tcpip.cc
10
tcpip.cc
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue