aboutsummaryrefslogtreecommitdiffstats
path: root/packet-telnet.c
diff options
context:
space:
mode:
authorGilbert Ramirez <gram@alumni.rice.edu>2001-10-26 02:55:20 +0000
committerGilbert Ramirez <gram@alumni.rice.edu>2001-10-26 02:55:20 +0000
commit74436f3854c69c27a093da0f5369825c84c1cb52 (patch)
tree42a459ce3883b2de0b950c9fde3481a39914e660 /packet-telnet.c
parent44dd278a0ce381bd618e0948e413b039234da159 (diff)
Guard against erroneously calculating a negative length during the
processing of sub-options. svn path=/trunk/; revision=4084
Diffstat (limited to 'packet-telnet.c')
-rw-r--r--packet-telnet.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/packet-telnet.c b/packet-telnet.c
index 93a8809a61..a1c9b28a0a 100644
--- a/packet-telnet.c
+++ b/packet-telnet.c
@@ -2,7 +2,7 @@
* Routines for telnet packet dissection
* Copyright 1999, Richard Sharpe <rsharpe@ns.aus.com>
*
- * $Id: packet-telnet.c,v 1.24 2001/01/25 06:14:14 guy Exp $
+ * $Id: packet-telnet.c,v 1.25 2001/10/26 02:55:20 gram Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@zing.org>
@@ -152,17 +152,19 @@ telnet_sub_option(proto_tree *telnet_tree, tvbuff_t *tvb, int start_offset)
subneg_len = offset - start_offset;
- ti = proto_tree_add_text(telnet_tree, tvb, start_offset, subneg_len,
- "Suboption Begin: %s", opt);
+ if (subneg_len > 0) {
+ ti = proto_tree_add_text(telnet_tree, tvb, start_offset, subneg_len,
+ "Suboption Begin: %s", opt);
- option_tree = proto_item_add_subtree(ti, ett_telnet_subopt);
+ option_tree = proto_item_add_subtree(ti, ett_telnet_subopt);
- proto_tree_add_text(option_tree, tvb, start_offset + 2, 2,
- "%s %s", (req ? "Send your" : "Here's my"), opt);
+ proto_tree_add_text(option_tree, tvb, start_offset + 2, 2,
+ "%s %s", (req ? "Send your" : "Here's my"), opt);
- if (req == 0) { /* Add the value */
- proto_tree_add_text(option_tree, tvb, start_offset + 4, subneg_len - 4,
- "Value: %s", tvb_format_text(tvb, start_offset + 4, subneg_len - 4));
+ if (req == 0) { /* Add the value */
+ proto_tree_add_text(option_tree, tvb, start_offset + 4, subneg_len - 4,
+ "Value: %s", tvb_format_text(tvb, start_offset + 4, subneg_len - 4));
+ }
}
return offset;
}