convert variables that were static just because of SET_ADDRESS macro to use the prope...
authorMichael Mann <mmann78@netscape.net>
Thu, 8 Jan 2015 22:07:25 +0000 (17:07 -0500)
committerMichael Mann <mmann78@netscape.net>
Fri, 9 Jan 2015 01:10:05 +0000 (01:10 +0000)
Change-Id: I914918d9629f654ead497dddac0f412b690e4409
Reviewed-on: https://code.wireshark.org/review/6430
Reviewed-by: Michael Mann <mmann78@netscape.net>
epan/dissectors/packet-atalk.c
epan/dissectors/packet-fddi.c
epan/dissectors/packet-ieee802154.c
epan/dissectors/packet-mausb.c
epan/dissectors/packet-sna.c
epan/dissectors/packet-tr.c
epan/dissectors/packet-usb.c
epan/dissectors/packet-usb.h

index 1b030823a1c7e7afb67b9877dd96b2429c72419b..18234dd378688468c22d56fb31e2ef4d97e1897a 100644 (file)
@@ -1437,7 +1437,8 @@ dissect_ddp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
   e_ddp                         ddp;
   proto_tree                   *ddp_tree;
   proto_item                   *ti, *hidden_item;
-  static struct atalk_ddp_addr  src, dst; /* has to be static due to SET_ADDRESS */
+  struct atalk_ddp_addr        *src = wmem_new(pinfo->pool, struct atalk_ddp_addr),
+                               *dst = wmem_new(pinfo->pool, struct atalk_ddp_addr);
   tvbuff_t                     *new_tvb;
 
   col_set_str(pinfo->cinfo, COL_PROTOCOL, "DDP");
@@ -1449,14 +1450,14 @@ dissect_ddp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
   ddp.sum=g_ntohs(ddp.sum);
   ddp.hops_len=g_ntohs(ddp.hops_len);
 
-  src.net = ddp.snet;
-  src.node = ddp.snode;
-  dst.net = ddp.dnet;
-  dst.node = ddp.dnode;
-  SET_ADDRESS(&pinfo->net_src, AT_ATALK, sizeof src, (guint8 *)&src);
-  SET_ADDRESS(&pinfo->src, AT_ATALK, sizeof src, (guint8 *)&src);
-  SET_ADDRESS(&pinfo->net_dst, AT_ATALK, sizeof dst, (guint8 *)&dst);
-  SET_ADDRESS(&pinfo->dst, AT_ATALK, sizeof dst, (guint8 *)&dst);
+  src->net = ddp.snet;
+  src->node = ddp.snode;
+  dst->net = ddp.dnet;
+  dst->node = ddp.dnode;
+  SET_ADDRESS(&pinfo->net_src, AT_ATALK, sizeof src, src);
+  SET_ADDRESS(&pinfo->src, AT_ATALK, sizeof src, src);
+  SET_ADDRESS(&pinfo->net_dst, AT_ATALK, sizeof dst, dst);
+  SET_ADDRESS(&pinfo->dst, AT_ATALK, sizeof dst, dst);
 
   pinfo->ptype = PT_DDP;
   pinfo->destport = ddp.dport;
@@ -1471,11 +1472,11 @@ dissect_ddp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
     ddp_tree = proto_item_add_subtree(ti, ett_ddp);
 
     hidden_item = proto_tree_add_string(ddp_tree, hf_ddp_src, tvb,
-                                        4, 3, atalk_addr_to_str(&src));
+                                        4, 3, atalk_addr_to_str(src));
     PROTO_ITEM_SET_HIDDEN(hidden_item);
 
     hidden_item = proto_tree_add_string(ddp_tree, hf_ddp_dst, tvb,
-                                        6, 3, atalk_addr_to_str(&dst));
+                                        6, 3, atalk_addr_to_str(dst));
     PROTO_ITEM_SET_HIDDEN(hidden_item);
 
     proto_tree_add_uint(ddp_tree, hf_ddp_hopcount,   tvb, 0, 1,
index 0ec6ffb303ec31e0c554cabb0e4ea985fcf6ca44..279aec56493df1871f7ea542bd0203ac146690d7 100644 (file)
@@ -315,7 +315,7 @@ dissect_fddi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
   proto_item      *ti, *hidden_item;
   const gchar     *fc_str;
   proto_tree      *fc_tree;
-  static guchar    src[6], dst[6]; /* has to be static due to SET_ADDRESS */
+  guchar          *src = (guchar*)wmem_alloc(pinfo->pool, 6), *dst = (guchar*)wmem_alloc(pinfo->pool, 6);
   guchar           src_swapped[6], dst_swapped[6];
   tvbuff_t        *next_tvb;
   static fddi_hdr  fddihdrs[4];
@@ -370,9 +370,9 @@ dissect_fddi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
 
   /* XXX - copy them to some buffer associated with "pi", rather than
      just making "dst" static? */
-  SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, &dst[0]);
-  SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, &dst[0]);
-  SET_ADDRESS(&fddihdr->dst, AT_ETHER, 6, &dst[0]);
+  SET_ADDRESS(&pinfo->dl_dst, AT_ETHER, 6, dst);
+  SET_ADDRESS(&pinfo->dst, AT_ETHER, 6, dst);
+  SET_ADDRESS(&fddihdr->dst, AT_ETHER, 6, dst);
 
   if (fh_tree) {
     proto_tree_add_ether(fh_tree, hf_fddi_dst, tvb, FDDI_P_DHOST + FDDI_PADDING, 6, dst);
@@ -395,9 +395,9 @@ dissect_fddi(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree,
 
   /* XXX - copy them to some buffer associated with "pi", rather than
      just making "src" static? */
-  SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, &src[0]);
-  SET_ADDRESS(&pinfo->src, AT_ETHER, 6, &src[0]);
-  SET_ADDRESS(&fddihdr->src, AT_ETHER, 6, &src[0]);
+  SET_ADDRESS(&pinfo->dl_src, AT_ETHER, 6, src);
+  SET_ADDRESS(&pinfo->src, AT_ETHER, 6, src);
+  SET_ADDRESS(&fddihdr->src, AT_ETHER, 6, src);
 
   if (fh_tree) {
     proto_tree_add_ether(fh_tree, hf_fddi_src, tvb, FDDI_P_SHOST + FDDI_PADDING, 6, src);
index 742bfa5fa64688b8fb0684f1f8ccfa9f3bd1f4c1..3056740464f165645b48722e30296921dd0f53d3 100644 (file)
@@ -728,21 +728,16 @@ dissect_ieee802154_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g
         offset += 2;
     }
     else if (packet->dst_addr_mode == IEEE802154_FCF_ADDR_EXT) {
-        static guint64 addr; /* has to be static due to SET_ADDRESS */
-
         /* Get the address */
         packet->dst64 = tvb_get_letoh64(tvb, offset);
 
-        /* Copy and convert the address to network byte order. */
-        addr = pntoh64(&(packet->dst64));
-
         /* Display the destination address. */
         /* XXX - OUI resolution doesn't happen when displaying resolved
          * EUI64 addresses; that should probably be fixed in
          * epan/addr_resolv.c.
          */
-        SET_ADDRESS(&pinfo->dl_dst, AT_EUI64, 8, &addr);
-        SET_ADDRESS(&pinfo->dst, AT_EUI64, 8, &addr);
+        TVB_SET_ADDRESS(&pinfo->dl_dst, AT_EUI64, tvb, offset, 8);
+        TVB_SET_ADDRESS(&pinfo->dst, AT_EUI64, tvb, offset, 8);
         if (tree) {
             proto_tree_add_item(ieee802154_tree, hf_ieee802154_dst64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
             proto_item_append_text(proto_root, ", Dst: %s", ep_eui64_to_display(packet->dst64));
@@ -841,21 +836,16 @@ dissect_ieee802154_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree, g
         offset += 2;
     }
     else if (packet->src_addr_mode == IEEE802154_FCF_ADDR_EXT) {
-        static guint64 addr; /* has to be static due to SET_ADDRESS */
-
         /* Get the address. */
         packet->src64 = tvb_get_letoh64(tvb, offset);
 
-        /* Copy and convert the address to network byte order. */
-        addr = pntoh64(&(packet->src64));
-
         /* Display the source address. */
         /* XXX - OUI resolution doesn't happen when displaying resolved
          * EUI64 addresses; that should probably be fixed in
          * epan/addr_resolv.c.
          */
-        SET_ADDRESS(&pinfo->dl_src, AT_EUI64, 8, &addr);
-        SET_ADDRESS(&pinfo->src, AT_EUI64, 8, &addr);
+        TVB_SET_ADDRESS(&pinfo->dl_src, AT_EUI64, tvb, offset, 8);
+        TVB_SET_ADDRESS(&pinfo->src, AT_EUI64, tvb, offset, 8);
         if (tree) {
             proto_tree_add_item(ieee802154_tree, hf_ieee802154_src64, tvb, offset, 8, ENC_LITTLE_ENDIAN);
             proto_item_append_text(proto_root, ", Src: %s", ep_eui64_to_display(packet->src64));
index 1f128f4fa10d41096525a342f2e8363f34de9fab..35fd890149478010a991b04a0ebe7180cb4c747d 100644 (file)
@@ -1117,7 +1117,6 @@ static conversation_t
                         gboolean is_data, gboolean req)
 {
     conversation_t *conversation = NULL;
-    static usb_address_t  src_addr, dst_addr; /* has to be static due to SET_ADDRESS */
     guint16 device_address;
     guint16 bus_num;
     int endpoint;
@@ -1128,8 +1127,7 @@ static conversation_t
         endpoint = mausb_ep_handle_ep_num(handle);
         bus_num = mausb_ep_handle_bus_num(handle);
 
-        usb_set_addr(pinfo, &src_addr, &dst_addr, bus_num, device_address,
-                     endpoint, req);
+        usb_set_addr(pinfo, bus_num, device_address, endpoint, req);
         conversation = get_usb_conversation(pinfo, &pinfo->src, &pinfo->dst,
                                             pinfo->srcport, pinfo->destport);
     }
index 5d054adc4bc77eff8f0c2f8c459e93a1b95a9868..09ba02c6e6041954f9ea6bedd7d2cacce075eec4 100644 (file)
@@ -1843,7 +1843,7 @@ dissect_fid4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
                NULL
        };
 
-       static struct sna_fid_type_4_addr src, dst; /* has to be static due to SET_ADDRESS */
+       struct sna_fid_type_4_addr *src, *dst;
 
        const int bytes_in_header = 26;
 
@@ -1915,8 +1915,9 @@ dissect_fid4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        proto_tree_add_uint(tree, hf_sna_th_def, tvb, offset, 2, def);
 
        /* Addresses in FID 4 are discontiguous, sigh */
-       dst.saf = dsaf;
-       dst.ef = def;
+       dst = wmem_new(pinfo->pool, struct sna_fid_type_4_addr);
+       dst->saf = dsaf;
+       dst->ef = def;
        SET_ADDRESS(&pinfo->net_dst, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN,
            (guint8* )&dst);
        SET_ADDRESS(&pinfo->dst, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN,
@@ -1926,8 +1927,9 @@ dissect_fid4(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        proto_tree_add_uint(tree, hf_sna_th_oef, tvb, offset+2, 2, oef);
 
        /* Addresses in FID 4 are discontiguous, sigh */
-       src.saf = osaf;
-       src.ef = oef;
+       src = wmem_new(pinfo->pool, struct sna_fid_type_4_addr);
+       src->saf = osaf;
+       src->ef = oef;
        SET_ADDRESS(&pinfo->net_src, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN,
            (guint8 *)&src);
        SET_ADDRESS(&pinfo->src, AT_SNA, SNA_FID_TYPE_4_ADDR_LEN,
index 31e4b017691ce5553446707c67bbd114340cec23..8da242fb16df80d702c0261b2d039a28b81111c1 100644 (file)
@@ -398,7 +398,7 @@ dissect_tr(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
        tr_hdr *volatile trh;
 
        /* non-source-routed version of source addr */
-       static guint8           trn_shost_nonsr[6]; /* has to be static due to SET_ADDRESS */
+       guint8          *trn_shost_nonsr = (guint8*)wmem_alloc(pinfo->pool, 6);
        int                     x;
 
        /* Token-Ring Strings */
index c6f13298d787f727195f2a53c700680253cae811..44988c0aba015f840a96d0f7ed188df436f8b82e 100644 (file)
@@ -2740,9 +2740,9 @@ try_dissect_next_protocol(proto_tree *tree, tvbuff_t *next_tvb, packet_info *pin
                 usb_conv_info->usb_trans_info = usb_trans_info;
             }
             else if (ctrl_recip == RQT_SETUP_RECIPIENT_ENDPOINT) {
-                static address        endpoint_addr;
+                address               endpoint_addr;
                 gint                  endpoint;
-                static usb_address_t  src_addr, dst_addr; /* has to be static due to SET_ADDRESS */
+                usb_address_t         src_addr, dst_addr;
                 guint32               src_endpoint, dst_endpoint;
                 conversation_t       *conversation;
 
@@ -3106,10 +3106,12 @@ dissect_usbpcap_buffer_packet_header(tvbuff_t *tvb, packet_info *pinfo, proto_tr
 
 /* Set the usb_address_t fields based on the direction of the urb */
 void
-usb_set_addr(packet_info *pinfo, usb_address_t *src_addr,
-             usb_address_t *dst_addr, guint16 bus_id, guint16 device_address,
+usb_set_addr(packet_info *pinfo, guint16 bus_id, guint16 device_address,
              int endpoint, gboolean req)
 {
+    usb_address_t  *src_addr = wmem_new(pinfo->pool, usb_address_t),
+                   *dst_addr = wmem_new(pinfo->pool, usb_address_t);
+
     if (req) {
         /* request */
         src_addr->device   = 0xffffffff;
@@ -3404,7 +3406,6 @@ dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent,
     proto_item           *urb_tree_ti;
     proto_tree           *tree;
     proto_item           *item;
-    static usb_address_t  src_addr, dst_addr; /* has to be static due to SET_ADDRESS */
     usb_conv_info_t      *usb_conv_info;
     conversation_t       *conversation;
     guint16              device_address;
@@ -3438,7 +3439,7 @@ dissect_usb_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent,
     else
         return; /* invalid USB pseudo header */
 
-    usb_set_addr(pinfo, &src_addr, &dst_addr, bus_id, device_address, endpoint,
+    usb_set_addr(pinfo, bus_id, device_address, endpoint,
                  (urb_type == URB_SUBMIT));
 
     conversation = get_usb_conversation(pinfo, &pinfo->src, &pinfo->dst, pinfo->srcport, pinfo->destport);
index 5161ea376f41c4c6d99dbc98bc830722b09255db..1e07dfce145b712766878a92a77746b26d27bd33 100644 (file)
@@ -239,8 +239,7 @@ dissect_usb_setup_request(packet_info *pinfo, proto_tree *tree,
 
 
 void
-usb_set_addr(packet_info *pinfo, usb_address_t *src_addr,
-             usb_address_t *dst_addr, guint16 bus_id, guint16 device_address,
+usb_set_addr(packet_info *pinfo, guint16 bus_id, guint16 device_address,
              int endpoint, gboolean req);
 
 usb_trans_info_t