diff options
author | Luigi Rizzo <luigi@FreeBSD.org> | 1999-08-12 05:40:07 +0000 |
---|---|---|
committer | Luigi Rizzo <luigi@FreeBSD.org> | 1999-08-12 05:40:07 +0000 |
commit | a18ff8bea76cfef2af67ccf8fc98e1966626d494 (patch) | |
tree | 593b5f71e72e79af0db13a2772ee2549aa550263 /release/picobsd/tinyware/ns/ns.c | |
parent | e2bd328224d2ade26183c20a7b180cbf9c5cd70d (diff) | |
download | src-a18ff8bea76cfef2af67ccf8fc98e1966626d494.tar.gz src-a18ff8bea76cfef2af67ccf8fc98e1966626d494.zip |
Fix a problem in printing interface names.
Notes
Notes:
svn path=/head/; revision=49653
Diffstat (limited to 'release/picobsd/tinyware/ns/ns.c')
-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 e8dd253e6dcb..7f3db556cbc6 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); |