diff options
author | 2020-08-07 21:16:12 -0400 | |
---|---|---|
committer | 2020-08-07 21:16:12 -0400 | |
commit | 2f6cd3f85497b10d495d213a125cabcea371d682 (patch) | |
tree | a6a757d402cedd017579cc84a3003e10fa556143 /src | |
parent | fixes for CVE-2020-17367 and CVE-2020-17368 (diff) | |
download | firejail-2f6cd3f85497b10d495d213a125cabcea371d682.tar.gz firejail-2f6cd3f85497b10d495d213a125cabcea371d682.tar.zst firejail-2f6cd3f85497b10d495d213a125cabcea371d682.zip |
patches form Debian (firejail 0.9.64-4, sid): element-profile.patch, usrsharedoc.patch, pathnames.patch, usr-share-firefox.patch
Diffstat (limited to 'src')
-rw-r--r-- | src/firecfg/firecfg.config | 1 | ||||
-rw-r--r-- | src/firejail/macros.c | 49 |
2 files changed, 39 insertions, 11 deletions
diff --git a/src/firecfg/firecfg.config b/src/firecfg/firecfg.config index 5cd6a602c..97148c6b6 100644 --- a/src/firecfg/firecfg.config +++ b/src/firecfg/firecfg.config | |||
@@ -165,6 +165,7 @@ easystroke | |||
165 | ebook-viewer | 165 | ebook-viewer |
166 | electron-mail | 166 | electron-mail |
167 | electrum | 167 | electrum |
168 | element-desktop | ||
168 | elinks | 169 | elinks |
169 | empathy | 170 | empathy |
170 | enchant | 171 | enchant |
diff --git a/src/firejail/macros.c b/src/firejail/macros.c index 9ed6b9715..ef64178b5 100644 --- a/src/firejail/macros.c +++ b/src/firejail/macros.c | |||
@@ -258,6 +258,28 @@ char *expand_macros(const char *path) { | |||
258 | return rv; | 258 | return rv; |
259 | } | 259 | } |
260 | 260 | ||
261 | // replace control characters with a '?' | ||
262 | static char *fix_control_chars(const char *fname) { | ||
263 | assert(fname); | ||
264 | |||
265 | size_t len = strlen(fname); | ||
266 | char *rv = malloc(len + 1); | ||
267 | if (!rv) | ||
268 | errExit("malloc"); | ||
269 | |||
270 | size_t i = 0; | ||
271 | while (fname[i] != '\0') { | ||
272 | if (iscntrl((unsigned char) fname[i])) | ||
273 | rv[i] = '?'; | ||
274 | else | ||
275 | rv[i] = fname[i]; | ||
276 | i++; | ||
277 | } | ||
278 | rv[i] = '\0'; | ||
279 | |||
280 | return rv; | ||
281 | } | ||
282 | |||
261 | void invalid_filename(const char *fname, int globbing) { | 283 | void invalid_filename(const char *fname, int globbing) { |
262 | // EUID_ASSERT(); | 284 | // EUID_ASSERT(); |
263 | assert(fname); | 285 | assert(fname); |
@@ -275,19 +297,24 @@ void invalid_filename(const char *fname, int globbing) { | |||
275 | return; | 297 | return; |
276 | } | 298 | } |
277 | 299 | ||
278 | int len = strlen(ptr); | 300 | size_t i = 0; |
279 | 301 | while (ptr[i] != '\0') { | |
280 | if (globbing) { | 302 | if (iscntrl((unsigned char) ptr[i])) { |
281 | // file globbing ('*?[]') is allowed | 303 | fprintf(stderr, "Error: \"%s\" is an invalid filename: no control characters allowed\n", |
282 | if (strcspn(ptr, "\\&!\"'<>%^(){};,") != (size_t)len) { | 304 | fix_control_chars(fname)); |
283 | fprintf(stderr, "Error: \"%s\" is an invalid filename\n", ptr); | ||
284 | exit(1); | 305 | exit(1); |
285 | } | 306 | } |
307 | i++; | ||
286 | } | 308 | } |
287 | else { | 309 | |
288 | if (strcspn(ptr, "\\&!?\"'<>%^(){};,*[]") != (size_t)len) { | 310 | char *reject; |
289 | fprintf(stderr, "Error: \"%s\" is an invalid filename\n", ptr); | 311 | if (globbing) |
290 | exit(1); | 312 | reject = "\\&!\"'<>%^{};,"; // file globbing ('*?[]') is allowed |
291 | } | 313 | else |
314 | reject = "\\&!?\"'<>%^{};,*[]"; | ||
315 | char *c = strpbrk(ptr, reject); | ||
316 | if (c) { | ||
317 | fprintf(stderr, "Error: \"%s\" is an invalid filename: rejected character: \"%c\"\n", fname, *c); | ||
318 | exit(1); | ||
292 | } | 319 | } |
293 | } | 320 | } |