Filter: catch shift undefined behavior
[lttng-ust.git] / liblttng-ust / lttng-filter-interpreter.c
index 1e7b12a5da4e0243ed1e00deb9b359b0569bb789..1354d9c1062e5bebf1d764cf31e9116f32124116 100644 (file)
@@ -1557,7 +1557,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data,
                                ret = -EINVAL;
                                goto end;
                        }
-
+                       /* Catch undefined behavior. */
+                       if (caa_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, ax_t, bx_t);
                        estack_ax_v = res;
@@ -1574,7 +1578,11 @@ uint64_t lttng_filter_interpret_bytecode(void *filter_data,
                                ret = -EINVAL;
                                goto end;
                        }
-
+                       /* Catch undefined behavior. */
+                       if (caa_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, ax_t, bx_t);
                        estack_ax_v = res;
This page took 0.023016 seconds and 4 git commands to generate.