diff options
-rw-r--r-- | src/bindfs.c | 2 | ||||
-rwxr-xr-x | tests/test_bindfs.rb | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/src/bindfs.c b/src/bindfs.c index 6668ab8..0d14447 100644 --- a/src/bindfs.c +++ b/src/bindfs.c @@ -1889,7 +1889,7 @@ static int parse_map_file(UserMap *map, UserMap *reverse_map, char *file, int as while ((read = getline(&line, &len, fp)) != -1) { // Remove newline in case someone builds a file with lines like 'a:b:123' by hand. // If we left the newline, strtok would return "123\n" as the last token. - if (read > 0) { + if (read > 0 && line[read - 1] == '\n') { line[read - 1] = '\0'; } diff --git a/tests/test_bindfs.rb b/tests/test_bindfs.rb index 8e4ee13..a616017 100755 --- a/tests/test_bindfs.rb +++ b/tests/test_bindfs.rb @@ -400,7 +400,7 @@ Tempfile.create('passwdfile') do |passwd_file| Tempfile.create('groupfile') do |group_file| passwd_file.puts("nobody:x:123:456:,,,:/tmp:/bin/false") passwd_file.flush - group_file.puts("#{nobody_group}:x:789") + group_file.write("#{nobody_group}:x:789") group_file.flush root_testenv("--map-passwd=#{Shellwords.escape(passwd_file.path)} --map-group=#{Shellwords.escape(group_file.path)}") do touch('src/file1') |