Skip to content

Commit

Permalink
mkcomposefs: Reject dumpfiles without trailing newline
Browse files Browse the repository at this point in the history
I was doing some more testing and ended up crafting a dumpfile
without a trailing newline. It took me a surprising amount
of time to figure out that we just ignore data without a
trailing newline.

Change things to hard error here for now. If this breaks
someone, we can probably downgrade this to a warning.

Closes: containers#327
Signed-off-by: Colin Walters <[email protected]>
  • Loading branch information
cgwalters committed Sep 5, 2024
1 parent 47042e8 commit 90c1f83
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 0 deletions.
3 changes: 3 additions & 0 deletions tests/assets/should-fail-nonl.dump
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/ 4096 40555 222 0 0 10 0.0 - - - trusted.foo1=bar-1 user.foo2=bar-2
/a 0 100644 1 0 0 0 0.0 - - -
/b 0 100644 1 0 0 0 0.0 - - -
1 change: 1 addition & 0 deletions tests/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ test_assets_small_extra = [
]

test_assets_should_fail = [
'should-fail-nonl.dump',
'should-fail-long-link.dump',
'should-fail-long-xattr-key.dump',
'should-fail-long-xattr-value.dump',
Expand Down
4 changes: 4 additions & 0 deletions tools/mkcomposefs.c
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,10 @@ static struct lcfs_node_s *tree_from_dump(FILE *input, char **out_err)
}
}
}
if (buf.size > 0) {
*out_err = make_error("Missing trailing newline");
return NULL;
}

buffer_free(&buf);

Expand Down

0 comments on commit 90c1f83

Please sign in to comment.