Filter error message cleanup
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 19 Sep 2012 18:00:41 +0000 (14:00 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Wed, 19 Sep 2012 18:00:41 +0000 (14:00 -0400)
When encountering an invalid opcode, don't print that an overflow has
occurred.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
liblttng-ust/lttng-filter-validator.c

index 4e257f5d9b969558f29e15dfcd34d3ea0e33dd85..456407ffde228fa625e3973b3d5e02c71b0bd4d7 100644 (file)
@@ -190,7 +190,7 @@ int bytecode_validate_overflow(struct bytecode_runtime *bytecode,
        {
                if (unlikely(pc + sizeof(struct return_op)
                                > start_pc + bytecode->len)) {
-                       ret = -EINVAL;
+                       ret = -ERANGE;
                }
                break;
        }
@@ -252,7 +252,7 @@ int bytecode_validate_overflow(struct bytecode_runtime *bytecode,
        {
                if (unlikely(pc + sizeof(struct binary_op)
                                > start_pc + bytecode->len)) {
-                       ret = -EINVAL;
+                       ret = -ERANGE;
                }
                break;
        }
@@ -270,7 +270,7 @@ int bytecode_validate_overflow(struct bytecode_runtime *bytecode,
        {
                if (unlikely(pc + sizeof(struct unary_op)
                                > start_pc + bytecode->len)) {
-                       ret = -EINVAL;
+                       ret = -ERANGE;
                }
                break;
        }
@@ -281,7 +281,7 @@ int bytecode_validate_overflow(struct bytecode_runtime *bytecode,
        {
                if (unlikely(pc + sizeof(struct logical_op)
                                > start_pc + bytecode->len)) {
-                       ret = -EINVAL;
+                       ret = -ERANGE;
                }
                break;
        }
@@ -300,7 +300,7 @@ int bytecode_validate_overflow(struct bytecode_runtime *bytecode,
        {
                if (unlikely(pc + sizeof(struct load_op) + sizeof(struct field_ref)
                                > start_pc + bytecode->len)) {
-                       ret = -EINVAL;
+                       ret = -ERANGE;
                }
                break;
        }
@@ -312,7 +312,7 @@ int bytecode_validate_overflow(struct bytecode_runtime *bytecode,
 
                if (unlikely(pc + sizeof(struct load_op)
                                > start_pc + bytecode->len)) {
-                       ret = -EINVAL;
+                       ret = -ERANGE;
                        break;
                }
 
@@ -320,7 +320,7 @@ int bytecode_validate_overflow(struct bytecode_runtime *bytecode,
                str_len = strnlen(insn->data, maxlen);
                if (unlikely(str_len >= maxlen)) {
                        /* Final '\0' not found within range */
-                       ret = -EINVAL;
+                       ret = -ERANGE;
                }
                break;
        }
@@ -329,7 +329,7 @@ int bytecode_validate_overflow(struct bytecode_runtime *bytecode,
        {
                if (unlikely(pc + sizeof(struct load_op) + sizeof(struct literal_numeric)
                                > start_pc + bytecode->len)) {
-                       ret = -EINVAL;
+                       ret = -ERANGE;
                }
                break;
        }
@@ -338,7 +338,7 @@ int bytecode_validate_overflow(struct bytecode_runtime *bytecode,
        {
                if (unlikely(pc + sizeof(struct load_op) + sizeof(struct literal_double)
                                > start_pc + bytecode->len)) {
-                       ret = -EINVAL;
+                       ret = -ERANGE;
                }
                break;
        }
@@ -349,7 +349,7 @@ int bytecode_validate_overflow(struct bytecode_runtime *bytecode,
        {
                if (unlikely(pc + sizeof(struct cast_op)
                                > start_pc + bytecode->len)) {
-                       ret = -EINVAL;
+                       ret = -ERANGE;
                }
                break;
        }
@@ -1099,9 +1099,10 @@ int lttng_filter_validate_bytecode(struct bytecode_runtime *bytecode)
        start_pc = &bytecode->data[0];
        for (pc = next_pc = start_pc; pc - start_pc < bytecode->len;
                        pc = next_pc) {
-               if (bytecode_validate_overflow(bytecode, start_pc, pc) != 0) {
-                       ERR("filter bytecode overflow\n");
-                       ret = -EINVAL;
+               ret = bytecode_validate_overflow(bytecode, start_pc, pc);
+               if (ret != 0) {
+                       if (ret == -ERANGE)
+                               ERR("filter bytecode overflow\n");
                        goto end;
                }
                dbg_printf("Validating op %s (%u)\n",
This page took 0.027455 seconds and 4 git commands to generate.