diff options
author | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2001-03-21 15:32:28 +0000 |
---|---|---|
committer | Jun-ichiro itojun Hagino <itojun@cvs.openbsd.org> | 2001-03-21 15:32:28 +0000 |
commit | 76d93e205c9f78ded4046808541f6978331d3bc6 (patch) | |
tree | 605bf544ed4ced7d015c4cf2db6f9f19093f6f5c /usr.sbin | |
parent | cb9f7086a2d5fd28bb1f28c39c6d1e71dbdb1f19 (diff) |
do not dereference null pointer. from kame
Diffstat (limited to 'usr.sbin')
-rw-r--r-- | usr.sbin/ndp/ndp.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/usr.sbin/ndp/ndp.c b/usr.sbin/ndp/ndp.c index a1baebee283..c8aedbad3d3 100644 --- a/usr.sbin/ndp/ndp.c +++ b/usr.sbin/ndp/ndp.c @@ -1,5 +1,5 @@ -/* $OpenBSD: ndp.c,v 1.9 2001/02/08 08:35:17 itojun Exp $ */ -/* $KAME: ndp.c,v 1.56 2001/02/08 07:36:45 itojun Exp $ */ +/* $OpenBSD: ndp.c,v 1.10 2001/03/21 15:32:27 itojun Exp $ */ +/* $KAME: ndp.c,v 1.62 2001/03/21 15:26:32 itojun Exp $ */ /* * Copyright (C) 1995, 1996, 1997, 1998, and 1999 WIDE Project. @@ -565,6 +565,7 @@ dump(addr) int llwidth; int ifwidth; char flgbuf[8]; + char *ifname; /* Print header */ if (!tflag && !cflag) @@ -629,14 +630,15 @@ again:; llwidth = strlen(ether_str(sdl)); if (W_ADDR + W_LL - addrwidth > llwidth) llwidth = W_ADDR + W_LL - addrwidth; - ifwidth = strlen(if_indextoname(sdl->sdl_index, - ifix_buf)); + ifname = if_indextoname(sdl->sdl_index, ifix_buf); + if (!ifname) + ifname = "?"; + ifwidth = strlen(ifname); if (W_ADDR + W_LL + W_IF - addrwidth - llwidth > ifwidth) ifwidth = W_ADDR + W_LL + W_IF - addrwidth - llwidth; printf("%-*.*s %-*.*s %*.*s", addrwidth, addrwidth, host_buf, - llwidth, llwidth, ether_str(sdl), ifwidth, ifwidth, - if_indextoname(sdl->sdl_index, ifix_buf)); + llwidth, llwidth, ether_str(sdl), ifwidth, ifwidth, ifname); /* Print neighbor discovery specific informations */ nbi = getnbrinfo(&sin->sin6_addr, sdl->sdl_index, 1); |