diff options
-rw-r--r-- | src/firejail/main.c | 4 | ||||
-rw-r--r-- | src/firejail/profile.c | 4 | ||||
-rw-r--r-- | src/firejail/util.c | 5 | ||||
-rwxr-xr-x | test/environment/rlimit-bad-profile.exp | 2 | ||||
-rwxr-xr-x | test/environment/rlimit-bad.exp | 2 |
5 files changed, 8 insertions, 9 deletions
diff --git a/src/firejail/main.c b/src/firejail/main.c index 3311224fd..4afd1d6b6 100644 --- a/src/firejail/main.c +++ b/src/firejail/main.c | |||
@@ -1490,7 +1490,7 @@ int main(int argc, char **argv, char **envp) { | |||
1490 | else if (strncmp(argv[i], "--rlimit-fsize=", 15) == 0) { | 1490 | else if (strncmp(argv[i], "--rlimit-fsize=", 15) == 0) { |
1491 | cfg.rlimit_fsize = parse_arg_size(argv[i] + 15); | 1491 | cfg.rlimit_fsize = parse_arg_size(argv[i] + 15); |
1492 | if (cfg.rlimit_fsize == 0) { | 1492 | if (cfg.rlimit_fsize == 0) { |
1493 | perror("Error: invalid rlimit-fsize. only use positive numbers and k, m or g suffix."); | 1493 | perror("Error: invalid rlimit-fsize. Only use positive numbers and k, m or g suffix."); |
1494 | exit(1); | 1494 | exit(1); |
1495 | } | 1495 | } |
1496 | arg_rlimit_fsize = 1; | 1496 | arg_rlimit_fsize = 1; |
@@ -1503,7 +1503,7 @@ int main(int argc, char **argv, char **envp) { | |||
1503 | else if (strncmp(argv[i], "--rlimit-as=", 12) == 0) { | 1503 | else if (strncmp(argv[i], "--rlimit-as=", 12) == 0) { |
1504 | cfg.rlimit_as = parse_arg_size(argv[i] + 12); | 1504 | cfg.rlimit_as = parse_arg_size(argv[i] + 12); |
1505 | if (cfg.rlimit_as == 0) { | 1505 | if (cfg.rlimit_as == 0) { |
1506 | perror("Error: invalid rlimit-as. only use positive numbers and k, m or g suffix."); | 1506 | perror("Error: invalid rlimit-as. Only use positive numbers and k, m or g suffix."); |
1507 | exit(1); | 1507 | exit(1); |
1508 | } | 1508 | } |
1509 | arg_rlimit_as = 1; | 1509 | arg_rlimit_as = 1; |
diff --git a/src/firejail/profile.c b/src/firejail/profile.c index a0d62241e..ea8773a51 100644 --- a/src/firejail/profile.c +++ b/src/firejail/profile.c | |||
@@ -1494,7 +1494,7 @@ int profile_check_line(char *ptr, int lineno, const char *fname) { | |||
1494 | else if (strncmp(ptr, "rlimit-fsize ", 13) == 0) { | 1494 | else if (strncmp(ptr, "rlimit-fsize ", 13) == 0) { |
1495 | cfg.rlimit_fsize = parse_arg_size(ptr + 13); | 1495 | cfg.rlimit_fsize = parse_arg_size(ptr + 13); |
1496 | if (cfg.rlimit_fsize == 0) { | 1496 | if (cfg.rlimit_fsize == 0) { |
1497 | perror("Error: invalid rlimit-fsize in profile file. only use positive numbers and k, m or g suffix."); | 1497 | perror("Error: invalid rlimit-fsize in profile file. Only use positive numbers and k, m or g suffix."); |
1498 | exit(1); | 1498 | exit(1); |
1499 | } | 1499 | } |
1500 | arg_rlimit_fsize = 1; | 1500 | arg_rlimit_fsize = 1; |
@@ -1507,7 +1507,7 @@ int profile_check_line(char *ptr, int lineno, const char *fname) { | |||
1507 | else if (strncmp(ptr, "rlimit-as ", 10) == 0) { | 1507 | else if (strncmp(ptr, "rlimit-as ", 10) == 0) { |
1508 | cfg.rlimit_as = parse_arg_size(ptr + 10); | 1508 | cfg.rlimit_as = parse_arg_size(ptr + 10); |
1509 | if (cfg.rlimit_as == 0) { | 1509 | if (cfg.rlimit_as == 0) { |
1510 | perror("Error: invalid rlimit-as in profile file. only use positive numbers and k, m or g suffix."); | 1510 | perror("Error: invalid rlimit-as in profile file. Only use positive numbers and k, m or g suffix."); |
1511 | exit(1); | 1511 | exit(1); |
1512 | } | 1512 | } |
1513 | arg_rlimit_as = 1; | 1513 | arg_rlimit_as = 1; |
diff --git a/src/firejail/util.c b/src/firejail/util.c index cd1a048fe..e2a4a1d90 100644 --- a/src/firejail/util.c +++ b/src/firejail/util.c | |||
@@ -55,12 +55,12 @@ long long unsigned parse_arg_size(char *str) { | |||
55 | sscanf(str, "%llu", &result); | 55 | sscanf(str, "%llu", &result); |
56 | 56 | ||
57 | char suffix = *(str + len - 1); | 57 | char suffix = *(str + len - 1); |
58 | if (!isdigit(suffix) && ( suffix == 'k' || suffix == 'm' || suffix == 'g')) { | 58 | if (!isdigit(suffix) && (suffix == 'k' || suffix == 'm' || suffix == 'g')) { |
59 | len -= 1; | 59 | len -= 1; |
60 | } | 60 | } |
61 | 61 | ||
62 | /* checks for is value valid positive number */ | 62 | /* checks for is value valid positive number */ |
63 | for ( int i = 0; i < len; i++) { | 63 | for (int i = 0; i < len; i++) { |
64 | if (!isdigit(*(str+i))) { | 64 | if (!isdigit(*(str+i))) { |
65 | return 0; | 65 | return 0; |
66 | } | 66 | } |
@@ -69,7 +69,6 @@ long long unsigned parse_arg_size(char *str) { | |||
69 | if (isdigit(suffix)) | 69 | if (isdigit(suffix)) |
70 | return result; | 70 | return result; |
71 | 71 | ||
72 | |||
73 | switch (suffix) { | 72 | switch (suffix) { |
74 | case 'k': | 73 | case 'k': |
75 | result *= 1024; | 74 | result *= 1024; |
diff --git a/test/environment/rlimit-bad-profile.exp b/test/environment/rlimit-bad-profile.exp index 2c5793c9d..b1572afb6 100755 --- a/test/environment/rlimit-bad-profile.exp +++ b/test/environment/rlimit-bad-profile.exp | |||
@@ -11,7 +11,7 @@ match_max 100000 | |||
11 | send -- "firejail --profile=rlimit-bad1.profile\r" | 11 | send -- "firejail --profile=rlimit-bad1.profile\r" |
12 | expect { | 12 | expect { |
13 | timeout {puts "TESTING ERROR 4\n";exit} | 13 | timeout {puts "TESTING ERROR 4\n";exit} |
14 | "invalid rlimit-fsize in profile file. only use positive numbers and k, m or g suffix." | 14 | "invalid rlimit-fsize in profile file. Only use positive numbers and k, m or g suffix." |
15 | } | 15 | } |
16 | after 100 | 16 | after 100 |
17 | 17 | ||
diff --git a/test/environment/rlimit-bad.exp b/test/environment/rlimit-bad.exp index 6bdfd4193..c05e14b97 100755 --- a/test/environment/rlimit-bad.exp +++ b/test/environment/rlimit-bad.exp | |||
@@ -10,7 +10,7 @@ match_max 100000 | |||
10 | send -- "firejail --rlimit-fsize=-1024\r" | 10 | send -- "firejail --rlimit-fsize=-1024\r" |
11 | expect { | 11 | expect { |
12 | timeout {puts "TESTING ERROR 0\n";exit} | 12 | timeout {puts "TESTING ERROR 0\n";exit} |
13 | "invalid rlimit-fsize. only use positive numbers and k, m or g suffix." | 13 | "invalid rlimit-fsize. Only use positive numbers and k, m or g suffix." |
14 | } | 14 | } |
15 | after 100 | 15 | after 100 |
16 | 16 | ||