aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--networking/route.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/networking/route.c b/networking/route.c
index d82b0132a..65c2fb7c8 100644
--- a/networking/route.c
+++ b/networking/route.c
@@ -494,6 +494,7 @@ void FAST_FUNC bb_displayroutes(int noresolve, int netstatfmt)
494{ 494{
495 char devname[64], flags[16], *sdest, *sgw; 495 char devname[64], flags[16], *sdest, *sgw;
496 unsigned long d, g, m; 496 unsigned long d, g, m;
497 int r;
497 int flgs, ref, use, metric, mtu, win, ir; 498 int flgs, ref, use, metric, mtu, win, ir;
498 struct sockaddr_in s_addr; 499 struct sockaddr_in s_addr;
499 struct in_addr mask; 500 struct in_addr mask;
@@ -504,20 +505,24 @@ void FAST_FUNC bb_displayroutes(int noresolve, int netstatfmt)
504 "Destination Gateway Genmask Flags %s Iface\n", 505 "Destination Gateway Genmask Flags %s Iface\n",
505 netstatfmt ? " MSS Window irtt" : "Metric Ref Use"); 506 netstatfmt ? " MSS Window irtt" : "Metric Ref Use");
506 507
507 if (fscanf(fp, "%*[^\n]\n") < 0) { /* Skip the first line. */ 508 /* Skip the first line. */
508 goto ERROR; /* Empty or missing line, or read error. */ 509 r = fscanf(fp, "%*[^\n]\n");
510 if (r < 0) {
511 /* Empty line, read error, or EOF. Yes, if routing table
512 * is completely empty, /proc/net/route has no header.
513 */
514 goto ERROR;
509 } 515 }
510 while (1) { 516 while (1) {
511 int r;
512 r = fscanf(fp, "%63s%lx%lx%X%d%d%d%lx%d%d%d\n", 517 r = fscanf(fp, "%63s%lx%lx%X%d%d%d%lx%d%d%d\n",
513 devname, &d, &g, &flgs, &ref, &use, &metric, &m, 518 devname, &d, &g, &flgs, &ref, &use, &metric, &m,
514 &mtu, &win, &ir); 519 &mtu, &win, &ir);
515 if (r != 11) { 520 if (r != 11) {
521 ERROR:
516 if ((r < 0) && feof(fp)) { /* EOF with no (nonspace) chars read. */ 522 if ((r < 0) && feof(fp)) { /* EOF with no (nonspace) chars read. */
517 break; 523 break;
518 } 524 }
519 ERROR: 525 bb_perror_msg_and_die(bb_msg_read_error);
520 bb_error_msg_and_die("fscanf");
521 } 526 }
522 527
523 if (!(flgs & RTF_UP)) { /* Skip interfaces that are down. */ 528 if (!(flgs & RTF_UP)) { /* Skip interfaces that are down. */
@@ -583,7 +588,7 @@ static void INET6_displayroutes(void)
583 break; 588 break;
584 } 589 }
585 ERROR: 590 ERROR:
586 bb_error_msg_and_die("fscanf"); 591 bb_perror_msg_and_die(bb_msg_read_error);
587 } 592 }
588 593
589 /* Do the addr6x shift-and-insert changes to ':'-delimit addresses. 594 /* Do the addr6x shift-and-insert changes to ':'-delimit addresses.