diff options
author | Guy Harris <guy@alum.mit.edu> | 2003-12-23 21:22:00 +0000 |
---|---|---|
committer | Guy Harris <guy@alum.mit.edu> | 2003-12-23 21:22:00 +0000 |
commit | 821baa3d48ae58afb1da20e5f4f7e0699c1520b6 (patch) | |
tree | 2766be43df63431fc4fe45f4591cd8a8b16f57fd | |
parent | 8afbfc0c6097596b50d41c849210337bd9c41ccc (diff) | |
download | wireshark-821baa3d48ae58afb1da20e5f4f7e0699c1520b6.tar.gz wireshark-821baa3d48ae58afb1da20e5f4f7e0699c1520b6.tar.bz2 wireshark-821baa3d48ae58afb1da20e5f4f7e0699c1520b6.zip |
Have "tvb_ensure_length_remaining()" throw the appropriate exception if
there's no data remaining - its callers largely depend on it doing so.
That means that the BEEP dissector doesn't have to check for it
returning 0.
svn path=/trunk/; revision=9433
-rw-r--r-- | epan/tvbuff.c | 13 | ||||
-rw-r--r-- | packet-beep.c | 5 |
2 files changed, 13 insertions, 5 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 35846a26c9..f0e2ed3596 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -9,7 +9,7 @@ * the data of a backing tvbuff, or can be a composite of * other tvbuffs. * - * $Id: tvbuff.c,v 1.54 2003/12/03 10:14:34 sahlberg Exp $ + * $Id: tvbuff.c,v 1.55 2003/12/23 21:22:00 guy Exp $ * * Copyright (c) 2000 by Gilbert Ramirez <gram@alumni.rice.edu> * @@ -590,6 +590,17 @@ tvb_ensure_length_remaining(tvbuff_t *tvb, gint offset) if (!compute_offset_length(tvb, offset, -1, &abs_offset, &abs_length, &exception)) { THROW(exception); } + if (abs_length == 0) { + /* + * This routine ensures there's at least one byte available. + * There aren't any bytes available, so throw the appropriate + * exception. + */ + if (abs_offset > tvb->reported_length) + THROW(ReportedBoundsError); + else + THROW(BoundsError); + } return abs_length; } diff --git a/packet-beep.c b/packet-beep.c index ece630ccde..8be72383fd 100644 --- a/packet-beep.c +++ b/packet-beep.c @@ -1,7 +1,7 @@ /* packet-beep.c * Routines for BEEP packet disassembly * - * $Id: packet-beep.c,v 1.13 2003/07/25 04:17:36 gram Exp $ + * $Id: packet-beep.c,v 1.14 2003/12/23 21:18:57 guy Exp $ * * Copyright (c) 2000 by Richard Sharpe <rsharpe@ns.aus.com> * Modified 2001 Darren New <dnew@invisible.net> for BEEP. @@ -389,9 +389,6 @@ static int header_len(tvbuff_t *tvb, int offset) while (1) { - if (tvb_ensure_length_remaining(tvb, offset + i) < 1) - return i; /* Not enough characters left ... */ - if ((sc = tvb_get_guint8(tvb, offset + i)) == 0x0d && tvb_get_guint8(tvb, offset + i + 1) == 0x0a) return i; /* Done here ... */ |