From 98f59e59e0c31ffcb953d3a7dba0da5e6f2f55f7 Mon Sep 17 00:00:00 2001 From: Harald Hoyer Date: Thu, 18 Apr 2013 10:15:25 +0200 Subject: fileio.c: do not parse comments after non-whitespace chars systemd does not want to understand comments after the first non-whitespace char occured. key=foo #comment will result into key == "foo #comment" key="foo" #comment will result into key == "foo#comment" "key= #comment" will result into key == "#comment" "key #comment" is an invalid line --- src/shared/fileio.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src/shared/fileio.c') diff --git a/src/shared/fileio.c b/src/shared/fileio.c index 2a272593a8..337b9e4147 100644 --- a/src/shared/fileio.c +++ b/src/shared/fileio.c @@ -239,7 +239,7 @@ static int parse_env_file_internal( break; case PRE_VALUE: - if (strchr(newline, c) || strchr(COMMENTS, c)) { + if (strchr(newline, c)) { state = PRE_KEY; key[n_key] = 0; @@ -247,7 +247,7 @@ static int parse_env_file_internal( value[n_value] = 0; /* strip trailing whitespace from key */ - while(strchr(WHITESPACE, key[--n_key])) + while(n_key && strchr(WHITESPACE, key[--n_key])) key[n_key]=0; r = push(key, value, userdata); @@ -279,6 +279,7 @@ static int parse_env_file_internal( case VALUE: if (strchr(newline, c)) { state = PRE_KEY; + key[n_key] = 0; if (value) @@ -289,7 +290,7 @@ static int parse_env_file_internal( value[last_whitespace] = 0; /* strip trailing whitespace from key */ - while(strchr(WHITESPACE, key[--n_key])) + while(n_key && strchr(WHITESPACE, key[--n_key])) key[n_key]=0; r = push(key, value, userdata); @@ -417,7 +418,7 @@ static int parse_env_file_internal( value[n_value] = 0; /* strip trailing whitespace from key */ - while(strchr(WHITESPACE, key[--n_key])) + while(n_key && strchr(WHITESPACE, key[--n_key])) key[n_key]=0; r = push(key, value, userdata); -- cgit v1.2.3-54-g00ecf