]> xenbits.xensource.com Git - people/andrewcoop/xen.git/commitdiff
fix out of bound access to mode_strings
authorStefano Stabellini <sstabellini@kernel.org>
Fri, 9 Dec 2016 01:17:04 +0000 (17:17 -0800)
committerStefano Stabellini <sstabellini@kernel.org>
Fri, 9 Dec 2016 19:37:33 +0000 (11:37 -0800)
mode == ARRAY_SIZE(mode_strings) causes an out of bound access to
the mode_strings array.

Coverity-ID: 1381859

Signed-off-by: Stefano Stabellini <sstabellini@kernel.org>
Reviewed-by: Julien Grall <julien.grall@arm.com>
xen/arch/arm/traps.c

index eb85d92c6d6fa1e9981531b15bcd8025428f4258..35d8e8b09a528afdd8fecc572a0b19d4f6ea36aa 100644 (file)
@@ -643,7 +643,7 @@ static const char *mode_string(uint32_t cpsr)
     };
     mode = cpsr & PSR_MODE_MASK;
 
-    if ( mode > ARRAY_SIZE(mode_strings) )
+    if ( mode >= ARRAY_SIZE(mode_strings) )
         return "Unknown";
     return mode_strings[mode] ? : "Unknown";
 }