diff options
author | Gerald Combs <gerald@wireshark.org> | 2005-03-28 15:55:47 +0000 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2005-03-28 15:55:47 +0000 |
commit | 131ab36a3257aec679019b7877fcf5055f9e3bca (patch) | |
tree | 566af01360ddc5c0ebc696f2f8f1b08b8fdeaec2 /epan/tvbuff.c | |
parent | 9d6ac60cefff17895674beaf30447b7a2c9285fc (diff) |
In tvb_get_string(), throw an exception if our length is less than zero.
Add a message block length check to the AIM dissector.
svn path=/trunk/; revision=13955
Diffstat (limited to 'epan/tvbuff.c')
-rw-r--r-- | epan/tvbuff.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/epan/tvbuff.c b/epan/tvbuff.c index 11e029106b..c184d9ba9e 100644 --- a/epan/tvbuff.c +++ b/epan/tvbuff.c @@ -1711,12 +1711,16 @@ guint8 * tvb_get_string(tvbuff_t *tvb, gint offset, gint length) { const guint8 *ptr; - guint8 *strbuf; + guint8 *strbuf = NULL; + + if (length < 0) + THROW(DissectorError); ptr = ensure_contiguous(tvb, offset, length); strbuf = g_malloc(length + 1); - if (length != 0) + if (length != 0) { memcpy(strbuf, ptr, length); + } strbuf[length] = '\0'; return strbuf; } |