Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/netbsd-1-4]: src/usr.sbin/tcpdump Pull up revisions 1.7-1.8 (requested b...



details:   https://anonhg.NetBSD.org/src/rev/0a77df1b1944
branches:  netbsd-1-4
changeset: 471197:0a77df1b1944
user:      he <he%NetBSD.org@localhost>
date:      Tue Oct 31 13:53:26 2000 +0000

description:
Pull up revisions 1.7-1.8 (requested by he):
  Change from sprintf() to snprintf() where we may print externally
  supplied data of unknown length.  Also fix an endianness problem.

diffstat:

 usr.sbin/tcpdump/print-atalk.c |  32 +++++++++++++++++---------------
 1 files changed, 17 insertions(+), 15 deletions(-)

diffs (82 lines):

diff -r 18cfbe52018d -r 0a77df1b1944 usr.sbin/tcpdump/print-atalk.c
--- a/usr.sbin/tcpdump/print-atalk.c    Tue Oct 31 12:31:25 2000 +0000
+++ b/usr.sbin/tcpdump/print-atalk.c    Tue Oct 31 13:53:26 2000 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: print-atalk.c,v 1.6 1997/10/03 19:55:01 christos Exp $ */
+/*     $NetBSD: print-atalk.c,v 1.6.4.1 2000/10/31 13:53:26 he Exp $   */
 
 /*
  * Copyright (c) 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997
@@ -29,7 +29,7 @@
 static const char rcsid[] =
     "@(#) Header: print-atalk.c,v 1.48 97/05/28 12:50:58 leres Exp  (LBL)";
 #else
-__RCSID("$NetBSD: print-atalk.c,v 1.6 1997/10/03 19:55:01 christos Exp $");
+__RCSID("$NetBSD: print-atalk.c,v 1.6.4.1 2000/10/31 13:53:26 he Exp $");
 #endif
 #endif
 
@@ -79,13 +79,13 @@
 };
 
 struct aarp {
-       u_short htype, ptype;
-       u_char  halen, palen;
-       u_short op;
-       u_char  hsaddr[6];
-       u_char  psaddr[4];
-       u_char  hdaddr[6];
-       u_char  pdaddr[4];
+       u_int16_t       htype, ptype;
+       u_int8_t        halen, palen;
+       u_int16_t       op;
+       u_int8_t        hsaddr[6];
+       u_int8_t        psaddr[4];
+       u_int8_t        hdaddr[6];
+       u_int8_t        pdaddr[4];
 };
 
 static char tstr[] = "[|atalk]";
@@ -196,9 +196,9 @@
 
        printf("aarp ");
        ap = (const struct aarp *)bp;
-       if (ap->htype == 1 && ap->ptype == ETHERTYPE_ATALK &&
+       if (ntohs(ap->htype) == 1 && ntohs(ap->ptype) == ETHERTYPE_ATALK &&
            ap->halen == 6 && ap->palen == 4 )
-               switch (ap->op) {
+               switch (ntohs(ap->op)) {
 
                case 1:                         /* request */
                        (void)printf("who-has %s tell %s",
@@ -215,8 +215,9 @@
                            AT(pdaddr), AT(psaddr));
                        return;
                }
-       (void)printf("len %d op %d htype %d ptype %#x halen %d palen %d",
-           length, ap->op, ap->htype, ap->ptype, ap->halen, ap->palen );
+       (void)printf("len %u op %u htype %u ptype %#x halen %u palen %u",
+           length, ntohs(ap->op), ntohs(ap->htype), ntohs(ap->ptype),
+           ap->halen, ap->palen);
 }
 
 static void
@@ -521,7 +522,7 @@
 {
        register struct hnamemem *tp, *tp2;
        register int i = (atnet << 8) | athost;
-       char nambuf[256];
+       char nambuf[MAXHOSTNAMELEN + 20];
        static int first = 1;
        FILE *fp;
 
@@ -568,7 +569,8 @@
                if (tp2->addr == i) {
                        tp->addr = (atnet << 8) | athost;
                        tp->nxt = newhnamemem();
-                       (void)sprintf(nambuf, "%s.%d", tp2->name, athost);
+                       (void)snprintf(nambuf, sizeof(nambuf), 
+                                       "%s.%d", tp2->name, athost);
                        tp->name = savestr(nambuf);
                        return (tp->name);
                }



Home | Main Index | Thread Index | Old Index