aboutsummaryrefslogtreecommitdiffstats
path: root/packet-ipdc.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2004-03-20 08:01:07 +0000
committerGuy Harris <guy@alum.mit.edu>2004-03-20 08:01:07 +0000
commit4f9cce3ea8bcbdc7b8286d7a55ba26591d714532 (patch)
treed258aa7f60f5ad49c93cbc63df4fcb1b51d5a51e /packet-ipdc.c
parent27449310dbdab42ae02b84a46f3a0b58b3803ab2 (diff)
downloadwireshark-4f9cce3ea8bcbdc7b8286d7a55ba26591d714532.tar.gz
wireshark-4f9cce3ea8bcbdc7b8286d7a55ba26591d714532.tar.bz2
wireshark-4f9cce3ea8bcbdc7b8286d7a55ba26591d714532.zip
"tmp_tag_text" can hold a string of up to 255 characters, which means it
needs to be 256 characters long to hold a maximum-length string plus a terminating '\0', as noted by Stefan Esser. Don't bother putting in the null terminator at the end in the case where we're putting an IP address or address/port into "tmp_tag_text" - "sprintf()" does that for you. In the case where it's an IP address and port, do it all in one sprintf call - I don't think there's a guarantee that sprintf(tmp_tag_text, "%s:%u", tmp_tag_text, ...) works, although it could work. Also, handle the case where the length is neither 4 (IP address) nor 6 (IP address/port). svn path=/trunk/; revision=10418
Diffstat (limited to 'packet-ipdc.c')
-rw-r--r--packet-ipdc.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/packet-ipdc.c b/packet-ipdc.c
index 05ceee98a8..ff3b5d2dca 100644
--- a/packet-ipdc.c
+++ b/packet-ipdc.c
@@ -3,7 +3,7 @@
* Copyright Lucent Technologies 2004
* Josh Bailey <joshbailey@lucent.com> and Ruud Linders <ruud@lucent.com>
*
- * $Id: packet-ipdc.c,v 1.2 2004/03/20 05:53:40 guy Exp $
+ * $Id: packet-ipdc.c,v 1.3 2004/03/20 08:01:07 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -84,7 +84,7 @@ dissect_ipdc_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
char *des;
char *enum_val;
char *tmp_str;
- char tmp_tag_text[255];
+ char tmp_tag_text[255+1];
const value_string *val_ptr;
guint32 type;
guint len;
@@ -197,13 +197,13 @@ dissect_ipdc_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
type = ipdc_tag_types[i].type;
tmp_tag = 0;
- tmp_tag_text[len] = 0;
switch (type) {
/* simple ASCII strings */
case ASCII:
tmp_str = tvb_memdup(tvb, offset + 2, len);
strncpy(tmp_tag_text, tmp_str, len);
+ tmp_tag_text[len] = 0;
free(tmp_str);
proto_tree_add_text(tag_tree, tvb, offset,
len + 2, "0x%2.2x: %s: %s", tag, des,
@@ -240,18 +240,22 @@ dissect_ipdc_common(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
/* IP addresses */
case IPA:
- if (len >= 4) {
+ if (len == 4) {
sprintf(tmp_tag_text, "%u.%u.%u.%u",
tvb_get_guint8(tvb, offset + 2),
tvb_get_guint8(tvb, offset + 3),
tvb_get_guint8(tvb, offset + 4),
tvb_get_guint8(tvb, offset + 5));
- }
-
- if (len == 6) {
- sprintf(tmp_tag_text, "%s:%u",
- tmp_tag_text,
+ } else if (len == 6) {
+ sprintf(tmp_tag_text, "%u.%u.%u.%u:%u",
+ tvb_get_guint8(tvb, offset + 2),
+ tvb_get_guint8(tvb, offset + 3),
+ tvb_get_guint8(tvb, offset + 4),
+ tvb_get_guint8(tvb, offset + 5),
tvb_get_ntohs(tvb, offset + 6));
+ } else {
+ sprintf(tmp_tag_text,
+ "Invalid IP address length %u", len);
}
proto_tree_add_text(tag_tree, tvb,