Julius Werner has submitted this change and it was merged. ( https://review.coreboot.org/c/coreboot/+/34211 )
Change subject: console: Correct printing of hexadecimal integers ......................................................................
console: Correct printing of hexadecimal integers
Commit b19946cc62 (console: Remove support for printing extra bases) truncated the digits string to only print integers of up to base 16. However, that string was also used to print the leading 'x' or 'X' for hexadecimal integers and is now too short. Fix this to prevent an out of bounds read.
Change-Id: Iab6470cc88f445f074cf7c0b675346b37f3f2375 Signed-off-by: Jacob Garber jgarber1@ualberta.ca Found-by: Coverity CID 1402999 Reviewed-on: https://review.coreboot.org/c/coreboot/+/34211 Tested-by: build bot (Jenkins) no-reply@coreboot.org Reviewed-by: Patrick Georgi pgeorgi@google.com Reviewed-by: HAOUAS Elyes ehaouas@noos.fr Reviewed-by: Nico Huber nico.h@gmx.de Reviewed-by: Julius Werner jwerner@chromium.org --- M src/console/vtxprintf.c 1 file changed, 4 insertions(+), 1 deletion(-)
Approvals: build bot (Jenkins): Verified Patrick Georgi: Looks good to me, approved Nico Huber: Looks good to me, approved HAOUAS Elyes: Looks good to me, but someone else must approve Julius Werner: Looks good to me, approved
diff --git a/src/console/vtxprintf.c b/src/console/vtxprintf.c index b50f398..848ad50 100644 --- a/src/console/vtxprintf.c +++ b/src/console/vtxprintf.c @@ -107,7 +107,10 @@ call_tx('0'), count++; else if (base == 16) { call_tx('0'), count++; - call_tx(digits[33]), count++; + if (type & LARGE) + call_tx('X'), count++; + else + call_tx('x'), count++; } } if (!(type & LEFT)) {