]> The Tcpdump Group git mirrors - tcpdump/commitdiff
Use sizeof to get sizes of various structure members, rather than
authorguy <guy>
Sun, 13 Nov 2005 20:23:09 +0000 (20:23 +0000)
committerguy <guy>
Sun, 13 Nov 2005 20:23:09 +0000 (20:23 +0000)
hardwiring the sizes (which runs the risk that the hardwired size in the
structure definition and code could get out of sync).

print-802_11.c

index 2f0a21cc87fefe2dba7fd7795d86dc5bab027f7f..891439e0373a7ce3e1f614315c2e3b541d0629c4 100644 (file)
@@ -22,7 +22,7 @@
 
 #ifndef lint
 static const char rcsid[] _U_ =
-    "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.31.2.9 2005-11-13 20:03:53 guy Exp $ (LBL)";
+    "@(#) $Header: /tcpdump/master/tcpdump/print-802_11.c,v 1.31.2.10 2005-11-13 20:23:09 guy Exp $ (LBL)";
 #endif
 
 #ifdef HAVE_CONFIG_H
@@ -177,7 +177,8 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset)
                        memcpy(&pbody->ssid, p + offset, 2);
                        offset += 2;
                        if (pbody->ssid.length != 0) {
-                               if (pbody->ssid.length > 32)
+                               if (pbody->ssid.length >
+                                   sizeof(pbody->ssid.ssid) - 1)
                                        return;
                                if (!TTEST2(*(p + offset), pbody->ssid.length))
                                        return;
@@ -197,7 +198,8 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset)
                        memcpy(&pbody->challenge, p + offset, 2);
                        offset += 2;
                        if (pbody->challenge.length != 0) {
-                               if (pbody->challenge.length > 253)
+                               if (pbody->challenge.length >
+                                   sizeof(pbody->challenge.text) - 1)
                                        return;
                                if (!TTEST2(*(p + offset), pbody->challenge.length))
                                        return;
@@ -262,7 +264,7 @@ parse_elements(struct mgmt_body_t *pbody, const u_char *p, int offset)
 
                        if (pbody->tim.length <= 3)
                                break;
-                       if (pbody->rates.length > 251)
+                       if (pbody->rates.length > sizeof pbody->tim.bitmap)
                                return;
                        if (!TTEST2(*(p + offset), pbody->tim.length - 3))
                                return;