Fix: bytecode linker: validate event and field array/sequence encoding
[deliverable/lttng-ust.git] / liblttng-ust / lttng-filter.c
index 0508349f39773534e8821b116a66f4c595806005..2db388dc5a3d9ddc3423ee34ab84ae5ab43d7bf9 100644 (file)
@@ -39,8 +39,8 @@ static const char *opnames[] = {
        [ FILTER_OP_MOD ] = "MOD",
        [ FILTER_OP_PLUS ] = "PLUS",
        [ FILTER_OP_MINUS ] = "MINUS",
-       [ FILTER_OP_RSHIFT ] = "RSHIFT",
-       [ FILTER_OP_LSHIFT ] = "LSHIFT",
+       [ FILTER_OP_BIT_RSHIFT ] = "BIT_RSHIFT",
+       [ FILTER_OP_BIT_LSHIFT ] = "BIT_LSHIFT",
        [ FILTER_OP_BIT_AND ] = "BIT_AND",
        [ FILTER_OP_BIT_OR ] = "BIT_OR",
        [ FILTER_OP_BIT_XOR ] = "BIT_XOR",
@@ -168,6 +168,10 @@ static const char *opnames[] = {
        [ FILTER_OP_LOAD_FIELD_STRING ] = "LOAD_FIELD_STRING",
        [ FILTER_OP_LOAD_FIELD_SEQUENCE ] = "LOAD_FIELD_SEQUENCE",
        [ FILTER_OP_LOAD_FIELD_DOUBLE ] = "LOAD_FIELD_DOUBLE",
+
+       [ FILTER_OP_UNARY_BIT_NOT ] = "UNARY_BIT_NOT",
+
+       [ FILTER_OP_RETURN_S64 ] = "RETURN_S64",
 };
 
 const char *print_op(enum filter_op op)
@@ -250,9 +254,23 @@ int apply_field_reloc(struct lttng_event *event,
                        op->op = FILTER_OP_LOAD_FIELD_REF_S64;
                        break;
                case atype_array:
+               {
+                       const struct lttng_basic_type *elem_type = &field->type.u.array.elem_type;
+
+                       if (elem_type != atype_integer || elem_type->u.basic.integer.encoding == lttng_encode_none)
+                               return -EINVAL;
+                       op->op = FILTER_OP_LOAD_FIELD_REF_SEQUENCE;
+                       break;
+               }
                case atype_sequence:
+               {
+                       const struct lttng_basic_type *elem_type = &field->type.u.sequence.elem_type;
+
+                       if (elem_type != atype_integer || elem_type->u.basic.integer.encoding == lttng_encode_none)
+                               return -EINVAL;
                        op->op = FILTER_OP_LOAD_FIELD_REF_SEQUENCE;
                        break;
+               }
                case atype_string:
                        op->op = FILTER_OP_LOAD_FIELD_REF_STRING;
                        break;
@@ -325,9 +343,25 @@ int apply_context_reloc(struct lttng_event *event,
                        op->op = FILTER_OP_GET_CONTEXT_REF_S64;
                        break;
                        /* Sequence and array supported as string */
-               case atype_string:
                case atype_array:
+               {
+                       const struct lttng_basic_type *elem_type = &ctx_field->event_field.type.u.array.elem_type;
+
+                       if (elem_type != atype_integer || elem_type->u.basic.integer.encoding == lttng_encode_none)
+                               return -EINVAL;
+                       op->op = FILTER_OP_GET_CONTEXT_REF_STRING;
+                       break;
+               }
                case atype_sequence:
+               {
+                       const struct lttng_basic_type *elem_type = &ctx_field->event_field.type.u.sequence.elem_type;
+
+                       if (elem_type != atype_integer || elem_type->u.basic.integer.encoding == lttng_encode_none)
+                               return -EINVAL;
+                       op->op = FILTER_OP_GET_CONTEXT_REF_STRING;
+                       break;
+               }
+               case atype_string:
                        op->op = FILTER_OP_GET_CONTEXT_REF_STRING;
                        break;
                case atype_float:
This page took 0.025866 seconds and 5 git commands to generate.