aboutsummaryrefslogtreecommitdiffstats
path: root/src/fcopy
diff options
context:
space:
mode:
authorLibravatar smitsohu <smitsohu@gmail.com>2019-09-05 16:15:16 +0200
committerLibravatar smitsohu <smitsohu@gmail.com>2019-09-05 16:15:16 +0200
commit27c136dcf4e84daee0c8886c869720ec9be7a594 (patch)
treedc3aa83592e8ee1b009731fefba7497d18dd3092 /src/fcopy
parentRevert changes in #2928 to seccomp group @default (diff)
downloadfirejail-27c136dcf4e84daee0c8886c869720ec9be7a594.tar.gz
firejail-27c136dcf4e84daee0c8886c869720ec9be7a594.tar.zst
firejail-27c136dcf4e84daee0c8886c869720ec9be7a594.zip
fix FIREJAIL_FILE_COPY_LIMIT larger than 2GB
Diffstat (limited to 'src/fcopy')
-rw-r--r--src/fcopy/main.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/fcopy/main.c b/src/fcopy/main.c
index 3f507a361..a08cc66b3 100644
--- a/src/fcopy/main.c
+++ b/src/fcopy/main.c
@@ -28,11 +28,10 @@ int arg_quiet = 0;
28int arg_debug = 0; 28int arg_debug = 0;
29static int arg_follow_link = 0; 29static int arg_follow_link = 0;
30 30
31static int copy_limit = 500 * 1024 *1024; // 500 MB 31static unsigned long long copy_limit = 500 * 1024 * 1024; // 500 MB
32#define COPY_LIMIT ( 32static unsigned long long size_cnt = 0;
33static int size_limit_reached = 0; 33static int size_limit_reached = 0;
34static unsigned file_cnt = 0; 34static unsigned file_cnt = 0;
35static unsigned size_cnt = 0;
36 35
37static char *outpath = NULL; 36static char *outpath = NULL;
38static char *inpath = NULL; 37static char *inpath = NULL;
@@ -187,7 +186,7 @@ static int fs_copydir(const char *infname, const struct stat *st, int ftype, str
187 186
188 // recalculate size 187 // recalculate size
189 if ((s.st_size + size_cnt) > copy_limit) { 188 if ((s.st_size + size_cnt) > copy_limit) {
190 fprintf(stderr, "Error fcopy: size limit of %dMB reached\n", (copy_limit / 1024) / 1024); 189 fprintf(stderr, "Error fcopy: size limit of %lluMB reached\n", (copy_limit / 1024) / 1024);
191 size_limit_reached = 1; 190 size_limit_reached = 1;
192 free(outfname); 191 free(outfname);
193 return 0; 192 return 0;
@@ -392,9 +391,9 @@ int main(int argc, char **argv) {
392 // extract copy limit size from env variable, if any 391 // extract copy limit size from env variable, if any
393 char *cl = getenv("FIREJAIL_FILE_COPY_LIMIT"); 392 char *cl = getenv("FIREJAIL_FILE_COPY_LIMIT");
394 if (cl) { 393 if (cl) {
395 copy_limit = atoi(cl) * 1024 * 1024; 394 copy_limit = strtoul(cl, NULL, 10) * 1024 * 1024;
396 if (arg_debug) 395 if (arg_debug)
397 printf("file copy limit %d bytes\n", copy_limit); 396 printf("file copy limit %llu bytes\n", copy_limit);
398 } 397 }
399 398
400 // copy files 399 // copy files