WARNINGS=Yes says:

/usr/src/usr.sbin/ndp/ndp.c: In function 'dump':
/usr/src/usr.sbin/ndp/ndp.c:564: warning: 'lim' may be used uninitialized in 
this function

The warning looks legitimate, IIUC there's room here for invalid memory
accesses (those would probably involve ndp -A).  Here's a fix proposal.

ok?


Index: ndp.c
===================================================================
RCS file: /cvs/src/usr.sbin/ndp/ndp.c,v
retrieving revision 1.74
diff -u -p -r1.74 ndp.c
--- ndp.c       31 Jul 2016 19:23:24 -0000      1.74
+++ ndp.c       31 Jul 2016 19:37:11 -0000
@@ -579,6 +579,7 @@ dump(struct in6_addr *addr, int cflag)
                    W_IF, W_IF, "Netif", "Expire", "S", "Flags");
 
 again:;
+       lim = NULL;
        mib[0] = CTL_NET;
        mib[1] = PF_ROUTE;
        mib[2] = 0;
@@ -602,7 +603,7 @@ again:;
                break;
        }
 
-       for (next = buf; next && next < lim; next += rtm->rtm_msglen) {
+       for (next = buf; next && lim && next < lim; next += rtm->rtm_msglen) {
                int isrouter = 0, prbs = 0;
 
                rtm = (struct rt_msghdr *)next;


-- 
jca | PGP: 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

Reply via email to