aboutsummaryrefslogtreecommitdiffstats
path: root/packet-cups.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2001-09-20 02:26:03 +0000
committerGuy Harris <guy@alum.mit.edu>2001-09-20 02:26:03 +0000
commitd1ec951825b9cee63227ef9347d1d2b082966e4d (patch)
tree306f81d809090e1cf5c967a8a6f4e82040fbd7b7 /packet-cups.c
parent5644182f655f55319d50c19f4b1e033478cda216 (diff)
"value_string" arrays must end with a terminator entry.
If "get_hex_uint()" supplies a "next_offset" equal to the offset fed into it, it found no hex digits; don't put the value into the tree if that's the case. If "get_unquoted_string()" or "get_quoted_string()" returns NULL, the string separator/terminator wasn't found; don't put the value into the tree if that's the case. svn path=/trunk/; revision=3947
Diffstat (limited to 'packet-cups.c')
-rw-r--r--packet-cups.c46
1 files changed, 30 insertions, 16 deletions
diff --git a/packet-cups.c b/packet-cups.c
index 9525dcb884..aceeaba5f2 100644
--- a/packet-cups.c
+++ b/packet-cups.c
@@ -5,7 +5,7 @@
* Charles Levert <charles@comm.polymtl.ca>
* Copyright 2001 Charles Levert
*
-* $Id: packet-cups.c,v 1.5 2001/06/18 02:17:45 guy Exp $
+* $Id: packet-cups.c,v 1.6 2001/09/20 02:26:03 guy Exp $
*
*
* This program is free software; you can redistribute it and/or
@@ -124,7 +124,8 @@ typedef enum _cups_state {
static const value_string cups_state_values[] = {
{ CUPS_IDLE, "idle" },
{ CUPS_PROCESSING, "processing" },
- { CUPS_STOPPED, "stopped" }
+ { CUPS_STOPPED, "stopped" },
+ { 0, NULL }
};
static int proto_cups = -1;
@@ -180,17 +181,20 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
ptype = get_hex_uint(tvb, offset, &next_offset);
len = next_offset - offset;
- if (cups_tree) {
- ti = proto_tree_add_uint(cups_tree, hf_cups_ptype,
- tvb, offset, len, ptype);
- ptype_subtree = proto_item_add_subtree(ti, ett_cups_ptype);
- for (u = 0; u < N_CUPS_PTYPE_BITS; u++) {
- proto_tree_add_text(ptype_subtree, tvb, offset, len,
- "%s",
- decode_boolean_bitfield(ptype,
- cups_ptype_bits[u].bit, sizeof (ptype)*8,
- cups_ptype_bits[u].on_string,
- cups_ptype_bits[u].off_string));
+ if (len != 0) {
+ if (cups_tree) {
+ ti = proto_tree_add_uint(cups_tree, hf_cups_ptype,
+ tvb, offset, len, ptype);
+ ptype_subtree = proto_item_add_subtree(ti,
+ ett_cups_ptype);
+ for (u = 0; u < N_CUPS_PTYPE_BITS; u++) {
+ proto_tree_add_text(ptype_subtree, tvb,
+ offset, len, "%s",
+ decode_boolean_bitfield(ptype,
+ cups_ptype_bits[u].bit, sizeof (ptype)*8,
+ cups_ptype_bits[u].on_string,
+ cups_ptype_bits[u].off_string));
+ }
}
}
offset = next_offset;
@@ -201,9 +205,11 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
state = get_hex_uint(tvb, offset, &next_offset);
len = next_offset - offset;
- if (cups_tree)
- proto_tree_add_uint(cups_tree, hf_cups_state,
- tvb, offset, len, state);
+ if (len != 0) {
+ if (cups_tree)
+ proto_tree_add_uint(cups_tree, hf_cups_state,
+ tvb, offset, len, state);
+ }
offset = next_offset;
if (!skip_space(tvb, offset, &next_offset))
@@ -211,6 +217,8 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
offset = next_offset;
str = get_unquoted_string(tvb, offset, &next_offset, &len);
+ if (str == NULL)
+ return; /* separator/terminator not found */
if (cups_tree)
proto_tree_add_text(cups_tree, tvb, offset, len,
"URI: %.*s",
@@ -230,6 +238,8 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
offset = next_offset;
str = get_quoted_string(tvb, offset, &next_offset, &len);
+ if (str == NULL)
+ return; /* separator/terminator not found */
proto_tree_add_text(cups_tree, tvb, offset+1, len,
"Location: \"%.*s\"",
(guint16) len, str);
@@ -240,6 +250,8 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
offset = next_offset;
str = get_quoted_string(tvb, offset, &next_offset, &len);
+ if (str == NULL)
+ return; /* separator/terminator not found */
proto_tree_add_text(cups_tree, tvb, offset+1, len,
"Information: \"%.*s\"",
(guint16) len, str);
@@ -250,6 +262,8 @@ dissect_cups(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree)
offset = next_offset;
str = get_quoted_string(tvb, offset, &next_offset, &len);
+ if (str == NULL)
+ return; /* separator/terminator not found */
proto_tree_add_text(cups_tree, tvb, offset+1, len,
"Make and model: \"%.*s\"",
(guint16) len, str);