Don't do fcn calls in arg of g_?to??(); Macro may very well eval args multiple times.
[obnox/wireshark/wip.git] / epan / dissectors / packet-dcerpc-epm.c
index a0a9bc791a047e318078d6842a8f7a22f0d5a42d..391c96a6b23208eafbd50833ac30c91eebbb2f8f 100644 (file)
@@ -162,7 +162,6 @@ epm_dissect_ept_entry_t(tvbuff_t *tvb, int offset,
     proto_tree *tree=NULL;
     int old_offset=offset;
     guint32 len;
-    gint slen;
     dcerpc_info *di;
     const char *str;
 
@@ -187,20 +186,17 @@ epm_dissect_ept_entry_t(tvbuff_t *tvb, int offset,
                                  hf_epm_ann_offset, NULL);
     offset = dissect_ndr_uint32 (tvb, offset, pinfo, tree, drep,
                                  hf_epm_ann_len, &len);
-    str=(const char *)tvb_get_ptr(tvb, offset, -1);
-    slen=len;
-    slen=MIN(slen,tvb_length_remaining(tvb, offset));
-    tvb_ensure_bytes_exist(tvb, offset, len);
-    proto_tree_add_item(tree, hf_epm_annotation, tvb, offset, len, TRUE);
+    str=tvb_get_ephemeral_string(tvb, offset, len);
+    proto_tree_add_item(tree, hf_epm_annotation, tvb, offset, len, ENC_ASCII|ENC_NA);
     offset += len;
 
     if(str&&str[0]){
         if(parent_tree) {
-            proto_item_append_text(item, " Service:%*s ", slen, str);
-            proto_item_append_text(tree->parent, " Service:%*s ", slen, str);
+            proto_item_append_text(item, " Service:%s ", str);
+            proto_item_append_text(tree->parent, " Service:%s ", str);
         }
         if (check_col(pinfo->cinfo, COL_INFO)) {
-            col_append_fstr(pinfo->cinfo, COL_INFO, ", Service:%*s", slen, str);
+            col_append_fstr(pinfo->cinfo, COL_INFO, ", Service:%s", str);
         }
     }
 
@@ -324,11 +320,12 @@ static const value_string proto_id_vals[] = {
 static int
 epm_dissect_tower_data (tvbuff_t *tvb, int offset,
                              packet_info *pinfo, proto_tree *tree,
-                             guint8 *drep)
+                             guint8 *drep _U_)
 {
     guint16 num_floors, i;
     dcerpc_info *di;
     const char *uuid_name;
+    guint8   u8little_endian = DREP_LITTLE_ENDIAN;
 
     di=pinfo->private_data;
     if(di->conformant_run){
@@ -348,7 +345,7 @@ epm_dissect_tower_data (tvbuff_t *tvb, int offset,
         e_uuid_t uuid;
         proto_item *pi;
 
-        it = proto_tree_add_text(tree, tvb, offset, 0, "Floor %d  ", i);
+        it = proto_tree_add_text(tree, tvb, offset, 0, "Floor %d ", i);
         tr = proto_item_add_subtree(it, ett_epm_tower_floor);
 
         len = tvb_get_letohs(tvb, offset);
@@ -360,7 +357,7 @@ epm_dissect_tower_data (tvbuff_t *tvb, int offset,
 
         switch(proto_id){
         case PROTO_ID_UUID:
-            dcerpc_tvb_get_uuid (tvb, offset+1, drep, &uuid);
+            dcerpc_tvb_get_uuid (tvb, offset+1, &u8little_endian, &uuid);
 
             uuid_name = guids_get_uuid_name(&uuid);
 
@@ -387,9 +384,11 @@ epm_dissect_tower_data (tvbuff_t *tvb, int offset,
             {
                 guint16 version = tvb_get_ntohs(tvb, offset+17);
                 const char *service = dcerpc_get_proto_name(&uuid, version);
-                if (service || uuid_name)
-                    proto_item_append_text(tr, "UUID: %s", service ? service : uuid_name);
-                else
+                if (service || uuid_name) {
+                    const char *s = service ? service : uuid_name;
+                    proto_item_append_text(tr, "UUID: %s", s);
+                    col_append_fstr(pinfo->cinfo, COL_INFO, ", %s", s);
+                } else {
                     proto_item_append_text(tr, "UUID: %08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x Version %d.%d", uuid.Data1, uuid.Data2, uuid.Data3,
                                            uuid.Data4[0], uuid.Data4[1],
                                            uuid.Data4[2], uuid.Data4[3],
@@ -397,6 +396,7 @@ epm_dissect_tower_data (tvbuff_t *tvb, int offset,
                                            uuid.Data4[6], uuid.Data4[7],
                                            tvb_get_guint8(tvb, offset+17),
                                            tvb_get_guint8(tvb, offset+18));
+                }
             }
             break;
         }
@@ -410,21 +410,21 @@ epm_dissect_tower_data (tvbuff_t *tvb, int offset,
 
         case PROTO_ID_UUID:
             /* XXX - is this big or little endian? */
-            proto_tree_add_item(tr, hf_epm_ver_min, tvb, offset, 2, FALSE);
+            proto_tree_add_item(tr, hf_epm_ver_min, tvb, offset, 2, ENC_BIG_ENDIAN);
             break;
         case PROTO_ID_TCP: /* this one is always big endian */
-            proto_tree_add_item(tr, hf_epm_proto_tcp_port, tvb, offset, 2, FALSE);
+            proto_tree_add_item(tr, hf_epm_proto_tcp_port, tvb, offset, 2, ENC_BIG_ENDIAN);
             proto_item_append_text(tr, "TCP Port:%d", tvb_get_ntohs(tvb, offset));
             break;
 
         case PROTO_ID_UDP: /* this one is always big endian */
-            proto_tree_add_item(tr, hf_epm_proto_udp_port, tvb, offset, 2, FALSE);
+            proto_tree_add_item(tr, hf_epm_proto_udp_port, tvb, offset, 2, ENC_BIG_ENDIAN);
             proto_item_append_text(tr, "UDP Port:%d", tvb_get_ntohs(tvb, offset));
             break;
 
         case PROTO_ID_IP: /* this one is always big endian */
-            proto_tree_add_item(tr, hf_epm_proto_ip, tvb, offset, 4, FALSE);
-            proto_item_append_text(tr, "IP:%s", ip_to_str(tvb_get_ptr(tvb, offset, 4)));
+            proto_tree_add_item(tr, hf_epm_proto_ip, tvb, offset, 4, ENC_BIG_ENDIAN);
+            proto_item_append_text(tr, "IP:%s", tvb_ip_to_str(tvb, offset));
             break;
 
         case PROTO_ID_RPC_CO:
@@ -434,28 +434,25 @@ epm_dissect_tower_data (tvbuff_t *tvb, int offset,
         case PROTO_ID_RPC_CL:
             proto_item_append_text(tr, "RPC connectionless protocol");
             /* XXX - is this big or little endian? */
-            proto_tree_add_item(tr, hf_epm_ver_min, tvb, offset, 2, FALSE);
+            proto_tree_add_item(tr, hf_epm_ver_min, tvb, offset, 2, ENC_BIG_ENDIAN);
             break;
 
         case PROTO_ID_NAMED_PIPES: /* \\PIPE\xxx   named pipe */
-            tvb_ensure_bytes_exist(tvb, offset, len);
-            proto_tree_add_item(tr, hf_epm_proto_named_pipes, tvb, offset, len, TRUE);
-            proto_item_append_text(tr, "NamedPipe:%*s",MIN(len,tvb_length_remaining(tvb, offset)), tvb_get_ptr(tvb, offset, -1));
+            proto_tree_add_item(tr, hf_epm_proto_named_pipes, tvb, offset, len, ENC_ASCII|ENC_NA);
+            proto_item_append_text(tr, "NamedPipe:%s", tvb_get_ephemeral_string(tvb, offset, len));
             break;
 
         case PROTO_ID_NAMED_PIPES_2: /* PIPENAME  named pipe */
-            tvb_ensure_bytes_exist(tvb, offset, len);
-            proto_tree_add_item(tr, hf_epm_proto_named_pipes, tvb, offset, len, TRUE);
-            proto_item_append_text(tr, "PIPE:%*s",MIN(len,tvb_length_remaining(tvb, offset)), tvb_get_ptr(tvb, offset, -1));
+            proto_tree_add_item(tr, hf_epm_proto_named_pipes, tvb, offset, len, ENC_ASCII|ENC_NA);
+            proto_item_append_text(tr, "PIPE:%s", tvb_get_ephemeral_string(tvb, offset, len));
             break;
 
         case PROTO_ID_NETBIOS: /* \\NETBIOS   netbios name */
-            tvb_ensure_bytes_exist(tvb, offset, len);
-            proto_tree_add_item(tr, hf_epm_proto_netbios_name, tvb, offset, len, TRUE);
-            proto_item_append_text(tr, "NetBIOS:%*s",MIN(len,tvb_length_remaining(tvb, offset)), tvb_get_ptr(tvb, offset, -1));
+            proto_tree_add_item(tr, hf_epm_proto_netbios_name, tvb, offset, len, ENC_ASCII|ENC_NA);
+            proto_item_append_text(tr, "NetBIOS:%s", tvb_get_ephemeral_string(tvb, offset, len));
             break;
         case PROTO_ID_HTTP: /* RPC over HTTP */
-            proto_tree_add_item(tr, hf_epm_proto_http_port, tvb, offset, 2, FALSE);
+            proto_tree_add_item(tr, hf_epm_proto_http_port, tvb, offset, 2, ENC_BIG_ENDIAN);
             proto_item_append_text(tr, "RPC over HTTP Port:%d", tvb_get_ntohs(tvb, offset));
             break;
 
@@ -786,3 +783,16 @@ proto_reg_handoff_epm (void)
     dcerpc_init_uuid (proto_epm3, ett_epm, &uuid_epm, ver_epm3, epm_dissectors, hf_epm_opnum);
     dcerpc_init_uuid (proto_epm4, ett_epm, &uuid_epm, ver_epm4, epm_dissectors, hf_epm_opnum);
 }
+
+/*
+ * Editor modelines  -  http://www.wireshark.org/tools/modelines.html
+ *
+ * Local variables:
+ * c-basic-offset: 4
+ * tab-width: 8
+ * indent-tabs-mode: nil
+ * End:
+ *
+ * vi: set shiftwidth=4 tabstop=8 expandtab:
+ * :indentSize=4:tabSize=8:noTabs=true:
+ */