From patchwork Sat May 4 17:23:03 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hilliard X-Patchwork-Id: 1095275 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::838; helo=mail-qt1-x838.google.com; envelope-from=swupdate+bncbcl4hcw73qcbbamvw7takgqelaytg6i@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="jXXnHVds"; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="d+R5UV9v"; dkim-atps=neutral Received: from mail-qt1-x838.google.com (mail-qt1-x838.google.com [IPv6:2607:f8b0:4864:20::838]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 44xG6v1V2nz9s5c for ; Sun, 5 May 2019 03:23:17 +1000 (AEST) Received: by mail-qt1-x838.google.com with SMTP id z34sf9798377qtz.14 for ; Sat, 04 May 2019 10:23:17 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1556990594; cv=pass; d=google.com; s=arc-20160816; b=qYcBQUxqRc/LaMyKLcUH+hBKPVHfHZvF8UGpxHjwFeORJhq30DXCL4qHLjXVXe40Yn XKkAjRsoCZJ4brsmIYfXAy22lCO5RlEFDQuDqoe0sm30rFjuXmfQ1+WRP0mBlyQM+NJo RQ4FemcK3KlcWQzQY+pCA0b/1FxBoPxjlnkGMwPXGxN9VP4wR4A+E2Cun/Kzi4ZXaTNB Ai2v4xHd3DyVUExtz9Y54bUW/wJ4ZJf4tOKhFvzKdALxgh1NDgPstgiew2RLDA7Afrdz PGxIyYbKxhZgD68s7NEWSOSQ25rthiMeD0QvrY1awy47DhvRR2ILDXzj/X0KNG6E1FAC Ie5Q== 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:mime-version:message-id:date :subject:cc:to:from:sender:dkim-signature:dkim-signature; bh=91RBUUc7SrMA3gsK67YnKA/5Q33bLXNoZP28kNR9/fE=; b=d5F70m8w2H99YJ8vc4t/qUshw/JJJiEkba23z5AA4ddJCB7aAuxnndJe/m8bW5s1Fq cVvhImwnNwL0BDGfszntwWiE2sYsxWnXWv3uui+QfMWjEhWnkQ9q483+XaVHt5CrBSsu ZvfbTcsC4jSQqjpb4ZVsU90dCHf6/yI+M9sBx55UGtWQBByPGKEnnRr2hRSCiRBQFlv9 C5Oi0TKPqRChTjOkY3WagxklGZIKNHEZLQFv9bQHetfCykZmrW2BvRV4DEHwbWHZWEHS q9+Ieh+E7fe8kTz38Etb7E9TekrS2bH/X9iiWwTkkIjHwIU5Rj9H4q2/7ob/yQZsNNaT KBHQ== ARC-Authentication-Results: i=2; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tfS5peul; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::d43 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:from:to:cc:subject:date:message-id:mime-version :x-original-sender:x-original-authentication-results:precedence :mailing-list:list-id:list-post:list-help:list-archive :list-subscribe:list-unsubscribe; bh=91RBUUc7SrMA3gsK67YnKA/5Q33bLXNoZP28kNR9/fE=; b=jXXnHVdsu422z//S/bTHlZ4pLGRGus6C0MHrWKf8Bhw2ExllyZ3oKBh715bt5QAwhb 4GGwh1trXSQjAAcfhlhgc8UhP0sYUZLeNvBswBOuyDtFmtPNzH79rxeNGEZbsbW+z+Ik X0DeI2KCb4bQLHuglb5ks0z7/w7KrV8nUoXgUUq7IxCxy4jG68mH75iz/CWhfQNwMyRR ElwUQcpGJYQLmbe1plEWteIx8TXdnp8rJEr1cwD3ANEfUDs1Y7q7PErm3WgEtFCdrwHk lemt4Js50A8xgpDrR5iOF2qUkMc15xitfiR6vourtEjiomLa0gHnvy9snyxVnktU7wXg KRqg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :list-post:list-help:list-archive:list-subscribe:list-unsubscribe; bh=91RBUUc7SrMA3gsK67YnKA/5Q33bLXNoZP28kNR9/fE=; b=d+R5UV9vUP3BL14KkuEBtVUXtW59NCyf+GkgBLEcEiEENQLa1qsdOgyj/kP5YPrZBg G4xqks18Qzfp0nnAoIH4HUCw5+PsNhPdawa0gHNBZIni5FJTEeSZaZdxB4C7/VyuMW4w fyhYCFeLhFOIDkSlixnA3WV5mRYcEV8YHRQuTWJORdYWmZGz4588wMMPw3WSVsxZHLgf xDaZqNu4gVb/qfVsaf8mzrtYySOqm+9wlJnebcuNH7YfaCJpJEvHYkkfbtyOgOfaU2zE kfiG+UcASq1Qqktv0VwHWCYpqgIofid0Us6PSTqiQUfEeUzkz6pg7e7273ns1bAGG+gJ TE3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=sender:x-gm-message-state:from:to:cc:subject:date:message-id :mime-version: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=91RBUUc7SrMA3gsK67YnKA/5Q33bLXNoZP28kNR9/fE=; b=X+rlD7+3g/X49MDHXYtFiDT/Z5Q851Kbe1dzeTnvOzjRehk8LKRFZ1e/RMwfIFWbGt lvd3LDD1bAmXCiTrMuNWn/5E5kQyq75YAiAIidNnVDRRuQBcZ3z0dkegMhGDg0ttwzYY hCAvhp1tPSoRh5yFiXqfhjXJogfpqm5RvnmpjIlxyxYF36iatuplRkVnvUut02LB33X1 c6nSu6t4sd5j/tpy9/MjV+YRNpWDTUIppqZ6H4fvavYkDbYvkzvQymTPckj10EuKY/0f lv2xWqo4SMgY3fbqSlrvErU0shHpKu2A9SXuZyDBrqgT5t/QRSoocta70V97hBFm9f9Q W3rw== Sender: swupdate@googlegroups.com X-Gm-Message-State: APjAAAWPeL0DaN+PPB1uNNcXJTjr8S6NOiW9x7NeMxu82XSoElWOuEBU caJjPDJzB6Eq36Wf119pty0= X-Google-Smtp-Source: APXvYqzFrDRdM/Juv+lYm2OExtAvbs0cVC+P8himDnPgP6hpt9iyFBqQET/XAeQlWF6b97NXvrAtrg== X-Received: by 2002:ac8:2e98:: with SMTP id h24mr13132811qta.97.1556990593859; Sat, 04 May 2019 10:23:13 -0700 (PDT) X-BeenThere: swupdate@googlegroups.com Received: by 2002:a37:4c8b:: with SMTP id z133ls2398360qka.0.gmail; Sat, 04 May 2019 10:23:13 -0700 (PDT) X-Received: by 2002:a37:e315:: with SMTP id y21mr3725872qki.233.1556990593517; Sat, 04 May 2019 10:23:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556990593; cv=none; d=google.com; s=arc-20160816; b=Cm7jwxNvjH/RT/n9CPfqgmAD4vGrQ4YdN2HbwAZuW59xM+13dfVg8CHwEMVBn3zELx +5OpwRi1zF4rbL2wkKuRBWqu4s3HKhHNc2Zb9n4AKJxsoX1+VTDr6pWcgrX9EtTWFgBz ftAMoVJR70MviB4LK9ysAiW+MqeSKus4dzrrZKJxmwY3PnkDDS2wQ6vUyYqcVusN7bzK ITnn7faNhKZa9lFriOZ3MbmtHNg83e9hmgP5w4XHdhEfSIZIBDU6o1HG1kTmcUtTbqLJ LdfjXEAD4y+gMo9Rr1z2oNK8hWuhp8YTb2ZALZte/h0xdhhfA/+TIPVn1i23/IzXquqQ PRCQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=8NEKpVBFY4Q7vVfVHOeqXcyvWSH33GuLvs0AWI7Oumo=; b=Egpiud5DDCKmph3wDcSZ2sgMWGndprq5NtA5+gm2kzw/7Kh06r6xfgoRYK56IUYHJS QcbsVrBX1iDmaBqsqOBJm92WA08MD7nWBwSLUxH+hFOOxhGQC3w6ok+QnBm6wJOytXe4 L0vpS1vEnm13Rr5J24gi1qAq9R/5K/nEIDTKBFQhSFn0VRmv7yLD1mOnYM8K4zQti2Pm D4eYV4Qb49BdDrBoqvA7F+l6uhmhdK2QoAM+VGRd9tWuIBlZ353pVDqglB6GLlNPOHcA aSDNCGFiPY1Z3JBIFfRxJVos0s6CKoFIVtj+HVslYRsRAmT+lBRt2Ee3sPmisTtB8ZBm u20g== ARC-Authentication-Results: i=1; gmr-mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=tfS5peul; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::d43 as permitted sender) smtp.mailfrom=james.hilliard1@gmail.com; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from mail-io1-xd43.google.com (mail-io1-xd43.google.com. [2607:f8b0:4864:20::d43]) by gmr-mx.google.com with ESMTPS id h5si352154qth.4.2019.05.04.10.23.13 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 May 2019 10:23:13 -0700 (PDT) Received-SPF: pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::d43 as permitted sender) client-ip=2607:f8b0:4864:20::d43; Received: by mail-io1-xd43.google.com with SMTP id r10so7790168ioc.8 for ; Sat, 04 May 2019 10:23:13 -0700 (PDT) X-Received: by 2002:a6b:5b0f:: with SMTP id v15mr2428263ioh.82.1556990592533; Sat, 04 May 2019 10:23:12 -0700 (PDT) Received: from james-x399.Home (97-118-224-253.hlrn.qwest.net. [97.118.224.253]) by smtp.gmail.com with ESMTPSA id v136sm3257478itv.26.2019.05.04.10.23.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 04 May 2019 10:23:11 -0700 (PDT) From: James Hilliard To: swupdate@googlegroups.com Cc: sbabic@denx.de, James Hilliard Subject: [swupdate] [PATCH v3 1/1] archive handler: set locale for libarchive Date: Sat, 4 May 2019 11:23:03 -0600 Message-Id: <20190504172303.107898-1-james.hilliard1@gmail.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 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=tfS5peul; spf=pass (google.com: domain of james.hilliard1@gmail.com designates 2607:f8b0:4864:20::d43 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: , Signed-off-by: James Hilliard --- Changes v2 -> v3: - rebase off of master --- handlers/archive_handler.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/handlers/archive_handler.c b/handlers/archive_handler.c index 7f12761..ed66457 100644 --- a/handlers/archive_handler.c +++ b/handlers/archive_handler.c @@ -6,6 +6,7 @@ */ #include +#include #include #include #include @@ -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 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(); if (!a) { goto out; @@ -155,6 +172,7 @@ out: archive_read_free(a); } + uselocale(old_locale); data->exitval = exitval; pthread_exit(NULL); }