diff --git a/qrexec-lib/unicode.c b/qrexec-lib/unicode.c index 5f39668b..fc4c56c0 100644 --- a/qrexec-lib/unicode.c +++ b/qrexec-lib/unicode.c @@ -137,7 +137,7 @@ static ssize_t validate_path(const uint8_t *const untrusted_name, size_t allowed if (i == 0 || untrusted_name[i - 1] == '/') { switch (untrusted_name[i]) { case '/': // repeated or initial slash - case '\0': // trailing slash or empty string + case '\0': // empty string return -1; case '.': if (untrusted_name[i + 1] == '\0' || untrusted_name[i + 1] == '/') diff --git a/qrexec-lib/validator-test.c b/qrexec-lib/validator-test.c index 372fb2d9..e85319f9 100644 --- a/qrexec-lib/validator-test.c +++ b/qrexec-lib/validator-test.c @@ -219,4 +219,6 @@ int main(int argc, char **argv) assert(!qubes_pure_validate_symbolic_link((const uint8_t *)"a/b/c", (const uint8_t *)"/a")); // Symlinks may end in "..". assert(qubes_pure_validate_symbolic_link((const uint8_t *)"a/b/c", (const uint8_t *)"..")); + // Symlinks may end in "/". + assert(qubes_pure_validate_symbolic_link((const uint8_t *)"a/b/c", (const uint8_t *)"a/")); }