From 677eb18d202d100871dd6b08a18db9dba314ed3b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stig=20Bj=C3=B8rlykke?= Date: Sat, 2 Feb 2008 17:25:40 +0000 Subject: Rewrote some prohibited APIs in epan/dissectors/ (sprintf, strcpy, strcat). If we get some truncated strings we probably overwrote some buffers... svn path=/trunk/; revision=24249 --- epan/dissectors/packet-afs.c | 14 ++++---- epan/dissectors/packet-ansi_map.c | 34 ++++++++----------- epan/dissectors/packet-ansi_map.h | 2 +- epan/dissectors/packet-bthci_cmd.c | 22 ++++++------ epan/dissectors/packet-bthci_evt.c | 22 ++++++------ epan/dissectors/packet-clnp.c | 6 ++-- epan/dissectors/packet-cops.c | 5 +-- epan/dissectors/packet-dcom.c | 2 +- epan/dissectors/packet-gtp.c | 10 +++--- epan/dissectors/packet-h450-ros.c | 20 ++++++----- epan/dissectors/packet-mgcp.c | 6 ++-- epan/dissectors/packet-nbns.c | 39 +++++++++++---------- epan/dissectors/packet-ncp-sss.c | 67 +++++++++++++++++++------------------ epan/dissectors/packet-nfs.c | 7 ++-- epan/dissectors/packet-q932-ros.c | 40 ++++++++++++---------- epan/dissectors/packet-smb-common.c | 2 +- epan/dissectors/packet-sqloracle.c | 2 +- epan/dissectors/packet-srvloc.c | 4 +-- epan/dissectors/packet-ssl-utils.c | 8 ++--- epan/dissectors/packet-telnet.c | 10 +++--- epan/dissectors/packet-tpncp.c | 6 ++-- 21 files changed, 170 insertions(+), 158 deletions(-) (limited to 'epan') diff --git a/epan/dissectors/packet-afs.c b/epan/dissectors/packet-afs.c index 636d5615e5..1c115be39e 100644 --- a/epan/dissectors/packet-afs.c +++ b/epan/dissectors/packet-afs.c @@ -649,13 +649,13 @@ static gint ett_afs_vldb_flags = -1; int acllen; \ char tmp[10]; \ tmp[0] = 0; \ - if ( acl & PRSFS_READ ) strcat(tmp, "r"); \ - if ( acl & PRSFS_LOOKUP ) strcat(tmp, "l"); \ - if ( acl & PRSFS_INSERT ) strcat(tmp, "i"); \ - if ( acl & PRSFS_DELETE ) strcat(tmp, "d"); \ - if ( acl & PRSFS_WRITE ) strcat(tmp, "w"); \ - if ( acl & PRSFS_LOCK ) strcat(tmp, "k"); \ - if ( acl & PRSFS_ADMINISTER ) strcat(tmp, "a"); \ + if ( acl & PRSFS_READ ) strncat(tmp, "r", 2); \ + if ( acl & PRSFS_LOOKUP ) strncat(tmp, "l", 2); \ + if ( acl & PRSFS_INSERT ) strncat(tmp, "i", 2); \ + if ( acl & PRSFS_DELETE ) strncat(tmp, "d", 2); \ + if ( acl & PRSFS_WRITE ) strncat(tmp, "w", 2); \ + if ( acl & PRSFS_LOCK ) strncat(tmp, "k", 2); \ + if ( acl & PRSFS_ADMINISTER ) strncat(tmp, "a", 2); \ ti = proto_tree_add_text(tree, tvb, offset, bytes, \ "ACL: %s %s%s", \ who, tmp, positive ? "" : " (negative)"); \ diff --git a/epan/dissectors/packet-ansi_map.c b/epan/dissectors/packet-ansi_map.c index 792bb1ec3d..f0c0d7c2a1 100644 --- a/epan/dissectors/packet-ansi_map.c +++ b/epan/dissectors/packet-ansi_map.c @@ -1,7 +1,7 @@ /* Do not modify this file. */ /* It is created automatically by the ASN.1 to Wireshark dissector compiler */ /* packet-ansi_map.c */ -/* ../../tools/asn2wrs.py -b -p ansi_map -c ansi_map.cnf -s packet-ansi_map-template ansi_map.asn */ +/* ../../tools/asn2wrs.py -b -p ansi_map -c ./ansi_map.cnf -s ./packet-ansi_map-template -D . ansi_map.asn */ /* Input file: packet-ansi_map-template.c */ @@ -1206,11 +1206,8 @@ update_saved_invokedata(packet_info *pinfo, proto_tree *tree _U_, tvbuff_t *tvb p_private_tcap=pinfo->private_data; if ((!pinfo->fd->flags.visited)&&(p_private_tcap->TransactionID_str)){ /* Only do this once XXX I hope its the right thing to do */ - strcpy(buf,p_private_tcap->TransactionID_str); /* The hash string needs to contain src and dest to distiguish differnt flows */ - strcat(buf,src_str); - strcat(buf,dst_str); - strcat(buf,"\0"); + g_snprintf(buf,1024,"%s%s%s",p_private_tcap->TransactionID_str,src_str,dst_str); /* If the entry allready exists don't owervrite it */ ansi_map_saved_invokedata = g_hash_table_lookup(TransactionId_table,buf); if(ansi_map_saved_invokedata) @@ -4485,7 +4482,7 @@ dissect_ansi_map_AuthenticationResponseUniqueChallenge(gboolean implicit_tag _U_ static int dissect_ansi_map_CallHistoryCount(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, - NULL); + NULL); return offset; } @@ -4948,7 +4945,7 @@ dissect_ansi_map_SystemCapabilities(gboolean implicit_tag _U_, tvbuff_t *tvb _U_ static int dissect_ansi_map_CallHistoryCountExpected(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, - NULL); + NULL); return offset; } @@ -5765,7 +5762,7 @@ dissect_ansi_map_ChannelData(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int o static int dissect_ansi_map_InterSwitchCount(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, - NULL); + NULL); return offset; } @@ -7880,7 +7877,7 @@ static const value_string ansi_map_SignalQuality_vals[] = { static int dissect_ansi_map_SignalQuality(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, - NULL); + NULL); return offset; } @@ -9807,7 +9804,7 @@ dissect_ansi_map_ControlChannelData(gboolean implicit_tag _U_, tvbuff_t *tvb _U_ static int dissect_ansi_map_ReceivedSignalQuality(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, - NULL); + NULL); return offset; } @@ -11670,7 +11667,7 @@ dissect_ansi_map_TimeDateOffset(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, in static int dissect_ansi_map_TimeOfDay(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, - NULL); + NULL); return offset; } @@ -14297,7 +14294,7 @@ dissect_ansi_map_ACGDirective(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int static int dissect_ansi_map_InvokingNEType(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, - NULL); + NULL); return offset; } @@ -14307,7 +14304,7 @@ dissect_ansi_map_InvokingNEType(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, in static int dissect_ansi_map_Range(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, - NULL); + NULL); return offset; } @@ -15052,7 +15049,7 @@ dissect_ansi_map_ReturnData(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int of /*--- End of included file: packet-ansi_map-fn.c ---*/ -#line 3623 "packet-ansi_map-template.c" +#line 3620 "packet-ansi_map-template.c" /* * 6.5.2.dk N.S0013-0 v 1.0,X.S0004-550-E v1.0 2.301 @@ -15698,11 +15695,8 @@ find_saved_invokedata(asn1_ctx_t *actx){ /* The hash string needs to contain src and dest to distiguish differnt flows */ src_str = address_to_str(src); dst_str = address_to_str(dst); - strcpy(buf, p_private_tcap->TransactionID_str); /* Reverse order to invoke */ - strcat(buf,dst_str); - strcat(buf,src_str); - strcat(buf,"\0"); + g_snprintf(buf,1024,"%s%s%s",p_private_tcap->TransactionID_str,dst_str,src_str); /* g_warning("Find Hash string %s",buf); */ @@ -18795,7 +18789,7 @@ void proto_register_ansi_map(void) { "ansi_map.StatusRequestRes", HFILL }}, /*--- End of included file: packet-ansi_map-hfarr.c ---*/ -#line 5217 "packet-ansi_map-template.c" +#line 5211 "packet-ansi_map-template.c" }; /* List of subtrees */ @@ -19048,7 +19042,7 @@ void proto_register_ansi_map(void) { &ett_ansi_map_ReturnData, /*--- End of included file: packet-ansi_map-ettarr.c ---*/ -#line 5250 "packet-ansi_map-template.c" +#line 5244 "packet-ansi_map-template.c" }; diff --git a/epan/dissectors/packet-ansi_map.h b/epan/dissectors/packet-ansi_map.h index c84e5a1a37..af25f1ca22 100644 --- a/epan/dissectors/packet-ansi_map.h +++ b/epan/dissectors/packet-ansi_map.h @@ -1,7 +1,7 @@ /* Do not modify this file. */ /* It is created automatically by the ASN.1 to Wireshark dissector compiler */ /* packet-ansi_map.h */ -/* ../../tools/asn2wrs.py -b -p ansi_map -c ansi_map.cnf -s packet-ansi_map-template ansi_map.asn */ +/* ../../tools/asn2wrs.py -b -p ansi_map -c ./ansi_map.cnf -s ./packet-ansi_map-template -D . ansi_map.asn */ /* Input file: packet-ansi_map-template.h */ diff --git a/epan/dissectors/packet-bthci_cmd.c b/epan/dissectors/packet-bthci_cmd.c index a393c924e3..4f0c2bf83e 100644 --- a/epan/dissectors/packet-bthci_cmd.c +++ b/epan/dissectors/packet-bthci_cmd.c @@ -834,20 +834,20 @@ dissect_bthci_cmd_cod(int type, tvbuff_t *tvb, int offset, packet_info *pinfo _U buf[0] = '\0'; proto_item_append_text(item, " (%s - services:", val_to_str(cod1 & 0x1f, bthci_cmd_major_dev_class_vals, "???")); - if (cod2 & 0x80) strcat(buf, " Information,"); - if (cod2 & 0x40) strcat(buf, " Telephony,"); - if (cod2 & 0x20) strcat(buf, " Audio,"); - if (cod2 & 0x10) strcat(buf, " Object transfer,"); - if (cod2 & 0x08) strcat(buf, " Capturing,"); - if (cod2 & 0x04) strcat(buf, " Rendering,"); - if (cod2 & 0x02) strcat(buf, " Networking,"); - if (cod2 & 0x01) strcat(buf, " Positioning,"); - if (cod1 & 0x20) strcat(buf, " Limited discoverable mode,"); + if (cod2 & 0x80) strncat(buf, " Information,", sizeof(buf) - strlen(buf)); + if (cod2 & 0x40) strncat(buf, " Telephony,", sizeof(buf) - strlen(buf)); + if (cod2 & 0x20) strncat(buf, " Audio,", sizeof(buf) - strlen(buf)); + if (cod2 & 0x10) strncat(buf, " Object transfer,", sizeof(buf) - strlen(buf)); + if (cod2 & 0x08) strncat(buf, " Capturing,", sizeof(buf) - strlen(buf)); + if (cod2 & 0x04) strncat(buf, " Rendering,", sizeof(buf) - strlen(buf)); + if (cod2 & 0x02) strncat(buf, " Networking,", sizeof(buf) - strlen(buf)); + if (cod2 & 0x01) strncat(buf, " Positioning,", sizeof(buf) - strlen(buf)); + if (cod1 & 0x20) strncat(buf, " Limited discoverable mode,", sizeof(buf) - strlen(buf)); buf[strlen(buf)-1] = '\0'; /* skip last comma */ - strcat(buf, ")"); - + strncat(buf, ")", sizeof(buf) - strlen(buf)); + buf[128-1] = '\0'; proto_item_append_text(item, buf); } else diff --git a/epan/dissectors/packet-bthci_evt.c b/epan/dissectors/packet-bthci_evt.c index 35ffc7cdeb..4fb5785671 100644 --- a/epan/dissectors/packet-bthci_evt.c +++ b/epan/dissectors/packet-bthci_evt.c @@ -640,20 +640,20 @@ dissect_bthci_evt_cod(tvbuff_t *tvb, int offset, packet_info *pinfo _U_, proto_t buf[0] = 0; proto_item_append_text(item, " (%s - services:", val_to_str(cod1 & 0x1f, bthci_cmd_major_dev_class_vals, "???")); - if (cod2 & 0x80) strcat(buf, " Information,"); - if (cod2 & 0x40) strcat(buf, " Telephony,"); - if (cod2 & 0x20) strcat(buf, " Audio,"); - if (cod2 & 0x10) strcat(buf, " Object transfer,"); - if (cod2 & 0x08) strcat(buf, " Capturing,"); - if (cod2 & 0x04) strcat(buf, " Rendering,"); - if (cod2 & 0x02) strcat(buf, " Networking,"); - if (cod2 & 0x01) strcat(buf, " Positioning,"); - if (cod1 & 0x20) strcat(buf, " Limited discoverable mode,"); + if (cod2 & 0x80) strncat(buf, " Information,", sizeof(buf) - strlen(buf)); + if (cod2 & 0x40) strncat(buf, " Telephony,", sizeof(buf) - strlen(buf)); + if (cod2 & 0x20) strncat(buf, " Audio,", sizeof(buf) - strlen(buf)); + if (cod2 & 0x10) strncat(buf, " Object transfer,", sizeof(buf) - strlen(buf)); + if (cod2 & 0x08) strncat(buf, " Capturing,", sizeof(buf) - strlen(buf)); + if (cod2 & 0x04) strncat(buf, " Rendering,", sizeof(buf) - strlen(buf)); + if (cod2 & 0x02) strncat(buf, " Networking,", sizeof(buf) - strlen(buf)); + if (cod2 & 0x01) strncat(buf, " Positioning,", sizeof(buf) - strlen(buf)); + if (cod1 & 0x20) strncat(buf, " Limited discoverable mode,", sizeof(buf) - strlen(buf)); buf[strlen(buf)-1] = 0; /* skip last comma */ - strcat(buf, ")"); - + strncat(buf, ")", sizeof(buf) - strlen(buf)); + buf[128-1] = '\0'; proto_item_append_text(item, buf); } else diff --git a/epan/dissectors/packet-clnp.c b/epan/dissectors/packet-clnp.c index 670bbe5bcc..8575e05713 100644 --- a/epan/dissectors/packet-clnp.c +++ b/epan/dissectors/packet-clnp.c @@ -1917,11 +1917,11 @@ static void dissect_clnp(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) "Unknown (0x%02x)"); flag_string[0] = '\0'; if (cnf_type & CNF_SEG_OK) - strcat(flag_string, "S "); + strncat(flag_string, "S ", 3); if (cnf_type & CNF_MORE_SEGS) - strcat(flag_string, "M "); + strncat(flag_string, "M ", 3); if (cnf_type & CNF_ERR_OK) - strcat(flag_string, "E "); + strncat(flag_string, "E ", 3); if (tree) { ti = proto_tree_add_uint_format(clnp_tree, hf_clnp_type, tvb, P_CLNP_TYPE, 1, cnf_type, diff --git a/epan/dissectors/packet-cops.c b/epan/dissectors/packet-cops.c index c95a76baa9..181fa50bea 100644 --- a/epan/dissectors/packet-cops.c +++ b/epan/dissectors/packet-cops.c @@ -2635,7 +2635,8 @@ cops_transaction_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *st, guint8 op /* Write the right data into the 'info field' on the Gui */ g_snprintf(info,sizeof(info),"COPS %-20s - ",val_to_str(op_code,cops_op_code_vals, "Unknown")); - strcat(info,val_to_str(code16,table_cops_dqos_transaction_id, "Unknown")); + strncat(info,val_to_str(code16,table_cops_dqos_transaction_id, "Unknown"), sizeof(info)-strlen(info)); + info[sizeof(info)-1] = '\0'; if (check_col(pinfo->cinfo, COL_INFO)) { col_clear(pinfo->cinfo, COL_INFO); @@ -3031,7 +3032,7 @@ cops_mm_transaction_id(tvbuff_t *tvb, packet_info *pinfo, proto_tree *st, guint8 /* Write the right data into the 'info field' on the Gui */ g_snprintf(info,sizeof(info),"COPS %-20s - ",val_to_str(op_code,cops_op_code_vals, "Unknown")); - strcat(info,val_to_str(code16,table_cops_mm_transaction_id, "Unknown")); + strncat(info,val_to_str(code16,table_cops_mm_transaction_id, "Unknown"), sizeof(info)-strlen(info)); if (check_col(pinfo->cinfo, COL_INFO)) { col_clear(pinfo->cinfo, COL_INFO); diff --git a/epan/dissectors/packet-dcom.c b/epan/dissectors/packet-dcom.c index c454c82b1c..439dfe8dcd 100644 --- a/epan/dissectors/packet-dcom.c +++ b/epan/dissectors/packet-dcom.c @@ -1612,7 +1612,7 @@ dcom_tvb_get_nwstringz0(tvbuff_t *tvb, gint offset, guint32 inLength, gchar *psz for(u32IdxA = 0, u32IdxW = 0; u32IdxW < u32Idx && u32IdxA < outLength-2; u32IdxW++, u32IdxA+=2) { - sprintf(&pszStr[u32IdxA], "%02X", tvb_get_guint8(tvb, offset+u32IdxW)); + g_snprintf(&pszStr[u32IdxA], 3, "%02X", tvb_get_guint8(tvb, offset+u32IdxW)); } } diff --git a/epan/dissectors/packet-gtp.c b/epan/dissectors/packet-gtp.c index 5896306755..a5def5b020 100644 --- a/epan/dissectors/packet-gtp.c +++ b/epan/dissectors/packet-gtp.c @@ -1592,12 +1592,12 @@ col_append_str_gtp(column_info *cinfo, gint el, const gchar *proto_name) { } _tmp[0] = '\0'; - strcat(_tmp, proto_name); - strcat(_tmp, " <"); - strcat(_tmp, cinfo->col_buf[i]); - strcat(_tmp, ">"); + strncat(_tmp, proto_name, COL_MAX_LEN); + strncat(_tmp, " <", COL_MAX_LEN - strlen(_tmp)); + strncat(_tmp, cinfo->col_buf[i], COL_MAX_LEN - strlen(_tmp)); + strncat(_tmp, ">", COL_MAX_LEN - strlen(_tmp)); cinfo->col_buf[i][0] = '\0'; - strcat(cinfo->col_buf[i], _tmp); + strncat(cinfo->col_buf[i], _tmp, COL_MAX_LEN); cinfo->col_data[i] = cinfo->col_buf[i]; } } diff --git a/epan/dissectors/packet-h450-ros.c b/epan/dissectors/packet-h450-ros.c index 5c4f86d65a..d8575b594f 100644 --- a/epan/dissectors/packet-h450-ros.c +++ b/epan/dissectors/packet-h450-ros.c @@ -178,7 +178,7 @@ dissect_h450_ros_InvokeId(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U static int dissect_h450_ros_T_invokeIdConstrained(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 64 "h450-ros.cnf" +#line 68 "h450-ros.cnf" offset = dissect_per_constrained_integer(tvb, offset, actx, tree, hf_index, 0U, 65535U, NULL, TRUE); @@ -410,7 +410,8 @@ dissect_h450_ros_GeneralProblem(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *a offset = dissect_per_integer(tvb, offset, actx, tree, hf_index, &problem_val); #line 51 "h450-ros.cnf" - strcpy(problem_str, val_to_str(problem_val, VALS(h450_ros_GeneralProblem_vals), "")); + strncpy(problem_str, val_to_str(problem_val, VALS(h450_ros_GeneralProblem_vals), ""), 64); + problem_str[64-1] = '\0'; return offset; } @@ -433,8 +434,9 @@ static int dissect_h450_ros_InvokeProblem(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { offset = dissect_per_integer(tvb, offset, actx, tree, hf_index, &problem_val); -#line 53 "h450-ros.cnf" - strcpy(problem_str, val_to_str(problem_val, VALS(h450_ros_InvokeProblem_vals), "")); +#line 54 "h450-ros.cnf" + strncpy(problem_str, val_to_str(problem_val, VALS(h450_ros_InvokeProblem_vals), ""), 64); + problem_str[64-1] = '\0'; return offset; } @@ -452,8 +454,9 @@ static int dissect_h450_ros_ReturnResultProblem(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { offset = dissect_per_integer(tvb, offset, actx, tree, hf_index, &problem_val); -#line 55 "h450-ros.cnf" - strcpy(problem_str, val_to_str(problem_val, VALS(h450_ros_ReturnResultProblem_vals), "")); +#line 57 "h450-ros.cnf" + strncpy(problem_str, val_to_str(problem_val, VALS(h450_ros_ReturnResultProblem_vals), ""), 64); + problem_str[64-1] = '\0'; return offset; } @@ -473,8 +476,9 @@ static int dissect_h450_ros_ReturnErrorProblem(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { offset = dissect_per_integer(tvb, offset, actx, tree, hf_index, &problem_val); -#line 57 "h450-ros.cnf" - strcpy(problem_str, val_to_str(problem_val, VALS(h450_ros_ReturnErrorProblem_vals), "")); +#line 60 "h450-ros.cnf" + strncpy(problem_str, val_to_str(problem_val, VALS(h450_ros_ReturnErrorProblem_vals), ""), 64); + problem_str[64-1] = '\0'; return offset; } diff --git a/epan/dissectors/packet-mgcp.c b/epan/dissectors/packet-mgcp.c index 2c02d0a1e2..445c5524e0 100644 --- a/epan/dissectors/packet-mgcp.c +++ b/epan/dissectors/packet-mgcp.c @@ -1459,7 +1459,7 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree if (verb_description != NULL) { /* Can show verb along with code if known */ - sprintf(code_with_verb, "%s (%s)", code, verb_description); + g_snprintf(code_with_verb, 64, "%s (%s)", code, verb_description); } proto_tree_add_string_format(tree, hf_mgcp_req_verb, tvb, @@ -1597,7 +1597,7 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree mi->request_available = TRUE; mgcp_call->responded = TRUE; mi->req_num = mgcp_call->req_num; - strcpy(mi->code,mgcp_call->code); + strncpy(mi->code,mgcp_call->code,5); item = proto_tree_add_uint_format(tree, hf_mgcp_req_frame, tvb, 0, 0, mgcp_call->req_num, "This is a response to a request in frame %u", @@ -1751,7 +1751,7 @@ static void dissect_mgcp_firstline(tvbuff_t *tvb, packet_info *pinfo, proto_tree mgcp_call->transid = mi->transid; mgcp_call->responded = FALSE; mgcp_call->req_time=pinfo->fd->abs_ts; - strcpy(mgcp_call->code,mi->code); + strncpy(mgcp_call->code,mi->code,5); /* Store it */ g_hash_table_insert(mgcp_calls, new_mgcp_call_key, mgcp_call); diff --git a/epan/dissectors/packet-nbns.c b/epan/dissectors/packet-nbns.c index 791874b020..1895f431bd 100644 --- a/epan/dissectors/packet-nbns.c +++ b/epan/dissectors/packet-nbns.c @@ -465,11 +465,11 @@ nbns_add_nbns_flags(column_info *cinfo, proto_tree *nbns_tree, tvbuff_t *tvb, in opcode = (guint16) ((flags & F_OPCODE) >> OPCODE_SHIFT); g_snprintf(buf, MAX_BUF_SIZE, "%s", val_to_str(opcode, opcode_vals, "Unknown operation")); if (flags & F_RESPONSE && !is_wack) { - strcat(buf, " response"); - strcat(buf, ", "); - strcat(buf, val_to_str(flags & F_RCODE, rcode_vals, - "Unknown error")); - + strncat(buf, " response", MAX_BUF_SIZE - strlen(buf)); + strncat(buf, ", ", MAX_BUF_SIZE - strlen(buf)); + strncat(buf, val_to_str(flags & F_RCODE, rcode_vals, + "Unknown error"), MAX_BUF_SIZE - strlen(buf)); + buf[MAX_BUF_SIZE-1] = '\0'; if ((flags & F_RCODE) && check_col(cinfo, COL_INFO)) col_append_fstr(cinfo, COL_INFO, ", %s", val_to_str(flags & F_RCODE, rcode_vals, @@ -519,11 +519,12 @@ nbns_add_nb_flags(proto_tree *rr_tree, tvbuff_t *tvb, int offset, gushort flags) buf=ep_alloc(MAX_BUF_SIZE); g_snprintf(buf, MAX_BUF_SIZE, "%s", val_to_str(flags & NB_FLAGS_ONT, nb_flags_ont_vals, "Unknown")); - strcat(buf, ", "); + strncat(buf, ", ", MAX_BUF_SIZE - strlen(buf)); if (flags & NB_FLAGS_G) - strcat(buf, "group"); + strncat(buf, "group", MAX_BUF_SIZE - strlen(buf)); else - strcat(buf, "unique"); + strncat(buf, "unique", MAX_BUF_SIZE - strlen(buf)); + buf[MAX_BUF_SIZE-1] = '\0'; tf = proto_tree_add_text(rr_tree, tvb, offset, 2, "Flags: 0x%x (%s)", flags, buf); field_tree = proto_item_add_subtree(tf, ett_nbns_nb_flags); @@ -554,19 +555,20 @@ nbns_add_name_flags(proto_tree *rr_tree, tvbuff_t *tvb, int offset, buf=ep_alloc(MAX_BUF_SIZE); g_snprintf(buf, MAX_BUF_SIZE, "%s", val_to_str(flags & NAME_FLAGS_ONT, name_flags_ont_vals, "Unknown")); - strcat(buf, ", "); + strncat(buf, ", ", MAX_BUF_SIZE - strlen(buf)); if (flags & NAME_FLAGS_G) - strcat(buf, "group"); + strncat(buf, "group", MAX_BUF_SIZE - strlen(buf)); else - strcat(buf, "unique"); + strncat(buf, "unique", MAX_BUF_SIZE - strlen(buf)); if (flags & NAME_FLAGS_DRG) - strcat(buf, ", being deregistered"); + strncat(buf, ", being deregistered", MAX_BUF_SIZE - strlen(buf)); if (flags & NAME_FLAGS_CNF) - strcat(buf, ", in conflict"); + strncat(buf, ", in conflict", MAX_BUF_SIZE - strlen(buf)); if (flags & NAME_FLAGS_ACT) - strcat(buf, ", active"); + strncat(buf, ", active", MAX_BUF_SIZE - strlen(buf)); if (flags & NAME_FLAGS_PRM) - strcat(buf, ", permanent node name"); + strncat(buf, ", permanent node name", MAX_BUF_SIZE - strlen(buf)); + buf[MAX_BUF_SIZE-1] = '\0'; tf = proto_tree_add_text(rr_tree, tvb, offset, 2, "Name flags: 0x%x (%s)", flags, buf); field_tree = proto_item_add_subtree(tf, ett_nbns_name_flags); @@ -664,9 +666,10 @@ dissect_nbns_answer(tvbuff_t *tvb, int offset, int nbns_data_offset, (data_offset - data_start) + data_len, "%s: type %s, class %s", name, type_name, class_name); - strcat(name, " ("); - strcat(name, netbios_name_type_descr(name_type)); - strcat(name, ")"); + strncat(name, " (", MAX_NAME_LEN - strlen(name)); + strncat(name, netbios_name_type_descr(name_type), MAX_NAME_LEN - strlen(name)); + strncat(name, ")", MAX_NAME_LEN - strlen(name)); + name[MAX_NAME_LEN-1] = '\0'; rr_tree = add_rr_to_tree(trr, ett_nbns_rr, tvb, offset, name, name_len, type_name, dns_class_name(class), ttl, data_len); while (data_len > 0) { diff --git a/epan/dissectors/packet-ncp-sss.c b/epan/dissectors/packet-ncp-sss.c index 0aa3b0479a..72e3d44bce 100644 --- a/epan/dissectors/packet-ncp-sss.c +++ b/epan/dissectors/packet-ncp-sss.c @@ -228,104 +228,104 @@ process_flags(proto_tree *sss_tree, tvbuff_t *tvb, guint32 foffset) { if (flags & bvalue) { - strcat(flags_str, sep); + strncat(flags_str, sep, 1024 - strlen(flags_str)); switch(bvalue) { case 0x00000001: - strcat(flags_str, "Enhanced Protection"); + strncat(flags_str, "Enhanced Protection", 1024 - strlen(flags_str)); break; case 0x00000002: - strcat(flags_str, "Create ID"); + strncat(flags_str, "Create ID", 1024 - strlen(flags_str)); break; case 0x00000004: - strcat(flags_str, "Remove Lock"); + strncat(flags_str, "Remove Lock", 1024 - strlen(flags_str)); break; case 0x00000008: - strcat(flags_str, "Repair"); + strncat(flags_str, "Repair", 1024 - strlen(flags_str)); break; case 0x00000010: - strcat(flags_str, "Unicode"); + strncat(flags_str, "Unicode", 1024 - strlen(flags_str)); break; case 0x00000020: - strcat(flags_str, "EP Master Password Used"); + strncat(flags_str, "EP Master Password Used", 1024 - strlen(flags_str)); break; case 0x00000040: - strcat(flags_str, "EP Password Used"); + strncat(flags_str, "EP Password Used", 1024 - strlen(flags_str)); break; case 0x00000080: - strcat(flags_str, "Set Tree Name"); + strncat(flags_str, "Set Tree Name", 1024 - strlen(flags_str)); break; case 0x00000100: - strcat(flags_str, "Get Context"); + strncat(flags_str, "Get Context", 1024 - strlen(flags_str)); break; case 0x00000200: - strcat(flags_str, "Destroy Context"); + strncat(flags_str, "Destroy Context", 1024 - strlen(flags_str)); break; case 0x00000400: - strcat(flags_str, "Not Defined"); + strncat(flags_str, "Not Defined", 1024 - strlen(flags_str)); break; case 0x00000800: - strcat(flags_str, "Not Defined"); + strncat(flags_str, "Not Defined", 1024 - strlen(flags_str)); break; case 0x00001000: - strcat(flags_str, "EP Lock"); + strncat(flags_str, "EP Lock", 1024 - strlen(flags_str)); break; case 0x00002000: - strcat(flags_str, "Not Initialized"); + strncat(flags_str, "Not Initialized", 1024 - strlen(flags_str)); break; case 0x00004000: - strcat(flags_str, "Enhanced Protection"); + strncat(flags_str, "Enhanced Protection", 1024 - strlen(flags_str)); break; case 0x00008000: - strcat(flags_str, "Store Not Synced"); + strncat(flags_str, "Store Not Synced", 1024 - strlen(flags_str)); break; case 0x00010000: - strcat(flags_str, "Admin Last Modified"); + strncat(flags_str, "Admin Last Modified", 1024 - strlen(flags_str)); break; case 0x00020000: - strcat(flags_str, "EP Password Present"); + strncat(flags_str, "EP Password Present", 1024 - strlen(flags_str)); break; case 0x00040000: - strcat(flags_str, "EP Master Password Present"); + strncat(flags_str, "EP Master Password Present", 1024 - strlen(flags_str)); break; case 0x00080000: - strcat(flags_str, "MP Disabled"); + strncat(flags_str, "MP Disabled", 1024 - strlen(flags_str)); break; case 0x00100000: - strcat(flags_str, "Not Defined"); + strncat(flags_str, "Not Defined", 1024 - strlen(flags_str)); break; case 0x00200000: - strcat(flags_str, "Not Defined"); + strncat(flags_str, "Not Defined", 1024 - strlen(flags_str)); break; case 0x00400000: - strcat(flags_str, "Not Defined"); + strncat(flags_str, "Not Defined", 1024 - strlen(flags_str)); break; case 0x00800000: - strcat(flags_str, "Not Defined"); + strncat(flags_str, "Not Defined", 1024 - strlen(flags_str)); break; case 0x01000000: - strcat(flags_str, "Not Defined"); + strncat(flags_str, "Not Defined", 1024 - strlen(flags_str)); break; case 0x02000000: - strcat(flags_str, "Not Defined"); + strncat(flags_str, "Not Defined", 1024 - strlen(flags_str)); break; case 0x04000000: - strcat(flags_str, "Not Defined"); + strncat(flags_str, "Not Defined", 1024 - strlen(flags_str)); break; case 0x08000000: - strcat(flags_str, "Not Defined"); + strncat(flags_str, "Not Defined", 1024 - strlen(flags_str)); break; case 0x10000000: - strcat(flags_str, "Not Defined"); + strncat(flags_str, "Not Defined", 1024 - strlen(flags_str)); break; case 0x20000000: - strcat(flags_str, "Not Defined"); + strncat(flags_str, "Not Defined", 1024 - strlen(flags_str)); break; case 0x40000000: - strcat(flags_str, "Not Defined"); + strncat(flags_str, "Not Defined", 1024 - strlen(flags_str)); break; case 0x80000000: - strcat(flags_str, "Not Defined"); + strncat(flags_str, "Not Defined", 1024 - strlen(flags_str)); break; default: break; @@ -334,6 +334,7 @@ process_flags(proto_tree *sss_tree, tvbuff_t *tvb, guint32 foffset) } bvalue = bvalue*2; } + flags_str[1024-1] = '\0'; tinew = proto_tree_add_uint_format(sss_tree, hf_flags, tvb, foffset, 4, flags, "%s 0x%08x", "Flags:", flags); flags_tree = proto_item_add_subtree(tinew, ett_nds); diff --git a/epan/dissectors/packet-nfs.c b/epan/dissectors/packet-nfs.c index 5ad990dceb..0a821953d3 100644 --- a/epan/dissectors/packet-nfs.c +++ b/epan/dissectors/packet-nfs.c @@ -1319,7 +1319,8 @@ dissect_fhandle_data_NETAPP(tvbuff_t* tvb, packet_info *pinfo _U_, proto_tree *t flag_string[0]=0; while (bit--) if (flags & (1<rose_ctx->d.code_local); + &actx->rose_ctx->d.code_local); return offset; } @@ -164,7 +164,7 @@ dissect_q932_ros_Code(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _ static int dissect_q932_ros_INTEGER(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, - NULL); + NULL); return offset; } @@ -205,7 +205,7 @@ dissect_q932_ros_InvokeId(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offs static int dissect_q932_ros_InvokeId_present(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, - NULL); + NULL); return offset; } @@ -245,7 +245,7 @@ dissect_q932_ros_T_linkedId(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int of static int dissect_q932_ros_InvokeArgument(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 69 "q932-ros.cnf" +#line 73 "q932-ros.cnf" gint len; len = tvb_length_remaining(tvb, offset); @@ -320,7 +320,7 @@ dissect_q932_ros_Invoke(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset static int dissect_q932_ros_ResultArgument(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 87 "q932-ros.cnf" +#line 91 "q932-ros.cnf" gint len; len = tvb_length_remaining(tvb, offset); @@ -409,7 +409,7 @@ dissect_q932_ros_ReturnResult(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int static int dissect_q932_ros_T_parameter(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { -#line 106 "q932-ros.cnf" +#line 110 "q932-ros.cnf" gint len; @@ -492,10 +492,11 @@ static const value_string q932_ros_GeneralProblem_vals[] = { static int dissect_q932_ros_GeneralProblem(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, - &problem_val); + &problem_val); #line 54 "q932-ros.cnf" - strcpy(problem_str, val_to_str(problem_val, VALS(q932_ros_GeneralProblem_vals), "")); + strncpy(problem_str, val_to_str(problem_val, VALS(q932_ros_GeneralProblem_vals), ""), 64); + problem_str[64-1] = '\0'; return offset; } @@ -517,10 +518,11 @@ static const value_string q932_ros_InvokeProblem_vals[] = { static int dissect_q932_ros_InvokeProblem(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, - &problem_val); + &problem_val); -#line 56 "q932-ros.cnf" - strcpy(problem_str, val_to_str(problem_val, VALS(q932_ros_InvokeProblem_vals), "")); +#line 57 "q932-ros.cnf" + strncpy(problem_str, val_to_str(problem_val, VALS(q932_ros_InvokeProblem_vals), ""), 64); + problem_str[64-1] = '\0'; return offset; } @@ -537,10 +539,11 @@ static const value_string q932_ros_ReturnResultProblem_vals[] = { static int dissect_q932_ros_ReturnResultProblem(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, - &problem_val); + &problem_val); -#line 58 "q932-ros.cnf" - strcpy(problem_str, val_to_str(problem_val, VALS(q932_ros_ReturnResultProblem_vals), "")); +#line 60 "q932-ros.cnf" + strncpy(problem_str, val_to_str(problem_val, VALS(q932_ros_ReturnResultProblem_vals), ""), 64); + problem_str[64-1] = '\0'; return offset; } @@ -559,10 +562,11 @@ static const value_string q932_ros_ReturnErrorProblem_vals[] = { static int dissect_q932_ros_ReturnErrorProblem(gboolean implicit_tag _U_, tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) { offset = dissect_ber_integer(implicit_tag, actx, tree, tvb, offset, hf_index, - &problem_val); + &problem_val); -#line 60 "q932-ros.cnf" - strcpy(problem_str, val_to_str(problem_val, VALS(q932_ros_ReturnErrorProblem_vals), "")); +#line 63 "q932-ros.cnf" + strncpy(problem_str, val_to_str(problem_val, VALS(q932_ros_ReturnErrorProblem_vals), ""), 64); + problem_str[64-1] = '\0'; return offset; } diff --git a/epan/dissectors/packet-smb-common.c b/epan/dissectors/packet-smb-common.c index 2265ca8a60..6b288f039b 100644 --- a/epan/dissectors/packet-smb-common.c +++ b/epan/dissectors/packet-smb-common.c @@ -331,7 +331,7 @@ get_unicode_or_ascii_string(tvbuff_t *tvb, int *offsetp, tvb_memcpy(tvb, (guint8 *)cur, *offsetp, copylen); cur[copylen] = '\0'; if (overflow) - strcat(cur, "..."); + strncat(cur, "...",4); string_len = *len; string = cur; } else { diff --git a/epan/dissectors/packet-sqloracle.c b/epan/dissectors/packet-sqloracle.c index f944302ce3..4ab245cc15 100644 --- a/epan/dissectors/packet-sqloracle.c +++ b/epan/dissectors/packet-sqloracle.c @@ -298,7 +298,7 @@ char * convertHexToString(BYTE *pSrc, UI16_T length) */ /* hexString = buf; */ - strcpy (hexString, buf); +/* strcpy (hexString, buf); */ return hexString; } #endif diff --git a/epan/dissectors/packet-srvloc.c b/epan/dissectors/packet-srvloc.c index 9a6ae53781..03c40c3ae9 100644 --- a/epan/dissectors/packet-srvloc.c +++ b/epan/dissectors/packet-srvloc.c @@ -560,7 +560,7 @@ attr_list(proto_tree *tree, int hf, tvbuff_t *tvb, int offset, int length, type_len = strcspn(tmp, ")"); add_v1_string(tree, hf_srvloc_srvrply_svcname, tvb, offset, type_len*2, encoding); offset += (type_len*2)+4; - strcpy(attr_type, "\0"); + attr_type[0] = '\0'; } /* If this is the attribute svcaddr */ if (strcmp(attr_type, "svcaddr-ws")==0) { @@ -625,7 +625,7 @@ attr_list(proto_tree *tree, int hf, tvbuff_t *tvb, int offset, int length, foffset += 57; } offset = foffset; - strcpy(attr_type, "\0"); + attr_type[0] = '\0'; } /* If there are no more supported attributes available then abort dissection */ if (strcmp(attr_type, "svcaddr-ws")!=0 && strcmp(attr_type, "svcname-ws")!=0 && strcmp(attr_type, "\0")!=0) { diff --git a/epan/dissectors/packet-ssl-utils.c b/epan/dissectors/packet-ssl-utils.c index f891dcec01..6f19eef373 100644 --- a/epan/dissectors/packet-ssl-utils.c +++ b/epan/dissectors/packet-ssl-utils.c @@ -2091,14 +2091,14 @@ ssl_load_pkcs12(FILE* fp, const gchar *cert_passwd) { buf_len = sizeof(buf_name); ret = gnutls_x509_crt_get_dn_by_oid(ssl_cert, GNUTLS_OID_X520_COMMON_NAME, 0, 0, buf_name, &buf_len); - if (ret < 0) { strcpy(buf_name, ""); } + if (ret < 0) { strncpy(buf_name, "", 256); } buf_len = sizeof(buf_email); ret = gnutls_x509_crt_get_dn_by_oid(ssl_cert, GNUTLS_OID_PKCS9_EMAIL, 0, 0, buf_email, &buf_len); - if (ret < 0) { strcpy(buf_email, ""); } + if (ret < 0) { strncpy(buf_email, "", 256); } buf_len = sizeof(buf_keyid); ret = gnutls_x509_crt_get_key_id(ssl_cert, 0, buf_keyid, &buf_len); - if (ret < 0) { strcpy(buf_keyid, ""); } + if (ret < 0) { strncpy(buf_keyid, "", 256); } private_key->x509_cert = ssl_cert; ssl_debug_printf( "Certificate imported: %s <%s>, KeyID %s\n", buf_name, buf_email, bytes_to_str(buf_keyid, buf_len)); @@ -2355,7 +2355,7 @@ ssl_association_add(GTree* associations, dissector_handle_t handle, guint port, assoc->tcp = tcp; assoc->ssl_port = port; assoc->info=g_malloc(strlen(protocol)+1); - strcpy(assoc->info, protocol); + strncpy(assoc->info, protocol, strlen(protocol)+1); assoc->handle = find_dissector(protocol); assoc->from_key_list = from_key_list; diff --git a/epan/dissectors/packet-telnet.c b/epan/dissectors/packet-telnet.c index 994d3d93c9..c52502a83a 100644 --- a/epan/dissectors/packet-telnet.c +++ b/epan/dissectors/packet-telnet.c @@ -500,13 +500,14 @@ dissect_comport_subopt(packet_info *pinfo _U_, const char *optname, tvbuff_t *tv int bit = ls & 1; if (bit) { if (print_count != 0) { - strcat(ls_buffer,", "); + strncat(ls_buffer,", ",512-strlen(ls_buffer)); } - strcat(ls_buffer,linestate_bits[idx]); + strncat(ls_buffer,linestate_bits[idx], 512-strlen(ls_buffer)); print_count++; } ls = ls >> 1; } + ls_buffer[512-1] = '\0'; proto_tree_add_text(tree, tvb, offset, 2, print_pattern, source, ls_buffer); } else { const char *print_pattern = (cmd == TNCOMPORT_SETLINESTATEMASK) ? @@ -530,13 +531,14 @@ dissect_comport_subopt(packet_info *pinfo _U_, const char *optname, tvbuff_t *tv int bit = ms & 1; if (bit) { if (print_count != 0) { - strcat(ms_buffer,", "); + strncat(ms_buffer,", ",256-strlen(ms_buffer)); } - strcat(ms_buffer,modemstate_bits[idx]); + strncat(ms_buffer,modemstate_bits[idx],256-strlen(ms_buffer)); print_count++; } ms = ms >> 1; } + ms_buffer[256-1] = '\0'; proto_tree_add_text(tree, tvb, offset, 2, print_pattern, source, ms_buffer); } else { const char *print_pattern = (cmd == TNCOMPORT_SETMODEMSTATEMASK) ? diff --git a/epan/dissectors/packet-tpncp.c b/epan/dissectors/packet-tpncp.c index aae96600e8..a121131e89 100644 --- a/epan/dissectors/packet-tpncp.c +++ b/epan/dissectors/packet-tpncp.c @@ -518,7 +518,8 @@ static gint fill_enums_id_vals(FILE *file) { else first_entry = 0; tpncp_enums_name_vals[enum_val] = g_strdup(enum_name); - strcpy(enum_type, enum_name); + strncpy(enum_type, enum_name, MAX_TPNCP_DB_ENTRY_LEN); + enum_type[MAX_TPNCP_DB_ENTRY_LEN-1] = '\0'; } tpncp_enums_id_vals[enum_val][i].strptr = g_strdup(enum_str); tpncp_enums_id_vals[enum_val][i].value = enum_id; @@ -639,7 +640,8 @@ static gint init_tpncp_data_fields_info(tpncp_data_field_info *data_fields_info, } current_tpncp_data_field_info->tpncp_data_field_descr = -1; hf_entr.p_id = ¤t_tpncp_data_field_info->tpncp_data_field_descr; - strcpy(current_tpncp_data_field_info->tpncp_data_field_name, tpncp_data_field_name); + strncpy(current_tpncp_data_field_info->tpncp_data_field_name, tpncp_data_field_name, MAX_TPNCP_DATA_FIELD_NAME_LEN); + current_tpncp_data_field_info->tpncp_data_field_name[MAX_TPNCP_DATA_FIELD_NAME_LEN-1] = '\0'; hf_entr.hfinfo.name = current_tpncp_data_field_info->tpncp_data_field_name; hf_entr.hfinfo.abbrev = current_tpncp_data_field_info->tpncp_data_field_name; switch (tpncp_data_field_size) { -- cgit v1.2.1