Skip to content

Commit

Permalink
Fixed some strcpy -> strncpy/g_snprintf cleanups.
Browse files Browse the repository at this point in the history
Removed a debug printout in t38.

svn path=/trunk/; revision=24188
  • Loading branch information
stigbjorlykke committed Jan 24, 2008
1 parent c2f444f commit 2df21cb
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 17 deletions.
5 changes: 2 additions & 3 deletions asn1/t38/packet-t38-template.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

/*
Expand Down Expand Up @@ -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));
Expand Down
4 changes: 2 additions & 2 deletions capture_loop.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
6 changes: 4 additions & 2 deletions conditions.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion editcap.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
15 changes: 7 additions & 8 deletions epan/dissectors/packet-t38.c
Original file line number Diff line number Diff line change
@@ -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 */

Expand Down Expand Up @@ -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);

/*
Expand Down Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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 }},
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion epan/dissectors/packet-t38.h
Original file line number Diff line number Diff line change
@@ -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 */

Expand Down

0 comments on commit 2df21cb

Please sign in to comment.