aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-clnp.c
diff options
context:
space:
mode:
authorjmayer <jmayer@f5534014-38df-0310-8fa8-9805f1628bb7>2006-01-16 07:59:44 +0000
committerjmayer <jmayer@f5534014-38df-0310-8fa8-9805f1628bb7>2006-01-16 07:59:44 +0000
commit2d665bfc89ed77768a05df1289b6e0d242701c58 (patch)
treeae17681289f1f8a5dedc49668631f2ea79dce8fb /epan/dissectors/packet-clnp.c
parent631c29fa27362bacee6f09054cbf4901cc34d71b (diff)
done:
packet-ntp.c: Rather confused and incorrect use of g_snprintf return value packet-pim.c: whitespace change packet-icmpv6.c: g_snprintf takes trailing \0 into account, fix off by 1 error packet-clnp.c: Fix incorrect use of g_snprintf return value packet-isakmp.c: g_snprintf takes trailing \0 into account packet-tr.c: Fix incorrect use of g_snprintf return value packet-radius.c: Fix incorrect use of g_snprintf return value packet-radius.h: constify a string variable packet-ldap.c: The return value isn't needed, so don't use it incorrectly packet-tcp.c: Fix incorrect use of g_snprintf return value packet-windows-common.c: Remove unneeded DISSECTOR_ASSERT packet-smb-sidsnooping.c: g_snprintf takes trailing \0 into account packet-pvfs2.c: g_snprintf takes trailing \0 into account packet-ptp.c: Remove #include snprintf packet-ppp.c: Fix incorrect use of g_snprintf return value packet-ospf.c: Fix incorrect use of g_snprintf return value packet-mip6.c: snprintf -> g_snprintf packet-bootp.c: Remove a commented out bad use of g_snprintf packet-ber.c: snprintf -> g_snprintf, g_snprintf takes trailing \0 into account 2do: 52 packet-ieee80211.c: 2DO 2 packet-nfs.c: 2DO - too many side effects 33 packet-bgp.c: 2DO 18 packet-dns.c: 2DO 14 packet-dcm.c: 2DO 13 packet-x11.c: 2DO 11 packet-kerberos.c: 2DO 10 packet-diameter.c: 2DO 9 packet-snmp.c: 2DO 9 packet-pgm.c: 2DO 7 packet-nbns.c: 2DO 6 packet-fcswils.c: 2DO 5 packet-wccp.c: 2DO 5 packet-cops.c: 2DO 4 packet-wtp.c: 2DO git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@17038 f5534014-38df-0310-8fa8-9805f1628bb7
Diffstat (limited to 'epan/dissectors/packet-clnp.c')
-rw-r--r--epan/dissectors/packet-clnp.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/epan/dissectors/packet-clnp.c b/epan/dissectors/packet-clnp.c
index 1e759199fc..8c99b34a9e 100644
--- a/epan/dissectors/packet-clnp.c
+++ b/epan/dissectors/packet-clnp.c
@@ -418,8 +418,9 @@ static gboolean is_all_printable(const guchar *stringtocheck, int length)
static gchar *print_tsap(const guchar *tsap, int length)
{
- gchar *cur, *tmp;
+ gchar *cur;
gboolean allprintable;
+ size_t index = 0, returned_length;
cur=ep_alloc(MAX_TSAP_LEN * 2 + 3);
cur[0] = '\0';
@@ -427,14 +428,17 @@ static gchar *print_tsap(const guchar *tsap, int length)
g_snprintf(cur, MAX_TSAP_LEN * 2 + 3, "<unsupported TSAP length>");
else {
allprintable = is_all_printable(tsap,length);
- tmp=cur;
if (!allprintable)
- tmp+=g_snprintf(tmp, (MAX_TSAP_LEN * 2 + 3)-(tmp-cur), "0x");
+ returned_length = g_snprintf(cur, MAX_TSAP_LEN * 2 + 3, "0x");
+ index += MIN(returned_length, MAX_TSAP_LEN * 2 + 3 - 1);
while (length != 0) {
- if (allprintable)
- tmp+=g_snprintf(tmp, (MAX_TSAP_LEN * 2 + 3)-(tmp-cur), "%c", *tsap ++);
- else
- tmp+=g_snprintf(tmp, (MAX_TSAP_LEN * 2 + 3)-(tmp-cur), "%02x", *tsap ++);
+ if (allprintable) {
+ returned_length = g_snprintf(&cur[index], MAX_TSAP_LEN * 2 + 3 - index, "%c", *tsap ++);
+ index += MIN(returned_length, MAX_TSAP_LEN * 2 + 3 - index - 1 );
+ } else {
+ returned_length = g_snprintf(&cur[index], MAX_TSAP_LEN * 2 + 3 - index, "%02x", *tsap ++);
+ index += MIN(returned_length, MAX_TSAP_LEN * 2 + 3 - index - 1);
+ }
length --;
}
}