Codebase list genext2fs / 727cf95
Enable system locale - change from the standard (C) to system locale. This allows libarchive (in case it is activated) to handle filenames. We only change LC_CTYPE since libarchive only needs the charset set. We don't use LC_ALL because it causes problems on some systems. We restore the original LC_CTYPE after extraction to avoid side effects. We use uselocale instead of setlocale to avoid setting LC_CTYPE globally. See on libarchive Website for a more complete description of the issue: https://github.com/libarchive/libarchive/issues/587 https://github.com/libarchive/libarchive/wiki/Filenames https://sources.debian.org/src/swupdate/2021.11-1/handlers/archive_handler.c/?hl=100#L94 Johannes Schauer Marin Rodrigues 2 years ago
2 changed file(s) with 43 addition(s) and 0 deletion(s). Raw diff Collapse all Expand all
0 --- a/genext2fs.c
1 +++ b/genext2fs.c
2 @@ -151,6 +151,7 @@
3 #ifdef HAVE_LIBARCHIVE
4 #include <archive.h>
5 #include <archive_entry.h>
6 +#include <locale.h>
7 #endif
8
9 #include "cache.h"
10 @@ -2475,6 +2476,22 @@ add2fs_from_tarball(filesystem *fs, uint
11 char *path2, *path3, *dir, *name, *lnk;
12 size_t filesize;
13 uint32 uid, gid, mode, ctime, mtime;
14 + locale_t archive_locale;
15 + locale_t old_locale;
16 + /*
17 + * Enable system locale - change from the standard (C) to system locale.
18 + * This allows libarchive (in case it is activated) to handle filenames.
19 + * We only change LC_CTYPE since libarchive only needs the charset set.
20 + * We don't use LC_ALL because it causes problems on some systems.
21 + * We restore the original LC_CTYPE after extraction to avoid side effects.
22 + * We use uselocale instead of setlocale to avoid setting LC_CTYPE globally.
23 + * See on libarchive Website for a more complete description of the issue:
24 + * https://github.com/libarchive/libarchive/issues/587
25 + * https://github.com/libarchive/libarchive/wiki/Filenames
26 + * https://sources.debian.org/src/swupdate/2021.11-1/handlers/archive_handler.c/?hl=100#L94
27 + */
28 + archive_locale = newlocale(LC_CTYPE_MASK, "", (locale_t)0);
29 + old_locale = uselocale(archive_locale);
30 a = archive_read_new();
31 if (a == NULL)
32 error_msg_and_die("Couldn't create archive reader.");
33 @@ -2596,6 +2613,8 @@ add2fs_from_tarball(filesystem *fs, uint
34 }
35 archive_read_close(a);
36 archive_read_free(a);
37 + uselocale(old_locale);
38 + freelocale(archive_locale);
39 #endif
40 }
41