diff options
author | sahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7> | 2005-10-16 00:14:19 +0000 |
---|---|---|
committer | sahlberg <sahlberg@f5534014-38df-0310-8fa8-9805f1628bb7> | 2005-10-16 00:14:19 +0000 |
commit | 7db5c78e43f5bbbc41c17f1c69bd1e753aa87b92 (patch) | |
tree | a1afc82ef3dff7e097cd5d58351982158d09b436 /epan/dissectors/packet-dcm.c | |
parent | eb864f9563f7a4aca821531845d5a08b8ac35118 (diff) |
get rid of some strcpy
git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@16234 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-dcm.c')
-rw-r--r-- | epan/dissectors/packet-dcm.c | 39 |
1 files changed, 10 insertions, 29 deletions
diff --git a/epan/dissectors/packet-dcm.c b/epan/dissectors/packet-dcm.c index 3d44b5ae7d..e9601330fa 100644 --- a/epan/dissectors/packet-dcm.c +++ b/epan/dissectors/packet-dcm.c @@ -505,12 +505,10 @@ dcm_tag2str(guint16 grp, guint16 elm, guint8 syntax, tvbuff_t *tvb, int offset, { char *buf; const guint8 *vval; - size_t vval_len; char *p; guint32 tag, val32; guint16 val16; dcmTag_t *dtag; - size_t pl; static dcmTag_t utag = { 0, 0, "(unknown)" }; #define MAX_BUF_LEN 1024 @@ -528,73 +526,56 @@ dcm_tag2str(guint16 grp, guint16 elm, guint8 syntax, tvbuff_t *tvb, int offset, dtag = &utag; DISSECTOR_ASSERT(MAX_BUF_LEN > strlen(dtag->desc)); - strcpy(buf, dtag->desc); - pl = MAX_BUF_LEN - strlen(buf); - p = buf + strlen(buf); + p=buf; + p+=g_snprintf(p, MAX_BUF_LEN-(p-buf), "%s", dtag->desc); if (vr > 0) { vval = tvb_format_text(tvb, vr, 2); - *p++ = ' '; - *p++ = '['; - strcpy(p, vval); - p += strlen(vval); - *p++ = ']'; - *p = 0; - pl -= 5; + p+=g_snprintf(p, MAX_BUF_LEN-(p-buf), " [%s]", vval); } switch (tr > 0 ? tr : dtag->dtype) { case DCM_TSTR: default: /* try ascii */ - *p++ = ' '; vval = tvb_format_text(tvb, offset, len); - vval_len = strlen(vval); - if (vval_len > pl) { - strncpy(p, vval, pl - 6); - p += pl - 6; - strcpy(p, "[...]"); - } else { - strncpy(p, vval, vval_len); - p += vval_len; - *p = 0; - } + p+=g_snprintf(p, MAX_BUF_LEN-(p-buf), " %s", vval); break; case DCM_TINT2: if (DCM_ILE & syntax) val16 = tvb_get_letohs(tvb, offset); else val16 = tvb_get_ntohs(tvb, offset); - g_snprintf(p, MAX_BUF_LEN-(p-buf), " 0x%x (%d)", val16, val16); + p+=g_snprintf(p, MAX_BUF_LEN-(p-buf), " 0x%x (%d)", val16, val16); break; case DCM_TINT4: if (DCM_ILE & syntax) val32 = tvb_get_letohl(tvb, offset); else val32 = tvb_get_ntohl(tvb, offset); - g_snprintf(p, MAX_BUF_LEN-(p-buf), " 0x%x (%d)", val32, val32); + p+=g_snprintf(p, MAX_BUF_LEN-(p-buf), " 0x%x (%d)", val32, val32); break; case DCM_TFLT: { gfloat valf; if (DCM_ILE & syntax) valf = tvb_get_letohieee_float(tvb, offset); else valf = tvb_get_ntohieee_float(tvb, offset); - g_snprintf(p, MAX_BUF_LEN-(p-buf), " (%f)", valf); + p+=g_snprintf(p, MAX_BUF_LEN-(p-buf), " (%f)", valf); } break; case DCM_TDBL: { gdouble vald; if (DCM_ILE & syntax) vald = tvb_get_letohieee_double(tvb, offset); else vald = tvb_get_ntohieee_double(tvb, offset); - g_snprintf(p, MAX_BUF_LEN-(p-buf), " (%f)", vald); + p+=g_snprintf(p, MAX_BUF_LEN-(p-buf), " (%f)", vald); } break; case DCM_TSTAT: /* call dcm_rsp2str() on TINT2 */ if (DCM_ILE & syntax) val16 = tvb_get_letohs(tvb, offset); else val16 = tvb_get_ntohs(tvb, offset); - g_snprintf(p, MAX_BUF_LEN-(p-buf), " 0x%x '%s'", val16, dcm_rsp2str(val16)); + p+=g_snprintf(p, MAX_BUF_LEN-(p-buf), " 0x%x '%s'", val16, dcm_rsp2str(val16)); break; case DCM_TCMD: /* call dcm_cmd2str() on TINT2 */ if (DCM_ILE & syntax) val16 = tvb_get_letohs(tvb, offset); else val16 = tvb_get_ntohs(tvb, offset); - g_snprintf(p, MAX_BUF_LEN-(p-buf), " 0x%x '%s'", val16, dcm_cmd2str(val16)); + p+=g_snprintf(p, MAX_BUF_LEN-(p-buf), " 0x%x '%s'", val16, dcm_cmd2str(val16)); break; case DCM_SQ: /* Sequence */ case DCM_OTH: /* Other BYTE, WORD, ... */ |