aboutsummaryrefslogtreecommitdiffstats
path: root/epan/dissectors/packet-pgsql.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2005-03-06 03:11:24 +0000
committerGuy Harris <guy@alum.mit.edu>2005-03-06 03:11:24 +0000
commit2ad3b256f4c8d7fcd6b438552e1db55ddd2e4ecb (patch)
tree2dc39d0881934c61c0edd4c3680417b4135faf12 /epan/dissectors/packet-pgsql.c
parent17dc5ee62e5a85ce8eaa9b2fb41f88e95f5abeb8 (diff)
Handle the "32-bit length is > 2^31-1, so the protocol tree routines
will treat it as negative" problem by first calling "tvb_ensure_bytes_exist()" - if the length is *that* large, it will run past the end of the tvbuff, so the exception that "tvb_ensure_bytes_exist()" will throw with a negative argument will be the correct exception. svn path=/trunk/; revision=13614
Diffstat (limited to 'epan/dissectors/packet-pgsql.c')
-rw-r--r--epan/dissectors/packet-pgsql.c18
1 files changed, 13 insertions, 5 deletions
diff --git a/epan/dissectors/packet-pgsql.c b/epan/dissectors/packet-pgsql.c
index 34371d0a10..a63e9d36ad 100644
--- a/epan/dissectors/packet-pgsql.c
+++ b/epan/dissectors/packet-pgsql.c
@@ -3,7 +3,7 @@
* <http://www.postgresql.org/docs/current/static/protocol.html>
* Copyright 2004 Abhijit Menon-Sen <ams@oryx.com>
*
- * $Id $
+ * $Id$
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -524,9 +524,13 @@ static void dissect_pgsql_fe_msg(guchar type, guint32 n, guint32 length,
l = tvb_get_ntohl(tvb, n);
proto_tree_add_int(shrub, hf_val_length, tvb, n, 4, l);
n += 4;
- /* XXX - if we don't limit l here, the function will assert on very large values */
- if (l > 0 && l < 1000000)
+ if (l > 0) {
+ /* Use tvb_ensure_bytes_exist() to handle the case where l
+ is > 2^32-1, so we don't have a problem with negative
+ values. */
+ tvb_ensure_bytes_exist(tvb, n, l);
proto_tree_add_item(shrub, hf_val_data, tvb, n, l, FALSE);
+ }
n += l;
}
@@ -779,9 +783,13 @@ static void dissect_pgsql_be_msg(guchar type, guint32 n, guint32 length,
l = tvb_get_ntohl(tvb, n);
proto_tree_add_int(shrub, hf_val_length, tvb, n, 4, l);
n += 4;
- /* XXX - if we don't limit l here, the function will assert on very large values */
- if (l > 0 && l < 1000000)
+ if (l > 0) {
+ /* Use tvb_ensure_bytes_exist() to handle the case where l
+ is > 2^32-1, so we don't have a problem with negative
+ values. */
+ tvb_ensure_bytes_exist(tvb, n, l);
proto_tree_add_item(shrub, hf_val_data, tvb, n, l, FALSE);
+ }
n += l;
}
break;