From bf3b1dbd6917a02fc97daf64adb84f1deca507ff Mon Sep 17 00:00:00 2001 From: Guy Harris Date: Fri, 25 Oct 2002 21:09:36 +0000 Subject: [PATCH] Correctly handle the "no IAC found" case in "telnet_sub_option()". Handle the "unknown command" case in "telnet_command()". svn path=/trunk/; revision=6507 --- packet-telnet.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packet-telnet.c b/packet-telnet.c index 238a509968..6c44d58755 100644 --- a/packet-telnet.c +++ b/packet-telnet.c @@ -2,7 +2,7 @@ * Routines for telnet packet dissection * Copyright 1999, Richard Sharpe * - * $Id: packet-telnet.c,v 1.32 2002/08/28 21:00:36 jmayer Exp $ + * $Id: packet-telnet.c,v 1.33 2002/10/25 21:09:36 guy Exp $ * * Ethereal - Network traffic analyzer * By Gerald Combs @@ -120,6 +120,7 @@ telnet_sub_option(proto_tree *telnet_tree, tvbuff_t *tvb, int start_offset) guint8 opt_byte; int subneg_len, req; const guchar *opt; + int iac_offset; guint len; offset += 2; /* skip IAC and SB */ @@ -136,11 +137,12 @@ telnet_sub_option(proto_tree *telnet_tree, tvbuff_t *tvb, int start_offset) /* Search for an IAC. */ len = tvb_length_remaining(tvb, offset); - offset = tvb_find_guint8(tvb, offset, len, TN_IAC); + iac_offset = tvb_find_guint8(tvb, offset, len, TN_IAC); if (offset == -1) { /* None found - run to the end of the packet. */ offset += len; - } + } else + offset = iac_offset; subneg_len = offset - start_offset; @@ -286,6 +288,11 @@ telnet_command(proto_tree *telnet_tree, tvbuff_t *tvb, int start_offset) offset = telnet_will_wont_do_dont(telnet_tree, tvb, start_offset, "Don't"); break; + + default: + proto_tree_add_text(telnet_tree, tvb, start_offset, 2, + "Command: Unknown (0x%02x)", optcode); + break; } return offset;