[CRIU] [PATCH 1/3] config: skip spaces at a beginning of lines

Andrei Vagin avagin at virtuozzo.com
Wed May 9 09:28:27 MSK 2018


Otherwise lines started with spaces are ignored.

Cc: Veronika Kabatova <vkabatov at redhat.com>
Signed-off-by: Andrei Vagin <avagin at virtuozzo.com>
---
 criu/config.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/criu/config.c b/criu/config.c
index 10630c661..b1c0d58f5 100644
--- a/criu/config.c
+++ b/criu/config.c
@@ -95,7 +95,12 @@ static char ** parse_config(char *filepath)
 			}
 			configuration = tmp_conf;
 		}
-		while (sscanf(line + offset, "%m[^ \t\n]s", &configuration[i]) == 1) {
+		while (1) {
+			while ((isspace(*(line + offset)) && (*(line + offset) != '\n'))) offset++;
+
+			if (sscanf(line + offset, "%m[^ \t\n]s", &configuration[i]) != 1)
+				break;
+
 			if (configuration[i][0] == '#') {
 				if (sscanf(line, "%*[^\n]") != 0) {
 					pr_err("Error while reading configuration file %s\n", filepath);
@@ -151,7 +156,6 @@ static char ** parse_config(char *filepath)
 				configuration[i] = tmp_string;
 			}
 			i++;
-			while ((isspace(*(line + offset)) && (*(line + offset) != '\n'))) offset++;
 		}
 		line = NULL;
 	}
-- 
2.14.3



More information about the CRIU mailing list