[PATCH] uefi: uefidump: don't dump non-printable variable contents (LP: #1435346)

Colin King colin.king at canonical.com
Fri Mar 27 03:06:14 UTC 2015


From: Colin Ian King <colin.king at canonical.com>

Do a hex dump of kernel dump UEFI vars if the contents is
not printable ASCII.

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/uefi/uefidump/uefidump.c | 32 ++++++++++++++++++++++++--------
 1 file changed, 24 insertions(+), 8 deletions(-)

diff --git a/src/uefi/uefidump/uefidump.c b/src/uefi/uefidump/uefidump.c
index 8421e72..014abe2 100644
--- a/src/uefi/uefidump/uefidump.c
+++ b/src/uefi/uefidump/uefidump.c
@@ -768,19 +768,35 @@ static void uefidump_info_dump_type0(fwts_framework *fw, fwts_uefi_var *var)
 {
 	char *ptr = (char*)var->data;
 	size_t len = var->datalen;
+	bool printable = true;
 
 	while (len && *ptr) {
-		char *start = ptr;
-		while (len && *ptr && *ptr != '\n') {
-			ptr++;
-			len--;
+		if (!(isspace(*ptr) || isprint(*ptr))) {
+			printable = false;
+			break;
 		}
+		ptr++;
+		len--;
+	}
 
-		if (*ptr == '\n') {
-			*ptr++ = '\0';
-			len--;
-			fwts_log_info_verbatum(fw, "  KLog: %s.", start);
+	ptr = (char*)var->data;
+	len = var->datalen;
+
+	if (printable) {
+		while (len && *ptr) {
+			char *start = ptr;
+			while (len && *ptr && *ptr != '\n') {
+				ptr++;
+				len--;
+			}
+			if (*ptr == '\n') {
+				*ptr++ = '\0';
+				len--;
+				fwts_log_info_verbatum(fw, "  KLog: %s.", start);
+			}
 		}
+	} else {
+		uefidump_var_hexdump(fw, var);
 	}
 }
 
-- 
2.1.4




More information about the fwts-devel mailing list