Skip to content

Commit 97688b7

Browse files
committed
qubes-fs-tree-check: Fix wrong error message for empty path
This should have a different error message, but due to an off-by-one it was never generated. Fixes QubesOS/qubes-issues#10309
1 parent e960f05 commit 97688b7

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

qubes-rpc/qubes-fs-tree-check.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -272,13 +272,14 @@ int main(int argc, char **argv)
272272
bool bad = false;
273273
unsigned long long size = 0;
274274
for (int i = optind; i < argc; ++i) {
275-
size_t len = strlen(argv[i]) + 1;
276-
if (len < 4 && memcmp("..", argv[i], len - 1) == 0) {
275+
size_t len = strlen(argv[i]);
276+
if (len < 3 && memcmp("..", argv[i], len) == 0) {
277277
if (len == 0)
278278
errx(1, "Empty string (passed as argument %d) is not a valid path", i);
279279
else
280280
errx(1, "Argument %d is \"%s\", which is not allowed. Try operating from the parent directory.", i, argv[i]);
281281
}
282+
len++;
282283
char *escaped = simple_strvis(argv[i]);
283284
char *dup1 = malloc(len), *dup2 = malloc(len);
284285
if (dup1 == NULL || dup2 == NULL)

0 commit comments

Comments
 (0)