From 993a9b373eb5be860894be1b770faa7b80148789 Mon Sep 17 00:00:00 2001 From: "Kelvin M. Klann" Date: Sun, 7 Sep 2025 12:01:15 +0000 Subject: [PATCH] modif: rlimit: use uppercase suffixes in the code/docs (#6891) The proper suffixes (KiB, MiB and GiB) are uppercase. This is a follow-up to #6890. Relates to #4315. --- src/firejail/main.c | 4 ++-- src/firejail/profile.c | 4 ++-- src/firejail/util.c | 8 ++++---- src/man/firejail.1.in | 4 ++-- test/environment/rlimit-bad-profile.exp | 2 +- test/environment/rlimit-bad.exp | 2 +- 6 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/firejail/main.c b/src/firejail/main.c index e82fa8b1f..8fd9e4438 100644 --- a/src/firejail/main.c +++ b/src/firejail/main.c @@ -1629,7 +1629,7 @@ int main(int argc, char **argv, char **envp) { else if (strncmp(argv[i], "--rlimit-fsize=", 15) == 0) { cfg.rlimit_fsize = parse_arg_size(argv[i] + 15); if (cfg.rlimit_fsize == 0) { - perror("Error: invalid rlimit-fsize. Only use positive numbers and k, m or g suffix."); + perror("Error: invalid rlimit-fsize. Only use positive numbers and K, M or G suffix."); exit(1); } arg_rlimit_fsize = 1; @@ -1642,7 +1642,7 @@ int main(int argc, char **argv, char **envp) { else if (strncmp(argv[i], "--rlimit-as=", 12) == 0) { cfg.rlimit_as = parse_arg_size(argv[i] + 12); if (cfg.rlimit_as == 0) { - perror("Error: invalid rlimit-as. Only use positive numbers and k, m or g suffix."); + perror("Error: invalid rlimit-as. Only use positive numbers and K, M or G suffix."); exit(1); } arg_rlimit_as = 1; diff --git a/src/firejail/profile.c b/src/firejail/profile.c index e9a060617..6d73020f2 100644 --- a/src/firejail/profile.c +++ b/src/firejail/profile.c @@ -1643,7 +1643,7 @@ int profile_check_line(char *ptr, int lineno, const char *fname) { else if (strncmp(ptr, "rlimit-fsize ", 13) == 0) { cfg.rlimit_fsize = parse_arg_size(ptr + 13); if (cfg.rlimit_fsize == 0) { - perror("Error: invalid rlimit-fsize in profile file. Only use positive numbers and k, m or g suffix."); + perror("Error: invalid rlimit-fsize in profile file. Only use positive numbers and K, M or G suffix."); exit(1); } arg_rlimit_fsize = 1; @@ -1656,7 +1656,7 @@ int profile_check_line(char *ptr, int lineno, const char *fname) { else if (strncmp(ptr, "rlimit-as ", 10) == 0) { cfg.rlimit_as = parse_arg_size(ptr + 10); if (cfg.rlimit_as == 0) { - perror("Error: invalid rlimit-as in profile file. Only use positive numbers and k, m or g suffix."); + perror("Error: invalid rlimit-as in profile file. Only use positive numbers and K, M or G suffix."); exit(1); } arg_rlimit_as = 1; diff --git a/src/firejail/util.c b/src/firejail/util.c index 6e5c160e0..9c5352886 100644 --- a/src/firejail/util.c +++ b/src/firejail/util.c @@ -52,7 +52,7 @@ long long unsigned parse_arg_size(char *str) { char suffix = *(str + len - 1); suffix = tolower((unsigned char)suffix); - if (!isdigit(suffix) && (suffix == 'k' || suffix == 'm' || suffix == 'g')) { + if (!isdigit(suffix) && (suffix == 'K' || suffix == 'M' || suffix == 'G')) { len -= 1; } @@ -68,13 +68,13 @@ long long unsigned parse_arg_size(char *str) { return result; switch (suffix) { - case 'k': + case 'K': result *= 1024; break; - case 'm': + case 'M': result *= 1024 * 1024; break; - case 'g': + case 'G': result *= 1024 * 1024 * 1024; break; default: diff --git a/src/man/firejail.1.in b/src/man/firejail.1.in index 04f8aeb00..ae18278fb 100644 --- a/src/man/firejail.1.in +++ b/src/man/firejail.1.in @@ -2577,7 +2577,7 @@ $ firejail \-\-restrict-namespaces=user,net .TP \fB\-\-rlimit-as=number Set the maximum size of the process's virtual memory (address space) in bytes. -Use k(ilobyte), m(egabyte) or g(igabyte) for size suffix (base 1024). +Use K(ilobyte), M(egabyte) or G(igabyte) for size suffix (base 1024). .TP \fB\-\-rlimit-cpu=number @@ -2591,7 +2591,7 @@ track of CPU seconds for each process independently. .TP \fB\-\-rlimit-fsize=number Set the maximum file size that can be created by a process. -Use k(ilobyte), m(egabyte) or g(igabyte) for size suffix (base 1024). +Use K(ilobyte), M(egabyte) or G(igabyte) for size suffix (base 1024). .TP \fB\-\-rlimit-nofile=number Set the maximum number of files that can be opened by a process. diff --git a/test/environment/rlimit-bad-profile.exp b/test/environment/rlimit-bad-profile.exp index b32066f8d..336c73dd4 100755 --- a/test/environment/rlimit-bad-profile.exp +++ b/test/environment/rlimit-bad-profile.exp @@ -11,7 +11,7 @@ match_max 100000 send -- "firejail --profile=rlimit-bad1.profile\r" expect { timeout {puts "TESTING ERROR 4\n";exit} - "invalid rlimit-fsize in profile file. Only use positive numbers and k, m or g suffix." + "invalid rlimit-fsize in profile file. Only use positive numbers and K, M or G suffix." } after 100 diff --git a/test/environment/rlimit-bad.exp b/test/environment/rlimit-bad.exp index 8f26ed25d..b960b6602 100755 --- a/test/environment/rlimit-bad.exp +++ b/test/environment/rlimit-bad.exp @@ -10,7 +10,7 @@ match_max 100000 send -- "firejail --rlimit-fsize=-1024\r" expect { timeout {puts "TESTING ERROR 0\n";exit} - "invalid rlimit-fsize. Only use positive numbers and k, m or g suffix." + "invalid rlimit-fsize. Only use positive numbers and K, M or G suffix." } after 100