[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] x86emul: deal with decode failure in predicates test



commit 9dfc82459004c7962afbf9152303068ab0e0bfad
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu Nov 23 10:03:38 2023 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Nov 23 10:03:38 2023 +0100

    x86emul: deal with decode failure in predicates test
    
    Don't let this end in SEGV, due to the subsequent NULL deref.
    
    Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 tools/tests/x86_emulator/predicates.c | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/tools/tests/x86_emulator/predicates.c 
b/tools/tests/x86_emulator/predicates.c
index 744cc847bc..4e90f5b625 100644
--- a/tools/tests/x86_emulator/predicates.c
+++ b/tools/tests/x86_emulator/predicates.c
@@ -2189,6 +2189,13 @@ void do_test(uint8_t *instr, unsigned int len, unsigned 
int modrm,
     {
         s = x86_decode_insn(ctxt, fetch);
 
+        if ( !s )
+        {
+            print_insn(instr, len);
+            printf(" failed to decode\n");
+            return;
+        }
+
         if ( x86_insn_length(s, ctxt) != len )
         {
             print_insn(instr, len);
@@ -2218,6 +2225,13 @@ void do_test(uint8_t *instr, unsigned int len, unsigned 
int modrm,
 
         s = x86_decode_insn(ctxt, fetch);
 
+        if ( !s )
+        {
+            print_insn(instr, len);
+            printf(" failed to decode\n");
+            return;
+        }
+
         if ( x86_insn_length(s, ctxt) != len )
         {
             print_insn(instr, len);
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.