From 52b6e57743f993ac39dbcbe5ea3414e9db8f0154 Mon Sep 17 00:00:00 2001 From: Ingo Franzki Date: Wed, 26 May 2021 13:28:39 +0200 Subject: [PATCH] zkey: Allow comments and empty lines in properties files MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Lines with '#' as first character are treated as comments, and are skipped. Empty lines are also skipped. Signed-off-by: Ingo Franzki Signed-off-by: Jan Höppner --- zkey/properties.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/zkey/properties.c b/zkey/properties.c index 147bcc5c..42183ee9 100644 --- a/zkey/properties.c +++ b/zkey/properties.c @@ -386,8 +386,12 @@ int properties_load(struct properties *properties, const char *filename, while (fgets(line, sizeof(line), fp) != NULL) { len = strlen(line); - if (line[len-1] == '\n') - line[len-1] = '\0'; + if (line[len - 1] == '\n') + line[len - 1] = '\0'; + if (line[0] == '#') + continue; + if (strlen(line) == 0) + continue; ch = strchr(line, '='); if (ch == NULL) { rc = -EPERM;