Don't use sprintf() - use ep_strbufs and ep_strbuf_append_printf()
authorguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 28 Mar 2009 17:30:31 +0000 (17:30 +0000)
committerguy <guy@f5534014-38df-0310-8fa8-9805f1628bb7>
Sat, 28 Mar 2009 17:30:31 +0000 (17:30 +0000)
instead.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@27876 f5534014-38df-0310-8fa8-9805f1628bb7

epan/dissectors/packet-dect.c

index 100bc0355641d2c4f5471a4a782e65cdba8f965d..004731cf78021bff1f53d12675e7d38dc6dc2ffc 100644 (file)
@@ -872,18 +872,21 @@ dissect_bfield(gboolean dect_packet_type _U_, struct dect_afield *pkt_afield,
                guint16 x, y=0;
                for(x=0;x<blen;x+=16)
                {
-                       /*gchar string[60];*/
-                       gchar string[145];
-                       string[0]='\0';
+                       /*
+                        * XXX - should this just be an FTYPE_BYTES field,
+                        * and possibly just displayed as "Data: N bytes"
+                        * rather than giving all the bytes of data?
+                        */
+                       emem_strbuf_t *string;
+                       string = ep_strbuf_new(NULL);
                        for(y=0;y<16;y++)
                        {
                                if((x+y)>=blen)
                                        break;
 
-                               /*g_snprintf(string, sizeof(string), "%s%.2x ", string, pkt_bfield->Data[x+y]);*/
-                               sprintf(string,"%s%.2x ", string, pkt_bfield->Data[x+y]);
+                               ep_strbuf_append_printf(string,"%.2x ", pkt_bfield->Data[x+y]);
                        }
-                       proto_tree_add_uint_format(BField, hf_dect_B_Data, tvb, offset, y, 0x2323, "Data: %s", string);
+                       proto_tree_add_uint_format(BField, hf_dect_B_Data, tvb, offset, y, 0x2323, "Data: %s", string->str);
                        if(y==16)
                                offset+=16;
                        else
@@ -899,19 +902,23 @@ dissect_bfield(gboolean dect_packet_type _U_, struct dect_afield *pkt_afield,
                        proto_tree_add_uint_format(BField, hf_dect_B_Data, tvb, offset, y, 0x2323, "Framenumber %u/%u", fn, fn+8);
                        for(x=0;x<blen;x+=16)
                        {
-                               /*gchar string[60];*/
-                               gchar string[145];
-                               string[0]='\0';
+                               /*
+                                * XXX - should this just be an FTYPE_BYTES
+                                * field, and possibly just displayed as
+                                * "Data: N bytes" rather than giving all
+                                * the bytes of data?
+                                */
+                               emem_strbuf_t *string;
+                               string = ep_strbuf_new(NULL);
                                for(y=0;y<16;y++)
                                {
                                        if((x+y)>=blen)
                                                break;
 
-                                       /*g_snprintf(string, sizeof(string), "%s%.2x ", string, pkt_bfield->Data[x+y]^scrt[fn][bytecount%31]);*/
-                                       sprintf(string,"%s%.2x ", string, pkt_bfield->Data[x+y]^scrt[fn][bytecount%31]);
+                                       ep_strbuf_append_printf(string,"%.2x ", pkt_bfield->Data[x+y]^scrt[fn][bytecount%31]);
                                        bytecount++;
                                }
-                               proto_tree_add_uint_format(BField, hf_dect_B_Data, tvb, offset, y, 0x2323, "Data: %s", string);
+                               proto_tree_add_uint_format(BField, hf_dect_B_Data, tvb, offset, y, 0x2323, "Data: %s", string->str);
                                if(y==16)
                                        offset+=16;
                                else