Skip to content

Commit

Permalink
Avoid casting away "const" in tests
Browse files Browse the repository at this point in the history
No functional change intended.
  • Loading branch information
DemiMarie committed May 9, 2024
1 parent 0a67060 commit 6c6923e
Showing 1 changed file with 20 additions and 20 deletions.
40 changes: 20 additions & 20 deletions qrexec-lib/validator-test.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,34 +72,34 @@ int main(int argc, char **argv)
{
(void)argc;
(void)argv;
assert(qubes_pure_validate_file_name((uint8_t *)u8"simple_safe_filename.txt"));
assert(qubes_pure_validate_file_name((const uint8_t *)u8"simple_safe_filename.txt"));

// Directory traversal checks
assert(!qubes_pure_validate_file_name((uint8_t *)".."));
assert(!qubes_pure_validate_file_name((uint8_t *)"../.."));
assert(!qubes_pure_validate_file_name((uint8_t *)"a/.."));
assert(!qubes_pure_validate_file_name((uint8_t *)"a/../b"));
assert(!qubes_pure_validate_file_name((uint8_t *)"/"));
assert(!qubes_pure_validate_file_name((uint8_t *)"//"));
assert(!qubes_pure_validate_file_name((uint8_t *)"///"));
assert(!qubes_pure_validate_file_name((uint8_t *)"/a"));
assert(!qubes_pure_validate_file_name((uint8_t *)"//a"));
assert(!qubes_pure_validate_file_name((uint8_t *)"///a"));
assert(!qubes_pure_validate_file_name((const uint8_t *)".."));
assert(!qubes_pure_validate_file_name((const uint8_t *)"../.."));
assert(!qubes_pure_validate_file_name((const uint8_t *)"a/.."));
assert(!qubes_pure_validate_file_name((const uint8_t *)"a/../b"));
assert(!qubes_pure_validate_file_name((const uint8_t *)"/"));
assert(!qubes_pure_validate_file_name((const uint8_t *)"//"));
assert(!qubes_pure_validate_file_name((const uint8_t *)"///"));
assert(!qubes_pure_validate_file_name((const uint8_t *)"/a"));
assert(!qubes_pure_validate_file_name((const uint8_t *)"//a"));
assert(!qubes_pure_validate_file_name((const uint8_t *)"///a"));

// No repeated slashes
assert(!qubes_pure_validate_file_name((uint8_t *)"a//b"));
assert(!qubes_pure_validate_file_name((const uint8_t *)"a//b"));

// No "." as a path component
assert(!qubes_pure_validate_file_name((uint8_t *)"."));
assert(!qubes_pure_validate_file_name((uint8_t *)"a/."));
assert(!qubes_pure_validate_file_name((uint8_t *)"./a"));
assert(!qubes_pure_validate_file_name((uint8_t *)"a/./a"));
assert(!qubes_pure_validate_file_name((const uint8_t *)"."));
assert(!qubes_pure_validate_file_name((const uint8_t *)"a/."));
assert(!qubes_pure_validate_file_name((const uint8_t *)"./a"));
assert(!qubes_pure_validate_file_name((const uint8_t *)"a/./a"));

// No ".." as a path component
assert(!qubes_pure_validate_file_name((uint8_t *)".."));
assert(!qubes_pure_validate_file_name((uint8_t *)"a/.."));
assert(!qubes_pure_validate_file_name((uint8_t *)"../a"));
assert(!qubes_pure_validate_file_name((uint8_t *)"a/../a"));
assert(!qubes_pure_validate_file_name((const uint8_t *)".."));
assert(!qubes_pure_validate_file_name((const uint8_t *)"a/.."));
assert(!qubes_pure_validate_file_name((const uint8_t *)"../a"));
assert(!qubes_pure_validate_file_name((const uint8_t *)"a/../a"));

// Looks like "." or ".." but is not
assert(qubes_pure_validate_file_name((const uint8_t *)".a"));
Expand Down

0 comments on commit 6c6923e

Please sign in to comment.