kumquat-buildroot/package/swupdate/0001-archive-handler-set-locale-for-libarchive.patch
Pierre-Jean Texier e2d299485e package/swupdate: bump to version 2019.04
New features in this release:
 - Improved documentation
 - delta updates based on rdiff library
 - support for libubootenv
 - dry-run option
 - CA certificates for signed images
 - Fix security leak in parser

This commit also:
 - introduce BR2_PACKAGE_LIBRSYNC for 'rdiff' Handler. No HAVE_* is
   needed, it just declares the functions locally and links with
   -lrsync.
 - introduce BR2_PACKAGE_LIBUBOOTENV
 - drop upstreamed patch
 - backport upstream patches (important fix)
 - regenerate the default swupdate.config. Now CONFIG_GUNZIP is always
   enabled because gunzip is provided by the default busybox config.

Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
[Arnout: don't mention ZLIB in help text for libubootenv, since it is
 select'ed by libubootenv.]
Signed-off-by: Arnout Vandecappelle (Essensium/Mind) <arnout@mind.be>
2019-06-10 23:51:36 +02:00

66 lines
2.0 KiB
Diff

From 95a2b9961119aac80aea1eeabbc1cd52b72d876a Mon Sep 17 00:00:00 2001
From: James Hilliard <james.hilliard1@gmail.com>
Date: Sat, 4 May 2019 11:38:37 -0600
Subject: [PATCH] archive handler: set locale for libarchive
Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
[Backported from: 95a2b9961119aac80aea1eeabbc1cd52b72d876a]
Signed-off-by: Pierre-Jean Texier <pjtexier@koncepto.io>
---
handlers/archive_handler.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/handlers/archive_handler.c b/handlers/archive_handler.c
index 7f12761..993bc10 100644
--- a/handlers/archive_handler.c
+++ b/handlers/archive_handler.c
@@ -6,6 +6,7 @@
*/
#include <sys/types.h>
+#include <locale.h>
#include <stdio.h>
#include <sys/stat.h>
#include <unistd.h>
@@ -68,6 +69,8 @@ copy_data(struct archive *ar, struct archive *aw)
static void *
extract(void *p)
{
+ locale_t archive_locale;
+ locale_t old_locale;
struct archive *a;
struct archive *ext = NULL;
struct archive_entry *entry = NULL;
@@ -77,6 +80,20 @@ extract(void *p)
flags = data->flags;
int exitval = -EFAULT;
+ /*
+ * 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
+ */
+ archive_locale = newlocale(LC_CTYPE_MASK, "", (locale_t)0);
+ old_locale = uselocale(archive_locale);
+
a = archive_read_new();
if (!a) {
goto out;
@@ -155,6 +172,7 @@ out:
archive_read_free(a);
}
+ uselocale(old_locale);
data->exitval = exitval;
pthread_exit(NULL);
}
--
2.7.4