CBOR: Avoid infinite loop when sequence has not-well-formed data
This fixes a defect in the original MR !4752 adding cbor sequence dissecting.
This commit is contained in:
parent
a114a115ba
commit
1120f545d3
|
@ -709,12 +709,16 @@ dissect_cborseq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void
|
||||||
gint offset = 0;
|
gint offset = 0;
|
||||||
proto_item *cbor_root;
|
proto_item *cbor_root;
|
||||||
proto_tree *cbor_tree;
|
proto_tree *cbor_tree;
|
||||||
|
proto_item *elem;
|
||||||
|
|
||||||
cbor_root = proto_tree_add_item(parent_tree, proto_cbor, tvb, offset, -1, ENC_NA);
|
cbor_root = proto_tree_add_item(parent_tree, proto_cbor, tvb, offset, -1, ENC_NA);
|
||||||
proto_item_append_text(cbor_root, " Sequence");
|
proto_item_append_text(cbor_root, " Sequence");
|
||||||
cbor_tree = proto_item_add_subtree(cbor_root, ett_cbor);
|
cbor_tree = proto_item_add_subtree(cbor_root, ett_cbor);
|
||||||
while ((guint)offset < tvb_reported_length(tvb)) {
|
while ((guint)offset < tvb_reported_length(tvb)) {
|
||||||
dissect_cbor_main_type(tvb, pinfo, cbor_tree, &offset);
|
elem = dissect_cbor_main_type(tvb, pinfo, cbor_tree, &offset);
|
||||||
|
if (!elem) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
|
|
|
@ -29,16 +29,22 @@ def main():
|
||||||
help='The diagnostic text input file, or "-" for stdin')
|
help='The diagnostic text input file, or "-" for stdin')
|
||||||
parser.add_argument('--outfile', default='-',
|
parser.add_argument('--outfile', default='-',
|
||||||
help='The PCAP output file, or "-" for stdout')
|
help='The PCAP output file, or "-" for stdout')
|
||||||
|
parser.add_argument('--intype', default='cbordiag',
|
||||||
|
choices=['cbordiag', 'raw'],
|
||||||
|
help='The input data type.')
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
# First get the CBOR data itself
|
# First get the CBOR data itself
|
||||||
infile_name = args.infile.strip()
|
infile_name = args.infile.strip()
|
||||||
if infile_name != '-':
|
if infile_name != '-':
|
||||||
infile = open(infile_name, 'r')
|
infile = open(infile_name, 'rb')
|
||||||
else:
|
else:
|
||||||
infile = sys.stdin
|
infile = sys.stdin.buffer
|
||||||
|
|
||||||
cbordata = check_output('diag2cbor.rb', stdin=infile)
|
if args.intype == 'raw':
|
||||||
|
cbordata = infile.read()
|
||||||
|
elif args.intype == 'cbordiag':
|
||||||
|
cbordata = check_output('diag2cbor.rb', stdin=infile)
|
||||||
|
|
||||||
# Now synthesize an HTTP request with that body
|
# Now synthesize an HTTP request with that body
|
||||||
req = HTTPRequest(
|
req = HTTPRequest(
|
||||||
|
|
Loading…
Reference in New Issue