aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/firejail/util.c21
-rw-r--r--status3
2 files changed, 14 insertions, 10 deletions
diff --git a/src/firejail/util.c b/src/firejail/util.c
index c1a680dd4..485ddb3af 100644
--- a/src/firejail/util.c
+++ b/src/firejail/util.c
@@ -538,31 +538,34 @@ char *split_comma(char *str) {
538char *clean_pathname(const char *path) { 538char *clean_pathname(const char *path) {
539 assert(path); 539 assert(path);
540 size_t len = strlen(path); 540 size_t len = strlen(path);
541 char *rv = calloc(len + 1, 1); 541 assert(len + 1 != 0 && path[len] == '\0');
542
543 char *rv = malloc(len + 1);
542 if (!rv) 544 if (!rv)
543 errExit("calloc"); 545 errExit("malloc");
546
544 if (len > 0) { 547 if (len > 0) {
545 int i, j, cnt; 548 size_t i, j, cnt;
546 for (i = 0, j = 0, cnt = 0; i < len; i++) { 549 for (i = 0, j = 0, cnt = 0; i < len; i++) {
547 if (path[i] == '/') 550 if (path[i] == '/')
548 cnt++; 551 cnt++;
549 else 552 else
550 cnt = 0; 553 cnt = 0;
554
551 if (cnt < 2) { 555 if (cnt < 2) {
552 rv[j] = path[i]; 556 rv[j] = path[i];
553 j++; 557 j++;
554 } 558 }
555 } 559 }
560 rv[j] = '\0';
561
556 // remove a trailing slash 562 // remove a trailing slash
557 if (j > 1 && rv[j - 1] == '/') 563 if (j > 1 && rv[j - 1] == '/')
558 rv[j - 1] = '\0'; 564 rv[j - 1] = '\0';
559 size_t new_len = strlen(rv);
560 if (new_len < len) {
561 rv = realloc(rv, new_len + 1);
562 if (!rv)
563 errExit("realloc");
564 }
565 } 565 }
566 else
567 *rv = '\0';
568
566 return rv; 569 return rv;
567} 570}
568 571
diff --git a/status b/status
index 96ad6512a..146df8600 100644
--- a/status
+++ b/status
@@ -1,5 +1,6 @@
1Oct 17, partial mainline merge
2 1
2Oct 12: full merge
3done: fs_whitelist: no warning if macro resolution fails because of missing…
3done: clean homedir pathname 4done: clean homedir pathname
4done: allow overriding of disable-mnt with noblacklist 5done: allow overriding of disable-mnt with noblacklist
5 6