diff options
Diffstat (limited to 'libcpu')
-rw-r--r-- | libcpu/ChangeLog | 13 | ||||
-rw-r--r-- | libcpu/Makefile.am | 3 | ||||
-rw-r--r-- | libcpu/i386_disasm.c | 11 | ||||
-rw-r--r-- | libcpu/i386_parse.y | 1 |
4 files changed, 23 insertions, 5 deletions
diff --git a/libcpu/ChangeLog b/libcpu/ChangeLog index 52567be8..a342b7f6 100644 --- a/libcpu/ChangeLog +++ b/libcpu/ChangeLog @@ -1,3 +1,16 @@ +2020-05-09 Mark Wielaard <mark@klomp.org> + + * i386_parse.y (new_bitfield): Call free newp on error. + +2020-04-16 Mark Wielaard <mark@klomp.org> + + * i386_disasm.c (i386_disasm): Replace assert with goto invalid_op + for bad prefix. + +2019-12-11 Omar Sandoval <osandov@fb.com> + + * Makefile.am (i386_lex_CFLAGS): Add -Wno-implicit-fallthrough. + 2019-10-17 Mark Wielaard <mark@klomp.org> * i386_data.h (FCT_sel): Check for param_start + 2 >= end instead diff --git a/libcpu/Makefile.am b/libcpu/Makefile.am index 03c71ea3..59def7d1 100644 --- a/libcpu/Makefile.am +++ b/libcpu/Makefile.am @@ -81,7 +81,8 @@ i386_lex_no_Werror = yes libeu = ../lib/libeu.a -i386_lex_CFLAGS = -Wno-unused-label -Wno-unused-function -Wno-sign-compare +i386_lex_CFLAGS = -Wno-unused-label -Wno-unused-function -Wno-sign-compare \ + -Wno-implicit-fallthrough i386_parse.o: i386_parse.c i386.mnemonics i386_parse_CFLAGS = -DNMNES="`wc -l < i386.mnemonics`" i386_lex.o: i386_parse.h diff --git a/libcpu/i386_disasm.c b/libcpu/i386_disasm.c index 4422ffa2..32df8cd0 100644 --- a/libcpu/i386_disasm.c +++ b/libcpu/i386_disasm.c @@ -407,7 +407,8 @@ i386_disasm (Ebl *ebl __attribute__((unused)), ++curr; - assert (last_prefix_bit != 0); + if (last_prefix_bit == 0) + goto invalid_op; correct_prefix = last_prefix_bit; } @@ -445,8 +446,8 @@ i386_disasm (Ebl *ebl __attribute__((unused)), the input data. */ goto do_ret; - assert (correct_prefix == 0 - || (prefixes & correct_prefix) != 0); + if (correct_prefix != 0 && (prefixes & correct_prefix) == 0) + goto invalid_op; prefixes ^= correct_prefix; if (0) @@ -473,7 +474,8 @@ i386_disasm (Ebl *ebl __attribute__((unused)), if (data == end) { - assert (prefixes != 0); + if (prefixes == 0) + goto invalid_op; goto print_prefix; } @@ -1125,6 +1127,7 @@ i386_disasm (Ebl *ebl __attribute__((unused)), } /* Invalid (or at least unhandled) opcode. */ + invalid_op: if (prefixes != 0) goto print_prefix; /* Make sure we get past the unrecognized opcode if we haven't yet. */ diff --git a/libcpu/i386_parse.y b/libcpu/i386_parse.y index 910d5458..90c7bd93 100644 --- a/libcpu/i386_parse.y +++ b/libcpu/i386_parse.y @@ -579,6 +579,7 @@ new_bitfield (char *name, unsigned long int num) error (0, 0, "%d: duplicated definition of bitfield '%s'", i386_lineno, name); free (name); + free (newp); return; } |