From patchwork Sun Jan 6 01:23:04 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 1021029 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=googlegroups.com (client-ip=2607:f8b0:4864:20::e3a; helo=mail-vs1-xe3a.google.com; envelope-from=swupdate+bncbcl4hcw73qcbbcvryxqqkgqebjyvlvi@googlegroups.com; receiver=) Authentication-Results: ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=googlegroups.com header.i=@googlegroups.com header.b="M+E1p56e"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="rDgHv0X+"; dkim-atps=neutral Received: from mail-vs1-xe3a.google.com (mail-vs1-xe3a.google.com [IPv6:2607:f8b0:4864:20::e3a]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43XLPn3D2Vz9sCr for ; Sun, 6 Jan 2019 12:23:24 +1100 (AEDT) Received: by mail-vs1-xe3a.google.com with SMTP id p8sf23093960vsd.22 for ; Sat, 05 Jan 2019 17:23:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1546737802; cv=pass; d=google.com; s=arc-20160816; b=dTztL7MsrRwxc0Vb5hpsZ7wcaDAJ8H2moHjUiNDaevoGJUmu+ROr93Im4oKPgOzeFA J4NKPVMEF1tRmF4M2nUM8EICVya9wwxcnTPDPwRWb7k1W8Rura8fZxigX7mOiZuGe3+8 cZwge3mnoTaIY4ng/p6Dm/J00+HlS8ybzfQIvWKHw1A57r7FUa24YCmNQ68WtaGs5h2r EjJ7zdtLRoaLhmiqOjky5sasL0kdfhC+gS0rTYAOqc5zHNA/lLKv1lWU5QD1TA1MDF17 S0yElg9Ys/qna6GPhPc1PA45b9cbkJlDHVQ+8VMFjBUGj55z6ajxSkvpwZC1eR+BSAK2 /y2Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post :list-id:mailing-list:precedence:message-id:date:subject:cc:to:from :mime-version:sender:dkim-signature:dkim-signature; bh=Vz66cRTlH31J+K1dVPoeLAsULdfIMvoFpOxwUb8Tm9g=; b=q2R4Sl2UTtzvLwestfKysnpvKYex7gnlBPnGGyeC2Nb5VNcgbImooqQAR6zDditKS2 ynPWOV+TZziHEPtdIxEd6uDN/Q1zJOMe89hqfnaJafHhf0jUrRAZqJSfOZbGdXwfaCcd hp8ZkrhiikCKj8g3/5/dsw25fy+9CLAeQuWzzi/mv1tfPBMttK5M5YETNzG1fgLbXx7I ++3G5sAgFIHCGTt3XxC2OXqeqISmxqM6qz+2KrkMsQVn7ZLOS8FGjG/r1kGxq5k7WGm5 5QUN/ovo0Upc0SFAuLG5f3pgc0Exh7Rso7drIkFf2d9ToSAud6OL5jqaDNlomWo1UXEn +M9g== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aGsWr4jn; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::243 as permitted sender) smtp.mailfrom=james.hilliard1@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlegroups.com; s=20161025; h=sender:mime-version:from:to:cc:subject:date:message-id :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=Vz66cRTlH31J+K1dVPoeLAsULdfIMvoFpOxwUb8Tm9g=; b=M+E1p56eAi2WiQr6POT0d49ejzv8/b9wwUOpTKDecwzfSctIRwlChpr2nFOri/1OYm rtfY+Qi/omCWkndmuqVa6TkvbFLzUPZY9VXSRghJ9mHRQLyPWZlz/8DHc91sIPQeh1CR wINDb4GYqTMuzb2O5RDNr3y4UVGZ8obJuiFLUpwlxW1/T8y1O4Fa2KoQ0L4P45jyX5d2 od+pjvrtkyzNOG7FPp9DpdengcCWey6dcXLE7dMcWgXwuV6exfGxoA1LiIUvHktU09xz kmc/ZK6xeFH2vts14ONug5TZAHZogglff2Mob3duPHDj4zZnrMlVTInjSdzILfEEdjk1 V6Tg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:to:cc:subject:date:message-id:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=Vz66cRTlH31J+K1dVPoeLAsULdfIMvoFpOxwUb8Tm9g=; b=rDgHv0X+UxAjgUm+y6ySi8bJ/S4VZ9/1jZQyuZvKkvCoEaN2m8/zZvYXbG+S0N9bie RQUfjaoZCmwOzJXUKvIJRGCPMkFheMoB0yXHRZsHZTIAuba6Z5A1gBz5shHsI1AazvHF tdxECQ58yyJPfc8pIvTYSqWfghZLvLMLKEQcFvFyXB1iArQbKcdCczkhDlYKCokpVq1f NwgXj3rkN2U5xnBqsD/Xbj96KT3pDMxuuTAipYacV1jYfIAvd/0wAM1/wofOjB8qiVX5 mfjP4ScFV9r80kAeThZ+E4ciiDDQ5KiNJPOhYVpOUuZJPH1QAc9zIEDkKWcHHs8AlwgO 9rTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:mime-version:from:to:cc:subject:date :message-id:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:x-spam-checked-in-group:list-post :list-help:list-archive:list-subscribe:list-unsubscribe; bh=Vz66cRTlH31J+K1dVPoeLAsULdfIMvoFpOxwUb8Tm9g=; b=m95m9hC0sUjvziDlzwdzzv7fO1Og3wQp4rmFcY/AF/13YnsrXT0yOB031YNDNJWwr6 h9huZIyXdnAEcc4T8MmJGIrU1KHPekLWbzIBZbrkTUi5HTQSick1ypxbqU1uXV4dLx9g bRkGA+3DQrREQBv7NX1b+1gZ5h7omQahnhzk++8ZgpC1SAmq9w9oFk5m25cMRwI/GhO4 7Kudn+Pu0v+xfh+f61OIF8tJAkhQHBeFJ1sHh6d2gT4+YtkPJaGpduBNFvVmid3swZlI aFiv2pCd8VcLzuLWs/2eJ70D8jESluXtvn/RnjI85nCqui5/rVaOj34kF2CuTrwk2v1x YYDA== Sender: swupdate@googlegroups.com X-Gm-Message-State: AJcUukedxdqx2FV8QwtVlvwODEMK+6GmvguoATPr4Q5D9fk25rdpi7oz lObGMgG5ZJQhaVvZaIBGZP4= X-Google-Smtp-Source: ALg8bN6fzv1IS61NIlXUS6QQxXqK3JOyQ3DVHqQ2m9AAgsOXm6OEsaLKgleLU7+EHZYhrEaoqEYC9w== X-Received: by 2002:a1f:9d46:: with SMTP id g67mr146934vke.6.1546737802715; Sat, 05 Jan 2019 17:23:22 -0800 (PST) MIME-Version: 1.0 X-BeenThere: swupdate@googlegroups.com Received: by 2002:a1f:ac91:: with SMTP id v139ls2876319vke.2.gmail; Sat, 05 Jan 2019 17:23:22 -0800 (PST) X-Received: by 2002:a1f:2d08:: with SMTP id t8mr41627772vkt.14.1546737802318; Sat, 05 Jan 2019 17:23:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546737802; cv=none; d=google.com; s=arc-20160816; b=l5+vbq/98c0AnWNNVfYH4pct1yPenQZHtqobE3+X8ZkgZNNs5lrYm63I0kkM/wafuZ VzjcLSErXpK/xNEP1ZEQSpKu10pgi8rkS2iTrpIZNnOfID2mTUYnaEPpNl5NRJE5on2r htDhUSwjEcfGOXUBtYquFpMsFB4MhLemONQaQrn/nshSiIv06sZln3XpMADvURnW9n72 hJ/rkZKuT89JmxOhliIw5VLmCPo7L2mpfNz5oll7UpE3hUXCNcYvdHYWjP3zGSs9B495 UyX11UEyG6kE3uhuUvoZm/iBE1ckkVteB0oRLBpequ1fjjO/J4h6ayFHYN1xu2rwKM8A t7Yg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:dkim-signature; bh=KrIRZ6tIeh0DhqLoBFlurzibVlzd5PckhCqqtDsjhRI=; b=pOoaqeIEfhi2u8G34815zSFEGb5jwPtSz4N+0Q+ir5aP1zJ/iEvpmClB1dAPnRV06S lQEKlAsFe2XZqGODdDGK4DXy/D7KnqlET7io6CCb+qH7rq082E84RPzUenjcOcz37lF5 zEpsh/eYjthj4GoKBv8W+utYVAqkWAtl7LAQb+And/slSH1TEACAJxAkOrgRrHobLG2F OgZXICITY20hFrDNCy10NufYgocOXllzpuBZCL+ZaRJgDWEcua32cUSeW76ThNH7WNdi 9pqWTi4UvOU3ukXrFGAE0El9G2jctei1r+HWIaAq9G4A6i+pzKWuwyp6vvCyCunNMFE1 jTag== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aGsWr4jn; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::243 as permitted sender) smtp.mailfrom=james.hilliard1@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-oi1-x243.google.com (mail-oi1-x243.google.com. [2607:f8b0:4864:20::243]) by gmr-mx.google.com with ESMTPS id x65si4013119vkg.2.2019.01.05.17.23.22 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 05 Jan 2019 17:23:22 -0800 (PST) Received-SPF: pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::243 as permitted sender) client-ip=2607:f8b0:4864:20::243; Received: by mail-oi1-x243.google.com with SMTP id c206so33338778oib.0 for ; Sat, 05 Jan 2019 17:23:22 -0800 (PST) X-Received: by 2002:aca:6c8b:: with SMTP id h133mr4744941oic.33.1546737801385; Sat, 05 Jan 2019 17:23:21 -0800 (PST) Received: from localhost.localdomain ([47.187.31.127]) by smtp.gmail.com with ESMTPSA id c132sm25133689oia.41.2019.01.05.17.23.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 05 Jan 2019 17:23:20 -0800 (PST) From: james.hilliard1@gmail.com To: swupdate@googlegroups.com Cc: sbabic@denx.de, James Hilliard Subject: [swupdate] [PATCH v2 1/1] archive handler: set locale for libarchive Date: Sun, 6 Jan 2019 09:23:04 +0800 Message-Id: <1546737784-6893-1-git-send-email-james.hilliard1@gmail.com> X-Mailer: git-send-email 2.7.4 X-Original-Sender: james.hilliard1@gmail.com X-Original-Authentication-Results: gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aGsWr4jn; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::243 as permitted sender) smtp.mailfrom=james.hilliard1@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Precedence: list Mailing-list: list swupdate@googlegroups.com; contact swupdate+owners@googlegroups.com List-ID: X-Spam-Checked-In-Group: swupdate@googlegroups.com X-Google-Group-Id: 605343134186 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , From: James Hilliard Signed-off-by: James Hilliard Acked-by: Stefano Babic --- handlers/archive_handler.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/handlers/archive_handler.c b/handlers/archive_handler.c index a44819d..35b1167 100644 --- a/handlers/archive_handler.c +++ b/handlers/archive_handler.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -67,6 +68,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; struct archive_entry *entry; @@ -75,6 +78,20 @@ extract(void *p) struct extract_data *data = (struct extract_data *)p; flags = data->flags; + /* + * 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 Websiete 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(); ext = archive_write_disk_new(); archive_write_disk_set_options(ext, flags); @@ -97,6 +114,7 @@ extract(void *p) if ((r = archive_read_open_filename(a, FIFO, 4096))) { ERROR("archive_read_open_filename(): %s %d", archive_error_string(a), r); + uselocale(old_locale); pthread_exit((void *)-1); } for (;;) { @@ -106,6 +124,7 @@ extract(void *p) if (r != ARCHIVE_OK) { ERROR("archive_read_next_header(): %s %d", archive_error_string(a), 1); + uselocale(old_locale); pthread_exit((void *)-1); } @@ -122,6 +141,7 @@ extract(void *p) if (r != ARCHIVE_OK) { ERROR("archive_write_finish_entry(): %s", archive_error_string(ext)); + uselocale(old_locale); pthread_exit((void *)-1); } } @@ -130,6 +150,7 @@ extract(void *p) archive_read_close(a); archive_read_free(a); + uselocale(old_locale); pthread_exit((void *)0); }