From 82513dbe8f7955e583f9135167a391380ddcef4b Mon Sep 17 00:00:00 2001 From: Mathieu Desnoyers Date: Wed, 19 Sep 2012 14:00:41 -0400 Subject: [PATCH] Filter error message cleanup When encountering an invalid opcode, don't print that an overflow has occurred. Signed-off-by: Mathieu Desnoyers --- liblttng-ust/lttng-filter-validator.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/liblttng-ust/lttng-filter-validator.c b/liblttng-ust/lttng-filter-validator.c index 4e257f5d..456407ff 100644 --- a/liblttng-ust/lttng-filter-validator.c +++ b/liblttng-ust/lttng-filter-validator.c @@ -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", -- 2.34.1