diff options
author | 2018-08-15 17:41:37 +0200 | |
---|---|---|
committer | 2018-08-15 17:41:37 +0200 | |
commit | 2dc3371a071aec665ac34e04bc53a0ef2ab59fb2 (patch) | |
tree | 7efed375f737694ed1a38e378d4a730045074abd | |
parent | wireshark.profile: enable apparmor (diff) | |
download | firejail-2dc3371a071aec665ac34e04bc53a0ef2ab59fb2.tar.gz firejail-2dc3371a071aec665ac34e04bc53a0ef2ab59fb2.tar.zst firejail-2dc3371a071aec665ac34e04bc53a0ef2ab59fb2.zip |
fix NP deref
private-home and private-bin are included just for consistency
-rw-r--r-- | src/firejail/fs_bin.c | 4 | ||||
-rw-r--r-- | src/firejail/fs_etc.c | 6 | ||||
-rw-r--r-- | src/firejail/fs_home.c | 4 | ||||
-rw-r--r-- | src/firejail/fs_lib.c | 6 |
4 files changed, 20 insertions, 0 deletions
diff --git a/src/firejail/fs_bin.c b/src/firejail/fs_bin.c index 5625ed356..168ecacfb 100644 --- a/src/firejail/fs_bin.c +++ b/src/firejail/fs_bin.c | |||
@@ -285,6 +285,10 @@ void fs_private_bin_list(void) { | |||
285 | errExit("strdup"); | 285 | errExit("strdup"); |
286 | 286 | ||
287 | char *ptr = strtok(dlist, ","); | 287 | char *ptr = strtok(dlist, ","); |
288 | if (!ptr) { | ||
289 | fprintf(stderr, "Error: invalid private-bin argument\n"); | ||
290 | exit(1); | ||
291 | } | ||
288 | globbing(ptr); | 292 | globbing(ptr); |
289 | while ((ptr = strtok(NULL, ",")) != NULL) | 293 | while ((ptr = strtok(NULL, ",")) != NULL) |
290 | globbing(ptr); | 294 | globbing(ptr); |
diff --git a/src/firejail/fs_etc.c b/src/firejail/fs_etc.c index 8847e44e7..bf60b56a7 100644 --- a/src/firejail/fs_etc.c +++ b/src/firejail/fs_etc.c | |||
@@ -99,6 +99,8 @@ errexit: | |||
99 | } | 99 | } |
100 | 100 | ||
101 | static void duplicate(const char *fname, const char *private_dir, const char *private_run_dir) { | 101 | static void duplicate(const char *fname, const char *private_dir, const char *private_run_dir) { |
102 | assert(fname); | ||
103 | |||
102 | if (*fname == '~' || *fname == '/' || strstr(fname, "..")) { | 104 | if (*fname == '~' || *fname == '/' || strstr(fname, "..")) { |
103 | fprintf(stderr, "Error: \"%s\" is an invalid filename\n", fname); | 105 | fprintf(stderr, "Error: \"%s\" is an invalid filename\n", fname); |
104 | exit(1); | 106 | exit(1); |
@@ -162,6 +164,10 @@ void fs_private_dir_list(const char *private_dir, const char *private_run_dir, c | |||
162 | 164 | ||
163 | 165 | ||
164 | char *ptr = strtok(dlist, ","); | 166 | char *ptr = strtok(dlist, ","); |
167 | if (!ptr) { | ||
168 | fprintf(stderr, "Error: invalid private %s argument\n", private_dir); | ||
169 | exit(1); | ||
170 | } | ||
165 | duplicate(ptr, private_dir, private_run_dir); | 171 | duplicate(ptr, private_dir, private_run_dir); |
166 | 172 | ||
167 | while ((ptr = strtok(NULL, ",")) != NULL) | 173 | while ((ptr = strtok(NULL, ",")) != NULL) |
diff --git a/src/firejail/fs_home.c b/src/firejail/fs_home.c index 09931bd56..3b5094ac9 100644 --- a/src/firejail/fs_home.c +++ b/src/firejail/fs_home.c | |||
@@ -494,6 +494,10 @@ void fs_private_home_list(void) { | |||
494 | errExit("strdup"); | 494 | errExit("strdup"); |
495 | 495 | ||
496 | char *ptr = strtok(dlist, ","); | 496 | char *ptr = strtok(dlist, ","); |
497 | if (!ptr) { | ||
498 | fprintf(stderr, "Error: invalid private-home argument\n"); | ||
499 | exit(1); | ||
500 | } | ||
497 | duplicate(ptr); | 501 | duplicate(ptr); |
498 | while ((ptr = strtok(NULL, ",")) != NULL) | 502 | while ((ptr = strtok(NULL, ",")) != NULL) |
499 | duplicate(ptr); | 503 | duplicate(ptr); |
diff --git a/src/firejail/fs_lib.c b/src/firejail/fs_lib.c index 77c9a0cf5..a607280a0 100644 --- a/src/firejail/fs_lib.c +++ b/src/firejail/fs_lib.c | |||
@@ -196,6 +196,8 @@ static void load_library(const char *fname) { | |||
196 | } | 196 | } |
197 | 197 | ||
198 | static void install_list_entry(const char *lib) { | 198 | static void install_list_entry(const char *lib) { |
199 | assert(lib); | ||
200 | |||
199 | // filename check | 201 | // filename check |
200 | int len = strlen(lib); | 202 | int len = strlen(lib); |
201 | if (strcspn(lib, "\\&!?\"'<>%^(){}[];,") != (size_t)len || | 203 | if (strcspn(lib, "\\&!?\"'<>%^(){}[];,") != (size_t)len || |
@@ -255,6 +257,10 @@ void fslib_install_list(const char *lib_list) { | |||
255 | errExit("strdup"); | 257 | errExit("strdup"); |
256 | 258 | ||
257 | char *ptr = strtok(dlist, ","); | 259 | char *ptr = strtok(dlist, ","); |
260 | if (!ptr) { | ||
261 | fprintf(stderr, "Error: invalid private-lib argument\n"); | ||
262 | exit(1); | ||
263 | } | ||
258 | install_list_entry(ptr); | 264 | install_list_entry(ptr); |
259 | 265 | ||
260 | while ((ptr = strtok(NULL, ",")) != NULL) | 266 | while ((ptr = strtok(NULL, ",")) != NULL) |