mirror of
https://github.com/nmap/nmap.git
synced 2025-12-08 21:51:28 +00:00
Display a warning if we can't read the first line (column headers) of
/proc/net/route. This also silences a _FORTIFY_SOURCE warning.
This commit is contained in:
12
tcpip.cc
12
tcpip.cc
@@ -3019,7 +3019,16 @@ static struct sys_route *getsysroutes_proc(FILE *routefp, int *howmany) {
|
|||||||
|
|
||||||
ifaces = getinterfaces(&numifaces);
|
ifaces = getinterfaces(&numifaces);
|
||||||
routes = (struct sys_route *) safe_zalloc(route_capacity * sizeof(struct sys_route));
|
routes = (struct sys_route *) safe_zalloc(route_capacity * sizeof(struct sys_route));
|
||||||
(void) fgets(buf, sizeof(buf), routefp); /* Kill the first line (column headers) */
|
|
||||||
|
/* Kill the first line (column headers) */
|
||||||
|
errno = 0;
|
||||||
|
if (fgets(buf, sizeof(buf), routefp) == NULL) {
|
||||||
|
if (errno)
|
||||||
|
error("Read error in /proc/net/route");
|
||||||
|
else
|
||||||
|
error("Premature EOF in /proc/net/route");
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
while(fgets(buf,sizeof(buf), routefp)) {
|
while(fgets(buf,sizeof(buf), routefp)) {
|
||||||
p = strtok(buf, " \t\n");
|
p = strtok(buf, " \t\n");
|
||||||
if (!p) {
|
if (!p) {
|
||||||
@@ -3101,6 +3110,7 @@ static struct sys_route *getsysroutes_proc(FILE *routefp, int *howmany) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
done:
|
||||||
*howmany = numroutes;
|
*howmany = numroutes;
|
||||||
return routes;
|
return routes;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user