summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacob Garber <jgarber1@ualberta.ca>2019-07-10 11:44:45 -0600
committerJulius Werner <jwerner@chromium.org>2019-07-10 20:22:40 +0000
commit5b9948140f97eceb47ba026d7bad6dfa2a3c483d (patch)
tree13ee9ccecc5927c96c36c151e9216e7ce690eb86 /src
parent15947182fde54bbc3c4faba780a515d8b63bce7f (diff)
downloadcoreboot-5b9948140f97eceb47ba026d7bad6dfa2a3c483d.tar.xz
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>
Diffstat (limited to 'src')
-rw-r--r--src/console/vtxprintf.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/src/console/vtxprintf.c b/src/console/vtxprintf.c
index b50f3987a5..848ad501ce 100644
--- a/src/console/vtxprintf.c
+++ b/src/console/vtxprintf.c
@@ -107,7 +107,10 @@ static int number(void (*tx_byte)(unsigned char byte, void *data),
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)) {