diff options
author | luigi <luigi@FreeBSD.org> | 1999-08-12 05:40:07 +0000 |
---|---|---|
committer | luigi <luigi@FreeBSD.org> | 1999-08-12 05:40:07 +0000 |
commit | cf902ddda01f66e310c8be488f0a5f2fc061e758 (patch) | |
tree | d3f98c998b415310896cfae4d8ce033ce82be86d /release | |
parent | a97a8415d6f1d2725b828c835a6203a9dd704813 (diff) | |
download | FreeBSD-src-cf902ddda01f66e310c8be488f0a5f2fc061e758.zip FreeBSD-src-cf902ddda01f66e310c8be488f0a5f2fc061e758.tar.gz |
Fix a problem in printing interface names.
Diffstat (limited to 'release')
-rw-r--r-- | release/picobsd/tinyware/ns/ns.c | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/release/picobsd/tinyware/ns/ns.c b/release/picobsd/tinyware/ns/ns.c index e8dd253..7f3db55 100644 --- a/release/picobsd/tinyware/ns/ns.c +++ b/release/picobsd/tinyware/ns/ns.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: ns.c,v 1.4 1998/09/07 06:41:14 abial Exp $ + * $Id: ns.c,v 1.5 1998/10/09 12:42:20 abial Exp $ */ @@ -135,11 +135,15 @@ sock_ntop(const struct sockaddr *sa, size_t salen) } case AF_LINK: { struct sockaddr_dl *sdl = (struct sockaddr_dl *) sa; + int l = sdl->sdl_nlen ; - if (sdl->sdl_nlen > 0) - snprintf(str, sizeof(str), "%*s", - sdl->sdl_nlen, &sdl->sdl_data[0]); - else + if (l >= sizeof(str) ) + l = sizeof(str) - 1 ; + + if (l > 0) { + strncpy(str, &sdl->sdl_data[0], l); + str[l] = '\0'; + } else snprintf(str, sizeof(str), "link#%d", sdl->sdl_index); return(str); } @@ -303,16 +307,15 @@ print_routing(char *proto) printf("----------------\n"); printf("Name Mtu Network Address " "Ipkts Ierrs Opkts Oerrs Coll\n"); - } - i=0; - for(next=if_buf;next<lim;next+=ifm->ifm_msglen) { + i=0; + for(next=if_buf;next<lim;next+=ifm->ifm_msglen) { ifm=(struct if_msghdr *)next; if_table[i]=(struct sockaddr *)(ifm+1); ifm_table[i]=ifm; sa = if_table[i]; - if (iflag && sa->sa_family == AF_LINK) { + if (sa->sa_family == AF_LINK) { struct sockaddr_dl *sdl = (struct sockaddr_dl *) sa; printf("%-4s %-5d <Link> ", @@ -333,6 +336,7 @@ print_routing(char *proto) ); } i++; + } } if (!rflag) { free(rt_buf); |