From 3833d31ed6f4102de058cf04fab6e66997f2b53c Mon Sep 17 00:00:00 2001 From: david Date: Mon, 7 Sep 2009 22:04:56 +0000 Subject: [PATCH] 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. --- tcpip.cc | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tcpip.cc b/tcpip.cc index 17af30b4d..a2ff7aeb4 100644 --- a/tcpip.cc +++ b/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) {