]> The Tcpdump Group git mirrors - tcpdump/blobdiff - print-rx.c
Handle IPX socket 0x553, which is some kind of NetBIOS-over-IPX socket.
[tcpdump] / print-rx.c
index cff131c553274575a347b5009bf8a27fba15b638..2fb3d2a8a96213273bdfe563d446342ab52de184 100644 (file)
@@ -13,7 +13,7 @@
 
 #ifndef lint
 static const char rcsid[] =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.15 2000-07-29 09:20:26 assar Exp $";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-rx.c,v 1.20 2001-01-10 08:12:01 fenner Exp $";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -21,6 +21,7 @@ static const char rcsid[] =
 #endif
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <string.h>
 #include <time.h>
 #include <sys/param.h>
@@ -28,8 +29,6 @@ static const char rcsid[] =
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <netinet/in.h>
-#include <netinet/in_systm.h>
-#include <netinet/ip.h>
 #include <arpa/inet.h>
 
 #include "interface.h"
@@ -41,6 +40,8 @@ static const char rcsid[] =
 
 #include "rx.h"
 
+#include "ip.h"
+
 static struct tok rx_types[] = {
        { RX_PACKET_TYPE_DATA,          "data" },
        { RX_PACKET_TYPE_ACK,           "ack" },
@@ -377,7 +378,7 @@ static int  rx_cache_find(const struct rx_header *, const struct ip *,
 static void ack_print(const u_char *, int);
 static void fs_print(const u_char *, int);
 static void fs_reply_print(const u_char *, int, int32_t);
-static void acl_print(u_char *, u_char *);
+static void acl_print(u_char *, int, u_char *);
 static void cb_print(const u_char *, int);
 static void cb_reply_print(const u_char *, int, int32_t);
 static void prot_print(const u_char *, int);
@@ -729,7 +730,7 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
                        printf(" \"%s\"", s); \
                }
 
-void
+static void
 ack_print(register const u_char *bp, int length)
 {
         u_char nAcks;
@@ -802,7 +803,7 @@ trunc:
  * Handle calls to the AFS file service (fs)
  */
 
-void
+static void
 fs_print(register const u_char *bp, int length)
 {
        int fs_op;
@@ -870,15 +871,16 @@ fs_print(register const u_char *bp, int length)
                        break;
                case 134:       /* Store ACL */
                {
-                       char a[AFSOPAQUEMAX];
+                       char a[AFSOPAQUEMAX+1];
                        FIDOUT();
                        TCHECK2(bp[0], 4);
                        i = EXTRACT_32BITS(bp);
                        bp += sizeof(int32_t);
                        TCHECK2(bp[0], i);
-                       strncpy(a, (char *) bp, min(AFSOPAQUEMAX, i));
+                       i = min(AFSOPAQUEMAX, i);
+                       strncpy(a, (char *) bp, i);
                        a[i] = '\0';
-                       acl_print((u_char *) a, (u_char *) a + i);
+                       acl_print((u_char *) a, sizeof(a), (u_char *) a + i);
                        break;
                }
                case 137:       /* Create file */
@@ -982,14 +984,15 @@ fs_reply_print(register const u_char *bp, int length, int32_t opcode)
                switch (opcode) {
                case 131:       /* Fetch ACL */
                {
-                       char a[AFSOPAQUEMAX];
+                       char a[AFSOPAQUEMAX+1];
                        TCHECK2(bp[0], 4);
                        i = EXTRACT_32BITS(bp);
                        bp += sizeof(int32_t);
                        TCHECK2(bp[0], i);
-                       strncpy(a, (char *) bp, min(AFSOPAQUEMAX, i));
+                       i = min(AFSOPAQUEMAX, i);
+                       strncpy(a, (char *) bp, i);
                        a[i] = '\0';
-                       acl_print((u_char *) a, (u_char *) a + i);
+                       acl_print((u_char *) a, sizeof(a), (u_char *) a + i);
                        break;
                }
                case 137:       /* Create file */
@@ -1043,19 +1046,22 @@ trunc:
  */
 
 static void
-acl_print(u_char *s, u_char *end)
+acl_print(u_char *s, int maxsize, u_char *end)
 {
        int pos, neg, acl;
        int n, i;
-       char user[128];
+       char *user;
 
-       if (sscanf((char *) s, "%d %d\n%n", &pos, &neg, &n) != 2)
+       if ((user = (char *)malloc(maxsize)) == NULL)
                return;
+
+       if (sscanf((char *) s, "%d %d\n%n", &pos, &neg, &n) != 2)
+               goto finish;
        
        s += n;
 
        if (s > end)
-               return;
+               goto finish;
 
        /*
         * This wacky order preserves the order used by the "fs" command
@@ -1079,25 +1085,29 @@ acl_print(u_char *s, u_char *end)
 
        for (i = 0; i < pos; i++) {
                if (sscanf((char *) s, "%s %d\n%n", user, &acl, &n) != 2)
-                       return;
+                       goto finish;
                s += n;
                printf(" +{%s ", user);
                ACLOUT(acl);
                printf("}");
                if (s > end)
-                       return;
+                       goto finish;
        }
 
        for (i = 0; i < neg; i++) {
                if (sscanf((char *) s, "%s %d\n%n", user, &acl, &n) != 2)
-                       return;
+                       goto finish;
                s += n;
                printf(" -{%s ", user);
                ACLOUT(acl);
                printf("}");
                if (s > end)
-                       return;
+                       goto finish;
        }
+
+finish:
+       free(user);
+       return;
 }
 
 #undef ACLOUT
@@ -2324,7 +2334,7 @@ trunc:
  * Handle RX ACK packets.
  */
 
-void
+static void
 rx_ack_print(register const u_char *bp, int length)
 {
        struct rx_ackPacket *rxa;