diff options
author | Cyrille Bagard <nocbos@gmail.com> | 2017-04-28 20:24:01 (GMT) |
---|---|---|
committer | Cyrille Bagard <nocbos@gmail.com> | 2017-04-28 20:24:01 (GMT) |
commit | aead324676d997c30aac2851f4a37125db195d3e (patch) | |
tree | f862af7240b5d20f2963ae75848ad4abc091bb1d /src | |
parent | 9b14115ff2a497439ea56b42c9a81a192067ec58 (diff) |
Rewritten some security checks when printing immediate values.
Diffstat (limited to 'src')
-rw-r--r-- | src/arch/immediate.c | 5 | ||||
-rw-r--r-- | src/arch/immediate.h | 3 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/arch/immediate.c b/src/arch/immediate.c index 88426de..a6f080f 100644 --- a/src/arch/immediate.c +++ b/src/arch/immediate.c @@ -893,7 +893,7 @@ static size_t _g_imm_operand_to_string(const GImmOperand *operand, AsmSyntax syn static const char *conv_si_defs[] = { "", "o", "d", "x", "c" }; static const char *conv_us_defs[] = { "", "o", "u", "x", "c" }; - result = 0; /* Gcc... */ + assert(display <= IOD_LAST_VALID); range = MDS_RANGE(operand->size); @@ -1042,11 +1042,12 @@ static size_t _g_imm_operand_to_string(const GImmOperand *operand, AsmSyntax syn default: assert(false); + result = 0; break; } - assert(((int)result) > 0); + assert(result > 0); return result; diff --git a/src/arch/immediate.h b/src/arch/immediate.h index b4d1f84..450ceef 100644 --- a/src/arch/immediate.h +++ b/src/arch/immediate.h @@ -54,6 +54,9 @@ typedef enum _ImmOperandDisplay } ImmOperandDisplay; +#define IOD_LAST_VALID IOD_CHAR + + #define G_TYPE_IMM_OPERAND g_imm_operand_get_type() #define G_IMM_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), g_imm_operand_get_type(), GImmOperand)) #define G_IS_IMM_OPERAND(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), g_imm_operand_get_type())) |