diff --git a/epan/dissectors/packet-cbor.c b/epan/dissectors/packet-cbor.c index 8a9710f5cd..5ca3a4d6d0 100644 --- a/epan/dissectors/packet-cbor.c +++ b/epan/dissectors/packet-cbor.c @@ -709,12 +709,16 @@ dissect_cborseq(tvbuff_t *tvb, packet_info *pinfo, proto_tree *parent_tree, void gint offset = 0; proto_item *cbor_root; proto_tree *cbor_tree; + proto_item *elem; cbor_root = proto_tree_add_item(parent_tree, proto_cbor, tvb, offset, -1, ENC_NA); proto_item_append_text(cbor_root, " Sequence"); cbor_tree = proto_item_add_subtree(cbor_root, ett_cbor); 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; diff --git a/tools/generate_cbor_pcap.py b/tools/generate_cbor_pcap.py index d515a44556..545b985eb1 100755 --- a/tools/generate_cbor_pcap.py +++ b/tools/generate_cbor_pcap.py @@ -29,16 +29,22 @@ def main(): help='The diagnostic text input file, or "-" for stdin') parser.add_argument('--outfile', default='-', 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() # First get the CBOR data itself infile_name = args.infile.strip() if infile_name != '-': - infile = open(infile_name, 'r') + infile = open(infile_name, 'rb') 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 req = HTTPRequest(