diff options
Diffstat (limited to 'src/firejail/util.c')
-rw-r--r-- | src/firejail/util.c | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/firejail/util.c b/src/firejail/util.c index b35225620..8c3a13fb8 100644 --- a/src/firejail/util.c +++ b/src/firejail/util.c | |||
@@ -1448,6 +1448,29 @@ static int has_link(const char *dir) { | |||
1448 | return 0; | 1448 | return 0; |
1449 | } | 1449 | } |
1450 | 1450 | ||
1451 | // allow strict ASCII letters and numbers; names with only numbers are rejected; spaces are rejected | ||
1452 | int invalid_name(const char *name) { | ||
1453 | const char *c = name; | ||
1454 | |||
1455 | int only_numbers = 1; | ||
1456 | while (*c) { | ||
1457 | if (!isalnum(*c)) | ||
1458 | return 1; | ||
1459 | if (!isdigit(*c)) | ||
1460 | only_numbers = 0; | ||
1461 | ++c; | ||
1462 | } | ||
1463 | if (only_numbers) | ||
1464 | return 1; | ||
1465 | |||
1466 | // restrict name to 64 chars max | ||
1467 | if (strlen(name) > 64) | ||
1468 | return 1; | ||
1469 | |||
1470 | return 0; | ||
1471 | } | ||
1472 | |||
1473 | |||
1451 | void check_homedir(const char *dir) { | 1474 | void check_homedir(const char *dir) { |
1452 | assert(dir); | 1475 | assert(dir); |
1453 | if (dir[0] != '/') { | 1476 | if (dir[0] != '/') { |