Filter: catch shift undefined behavior
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 22 Sep 2017 20:00:13 +0000 (16:00 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 6 Jun 2018 20:42:04 +0000 (16:42 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
lttng-filter-interpreter.c

index 5bf0bd6074719ef59cf5dc8a2fe57f4cc0f5e7e7..b1e5ba7360261a651386ebfa4485093a4a566237 100644 (file)
@@ -990,6 +990,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data,
                {
                        int64_t res;
 
+                       /* Catch undefined behavior. */
+                       if (unlikely(estack_ax_v < 0 || estack_ax_v >= 64)) {
+                               ret = -EINVAL;
+                               goto end;
+                       }
                        res = (estack_bx_v >> estack_ax_v);
                        estack_pop(stack, top, ax, bx);
                        estack_ax_v = res;
@@ -1000,6 +1005,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data,
                {
                        int64_t res;
 
+                       /* Catch undefined behavior. */
+                       if (unlikely(estack_ax_v < 0 || estack_ax_v >= 64)) {
+                               ret = -EINVAL;
+                               goto end;
+                       }
                        res = (estack_bx_v << estack_ax_v);
                        estack_pop(stack, top, ax, bx);
                        estack_ax_v = res;
This page took 0.026619 seconds and 4 git commands to generate.