lib/ctf-ir/trace.c: validate PH `packet_seq_num` field
authorPhilippe Proulx <eeppeliteloop@gmail.com>
Thu, 22 Jun 2017 15:17:42 +0000 (11:17 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Thu, 6 Jul 2017 20:16:54 +0000 (16:16 -0400)
Must be an unsigned integer field if it exists.

Signed-off-by: Philippe Proulx <eeppeliteloop@gmail.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
lib/ctf-ir/trace.c

index 634a71efd863af6ec05842d2374cbb4a3c23dd24..110c20d4ebff28950373fb12419c22a7db5373a5 100644 (file)
@@ -793,6 +793,30 @@ bool packet_header_field_type_is_valid(struct bt_ctf_trace *trace,
                BT_PUT(field_type);
        }
 
+       /*
+        * If there's a `packet_seq_num` field, it must be an unsigned
+        * integer field type.
+        */
+       field_type = bt_ctf_field_type_structure_get_field_type_by_name(
+               packet_header_type, "packet_seq_num");
+       if (field_type) {
+               if (!bt_ctf_field_type_is_integer(field_type)) {
+                       BT_LOGW("Invalid packet header field type: `packet_seq_num` field must be an integer field type: "
+                               "stream-id-ft-addr=%p, packet-seq-num-ft-id=%s",
+                               field_type,
+                               bt_ctf_field_type_id_string(field_type->id));
+                       goto invalid;
+               }
+
+               if (bt_ctf_field_type_integer_is_signed(field_type)) {
+                       BT_LOGW("Invalid packet header field type: `packet_seq_num` field must be an unsigned integer field type: "
+                               "packet-seq-num-ft-addr=%p", field_type);
+                       goto invalid;
+               }
+
+               BT_PUT(field_type);
+       }
+
        goto end;
 
 invalid:
This page took 0.025671 seconds and 4 git commands to generate.