From 73d5e17026363240d263b24ab303d29ee8732d42 Mon Sep 17 00:00:00 2001 From: Harald Freudenberger Date: Tue, 29 Aug 2017 11:21:56 +0200 Subject: [PATCH] lszcrypt: fix random domain printout when no config available The sysfs files ap_control_domain_mask and ap_usage_domain_mask may hold just a string "not supported" if there's no crypto configuration available. However, lszcrypt always processed the content of these files as hex number and so produced funny output if there's no configuration data available. Signed-off-by: Harald Freudenberger Signed-off-by: Michael Holzheu --- zconf/zcrypt/lszcrypt.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/zconf/zcrypt/lszcrypt.c b/zconf/zcrypt/lszcrypt.c index 42d7502d..30b53c57 100644 --- a/zconf/zcrypt/lszcrypt.c +++ b/zconf/zcrypt/lszcrypt.c @@ -168,7 +168,7 @@ static void show_domains_util_rec(char *domain_array[]) */ static void show_domains(void) { - char ctrl_domain_mask[67], usag_domain_mask[67], byte_str[3] = {}; + char ctrl_domain_mask[80], usag_domain_mask[80], byte_str[3] = {}; int ctrl_chunk, usag_chunk; char *ap, *domain_array[32 * 8 + 4]; int i, x, n; @@ -181,8 +181,12 @@ static void show_domains(void) util_file_read_line(ctrl_domain_mask, sizeof(ctrl_domain_mask), "%s/ap_control_domain_mask", ap); + if (strstr(ctrl_domain_mask, "not")) + errx(EXIT_FAILURE, "Control domain mask not available."); util_file_read_line(usag_domain_mask, sizeof(usag_domain_mask), "%s/ap_usage_domain_mask", ap); + if (strstr(usag_domain_mask, "not")) + errx(EXIT_FAILURE, "Usage domain mask not available."); /* remove leading '0x' from domain mask string */ memmove(&ctrl_domain_mask[0], &ctrl_domain_mask[2], sizeof(ctrl_domain_mask) - 2);