From 06b13a37f0f4b3545b899e3488762b3ed9c20812 Mon Sep 17 00:00:00 2001 From: Gabe Black Date: Fri, 9 Aug 2013 00:40:06 -0700 Subject: [PATCH] cbmem: Terminate the cbmem console at the cursor position. If the cbmem console buffer isn't zero filled before it's used, there won't be a terminator at the end. We need to put one at the cursor position manually. Change-Id: I69870c2b24b67ce3cbcd402b62f3574acb4c2a8f Signed-off-by: Gabe Black Reviewed-on: https://gerrit.chromium.org/gerrit/65300 Reviewed-by: Hung-Te Lin Commit-Queue: Gabe Black Tested-by: Gabe Black (cherry picked from commit 8ec61e52a6a27ed518d0abb5a19d6261edf9dab1) Signed-off-by: Isaac Christensen Reviewed-on: http://review.coreboot.org/6404 Tested-by: build bot (Jenkins) Reviewed-by: Paul Menzel Reviewed-by: Edward O'Callaghan --- util/cbmem/cbmem.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/util/cbmem/cbmem.c b/util/cbmem/cbmem.c index fabede32c4..4dcfe91ad1 100644 --- a/util/cbmem/cbmem.c +++ b/util/cbmem/cbmem.c @@ -472,8 +472,8 @@ static void dump_console(void) * char console[size] * Hence we have to add 8 to get to the actual console string. */ - size = *(uint32_t *)console_p; - cursor = *(uint32_t *) (console_p + 4); + size = ((uint32_t *)console_p)[0]; + cursor = ((uint32_t *)console_p)[1]; /* Cursor continues to go on even after no more data fits in * the buffer but the data is dropped in this case. */ @@ -489,6 +489,7 @@ static void dump_console(void) size + sizeof(size) + sizeof(cursor)); memcpy(console_c, console_p + 8, size); console_c[size] = 0; + console_c[cursor] = 0; printf("%s\n", console_c); if (size < cursor)