Fixed some strcpy -> strncpy/g_snprintf cleanups.
authorStig Bjørlykke <stig@bjorlykke.org>
Thu, 24 Jan 2008 23:01:37 +0000 (23:01 -0000)
committerStig Bjørlykke <stig@bjorlykke.org>
Thu, 24 Jan 2008 23:01:37 +0000 (23:01 -0000)
Removed a debug printout in t38.

svn path=/trunk/; revision=24188

asn1/t38/packet-t38-template.c
capture_loop.c
conditions.c
editcap.c
epan/dissectors/packet-t38.c
epan/dissectors/packet-t38.h

index a87467526c8c85497ac607266a49d56ce87f9cf8..3dea63381962edc694349109f174e4792bfaf5e9 100644 (file)
@@ -232,8 +232,6 @@ void t38_add_address(packet_info *pinfo,
                 return;
         }
 
-               printf("#%u: t38_add_address(%s, %u, %u, %s, %u\n", pinfo->fd->num, address_to_str(addr), port, other_port, setup_method, setup_frame_number);
-
         SET_ADDRESS(&null_addr, AT_NONE, 0, NULL);
 
         /*
@@ -480,7 +478,8 @@ init_t38_info_conv(packet_info *pinfo)
 
                /* copy the t38 conversation info to the packet t38 conversation */
                p_t38_packet_conv = se_alloc(sizeof(t38_conv));
-               strcpy(p_t38_packet_conv->setup_method, p_t38_conv->setup_method);
+               strncpy(p_t38_packet_conv->setup_method, p_t38_conv->setup_method, MAX_T38_SETUP_METHOD_SIZE);
+               p_t38_packet_conv->setup_method[MAX_T38_SETUP_METHOD_SIZE] = '\0';
                p_t38_packet_conv->setup_frame_number = p_t38_conv->setup_frame_number;
 
                memcpy(&(p_t38_packet_conv->src_t38_info), &(p_t38_conv->src_t38_info), sizeof(t38_conv_info));
index 8c602a4a16ed2b3a00d9812a01e871d01dae208a..38f7e34674c20ac2cb51e3b64ab66b1a2e67a628 100644 (file)
@@ -990,12 +990,12 @@ capture_loop_init_output(capture_options *capture_opts, int save_file_fd, loop_d
     switch (err) {
 
     case WTAP_ERR_CANT_OPEN:
-      strcpy(errmsg, "The file to which the capture would be saved"
+      g_snprintf(errmsg, errmsg_len, "The file to which the capture would be saved"
                " couldn't be created for some unknown reason.");
       break;
 
     case WTAP_ERR_SHORT_WRITE:
-      strcpy(errmsg, "A full header couldn't be written to the file"
+      g_snprintf(errmsg, errmsg_len, "A full header couldn't be written to the file"
                " to which the capture would be saved.");
       break;
 
index b6276e7ca23cfe2d26131f1427fe8ba0d2b7206d..95b42f7beacca701991a43075d0d5fea772a3af1 100644 (file)
@@ -70,7 +70,8 @@ condition* cnd_new(const char* class_id, ...){
     g_free(cnd_ref);
     return NULL;
   }
-  strcpy(id, class_id);
+  strncpy(id, class_id, strlen(class_id));
+  id[strlen(class_id)] = '\0';
   cnd_ref->class_id = id;
   /* perform class specific initialization */
   va_start(ap, class_id);
@@ -146,7 +147,8 @@ gboolean cnd_register_class(const char* class_id,
   /* GHashTable keys need to be persistent for the lifetime of the hash
      table. Allocate memory and copy the class id which we use as key. */
   if((key = (char*)g_malloc(strlen(class_id)+1)) == NULL) return FALSE;
-  strcpy(key, class_id);
+  strncpy(key, class_id, strlen(class_id));
+  key[strlen(class_id)] = '\0';
   /* initialize class structure */
   if((cls = (_cnd_class*)g_malloc(sizeof(_cnd_class))) == NULL){
     g_free(key);
index 0230aee34d84699f1c87017450a04c420df85fa0..14fcdb84a28d511cf4212fdabd9053935a7f5fb6 100644 (file)
--- a/editcap.c
+++ b/editcap.c
@@ -765,7 +765,7 @@ int main(int argc, char *argv[])
 
               if (err_type < ERR_WT_FMT) {
                 if ((unsigned int)i < phdr->caplen - 2)
-                  strcpy((char*) &buf[i],  "%s");
+                  strncpy((char*) &buf[i],  "%s", 2);
                 err_type = ERR_WT_TOTAL;
               } else {
                 err_type -= ERR_WT_FMT;
index c52f2cb48cef732c5d44b7f3bb0ebbe456a5958d..0129bf4a0482a274893de7c86efe92b16197c871 100644 (file)
@@ -1,7 +1,7 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Wireshark dissector compiler   */
 /* packet-t38.c                                                               */
-/* ../../tools/asn2wrs.py -p t38 -c t38.cnf -s packet-t38-template T38_2002.asn */
+/* ../../tools/asn2wrs.py -p t38 -c ./t38.cnf -s ./packet-t38-template -D . T38_2002.asn */
 
 /* Input file: packet-t38-template.c */
 
@@ -277,8 +277,6 @@ void t38_add_address(packet_info *pinfo,
                 return;
         }
 
-               printf("#%u: t38_add_address(%s, %u, %u, %s, %u\n", pinfo->fd->num, address_to_str(addr), port, other_port, setup_method, setup_frame_number);
-
         SET_ADDRESS(&null_addr, AT_NONE, 0, NULL);
 
         /*
@@ -808,7 +806,7 @@ dissect_t38_IFPPacket(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, p
 static int
 dissect_t38_T_seq_number(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
   offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index,
-                                              0U, 65535U, &seq_number, FALSE);
+                                                            0U, 65535U, &seq_number, FALSE);
 
 #line 232 "t38.cnf"
     /* info for tap */
@@ -979,7 +977,7 @@ static int dissect_UDPTLPacket_PDU(tvbuff_t *tvb _U_, packet_info *pinfo _U_, pr
 
 
 /*--- End of included file: packet-t38-fn.c ---*/
-#line 402 "packet-t38-template.c"
+#line 400 "packet-t38-template.c"
 
 /* initialize the tap t38_info and the conversation */
 static void
@@ -1061,7 +1059,8 @@ init_t38_info_conv(packet_info *pinfo)
 
                /* copy the t38 conversation info to the packet t38 conversation */
                p_t38_packet_conv = se_alloc(sizeof(t38_conv));
-               strcpy(p_t38_packet_conv->setup_method, p_t38_conv->setup_method);
+               strncpy(p_t38_packet_conv->setup_method, p_t38_conv->setup_method, MAX_T38_SETUP_METHOD_SIZE);
+               p_t38_packet_conv->setup_method[MAX_T38_SETUP_METHOD_SIZE] = '\0';
                p_t38_packet_conv->setup_frame_number = p_t38_conv->setup_frame_number;
 
                memcpy(&(p_t38_packet_conv->src_t38_info), &(p_t38_conv->src_t38_info), sizeof(t38_conv_info));
@@ -1350,7 +1349,7 @@ proto_register_t38(void)
         "t38.OCTET_STRING", HFILL }},
 
 /*--- End of included file: packet-t38-hfarr.c ---*/
-#line 696 "packet-t38-template.c"
+#line 695 "packet-t38-template.c"
                {   &hf_t38_setup,
                    { "Stream setup", "t38.setup", FT_STRING, BASE_NONE,
                    NULL, 0x0, "Stream setup, method and frame number", HFILL }},
@@ -1405,7 +1404,7 @@ proto_register_t38(void)
     &ett_t38_T_fec_data,
 
 /*--- End of included file: packet-t38-ettarr.c ---*/
-#line 737 "packet-t38-template.c"
+#line 736 "packet-t38-template.c"
                &ett_t38_setup,
                &ett_data_fragment,
                &ett_data_fragments
index 0d3af6db3a1cbf84e6a34aeea4d683eccf6bdf40..a33b22868bde198e1b7f76b928a84ec419aba600 100644 (file)
@@ -1,7 +1,7 @@
 /* Do not modify this file.                                                   */
 /* It is created automatically by the ASN.1 to Wireshark dissector compiler   */
 /* packet-t38.h                                                               */
-/* ../../tools/asn2wrs.py -p t38 -c t38.cnf -s packet-t38-template T38_2002.asn */
+/* ../../tools/asn2wrs.py -p t38 -c ./t38.cnf -s ./packet-t38-template -D . T38_2002.asn */
 
 /* Input file: packet-t38-template.h */