diff options
author | 2021-06-11 17:31:08 +0300 | |
---|---|---|
committer | 2021-06-11 17:31:08 +0300 | |
commit | ef1956e87a550bf9a699de850accbe608e142ea9 (patch) | |
tree | 895d12401ffe86717a9b5c52def2c3a03b560d43 | |
parent | update src/firejail/firejail.h (diff) | |
download | firejail-ef1956e87a550bf9a699de850accbe608e142ea9.tar.gz firejail-ef1956e87a550bf9a699de850accbe608e142ea9.tar.zst firejail-ef1956e87a550bf9a699de850accbe608e142ea9.zip |
update src/firejail/util.c
Co-authored-by: Kelvin M. Klann <kmk3.code@protonmail.com>
-rw-r--r-- | src/firejail/util.c | 30 |
1 files changed, 18 insertions, 12 deletions
diff --git a/src/firejail/util.c b/src/firejail/util.c index 05c5f26d8..7ee83a13e 100644 --- a/src/firejail/util.c +++ b/src/firejail/util.c | |||
@@ -49,22 +49,28 @@ | |||
49 | #define EMPTY_STRING ("") | 49 | #define EMPTY_STRING ("") |
50 | 50 | ||
51 | 51 | ||
52 | long long unsigned parse_arg_size (char * str) { | 52 | long long unsigned parse_arg_size(char *str) { |
53 | long long unsigned result = 0; | 53 | long long unsigned result = 0; |
54 | int len = strlen(str); | 54 | int len = strlen(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)) { | 58 | if (isdigit(suffix)) |
59 | if ( suffix == 'k' ) { | 59 | return result; |
60 | result *= 1024; | 60 | |
61 | } else if ( suffix == 'm' ) { | 61 | switch (result) { |
62 | result *= 1024*1024; | 62 | case 'k': |
63 | } else if ( suffix == 'g' ) { | 63 | result *= 1024; |
64 | result *= 1024*1024*1024; | 64 | break; |
65 | } else { | 65 | case 'm': |
66 | return 0; | 66 | result *= 1024 * 1024; |
67 | } | 67 | break; |
68 | case 'g': | ||
69 | result *= 1024 * 1024 * 1024; | ||
70 | break; | ||
71 | default: | ||
72 | result = 0; | ||
73 | break; | ||
68 | } | 74 | } |
69 | 75 | ||
70 | return result; | 76 | return result; |