From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id ACJlCjRD+GOJ5AAAbAwnHQ (envelope-from ) for ; Fri, 24 Feb 2023 05:55:16 +0100 Received: from aspmx1.migadu.com ([2001:41d0:8:6d80::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id QABbCjRD+GP7ggEA9RJhRA (envelope-from ) for ; Fri, 24 Feb 2023 05:55:16 +0100 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by aspmx1.migadu.com (Postfix) with ESMTPS id 6E20E29597 for ; Fri, 24 Feb 2023 05:55:15 +0100 (CET) Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=p8beQd77; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Seal: i=1; s=key1; d=yhetil.org; t=1677214516; a=rsa-sha256; cv=none; b=jsvDVpNaCYPHzgPjZz0PabyXg5R4XNFEsDj98DQpDdzzEMmMFy6D5Upl50gQKreGrKTURb F436UA+Co+66GB0qb2a+FZOHfzFWryUk92mqJ0RTEjkvALZ928sAYhq8NF+do0GJQcAWZJ pUFwe9aW8FLSl20LnJ2M6JsSf1MgMReLEjHxhX2MOBLciug5A7mUs5qoSADwTE8et+WV00 HSwk1ehqnY7ZhpdEDz/JA40VqEMxX+StmzC4mgcNsrcFcfkliLzs33C1fyjLTeS7rli2fC jL3zIvTxHnq+oRvz06LMd7QKLmaHdwh4Ue0M8eC6Z1xiK2xoRwd4dC4MhG3Brg== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=p8beQd77; spf=pass (aspmx1.migadu.com: domain of "bug-guix-bounces+larch=yhetil.org@gnu.org" designates 209.51.188.17 as permitted sender) smtp.mailfrom="bug-guix-bounces+larch=yhetil.org@gnu.org"; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none) ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1677214516; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding:resent-cc: resent-from:resent-sender:resent-message-id:in-reply-to:in-reply-to: references:references:list-id:list-help:list-unsubscribe: list-subscribe:list-post:dkim-signature; bh=qxIAuzDUk9NOc7lSmjXWSF6qvuSQy9bMDeAJnbAWXP0=; b=U6KwJ/3TxheONH+AGEhqR3qKqYAPHuxtfCdOrx8xzRsYfPCEAHLLkNvvzukZ3xtMARHNo/ wicBN1BLc+hd+mtAyqlEr2KuSVqZ0kCNRtFVhSGqi4TX/p3gOYhKCPEno3dgcUwfYjVfHM jqx3jouCmQWw4PonKgYVVT9lLoqWWifvSllqBEAMUDVylXMz24R1rbLPBHfMp5ErTWK+MI 3OWCQ1RFyR6bSziTgAbOMMLzz5j9zJfT+NiJNLtMqQxiSlLnxLRFgKFxGL9Dmjeue9hj+T s6MCCmaYoLIPO4+B2LFzuK4lYCUtF3Q4CJNs+5Y/YZswsYZV3fDbMsNVJDKkyw== Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVQ6t-0004Dh-2F; Thu, 23 Feb 2023 23:55:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pVQ6p-0004DV-0f for bug-guix@gnu.org; Thu, 23 Feb 2023 23:55:03 -0500 Received: from debbugs.gnu.org ([209.51.188.43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pVQ6o-0002dF-GI for bug-guix@gnu.org; Thu, 23 Feb 2023 23:55:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pVQ6o-0007Xp-Al for bug-guix@gnu.org; Thu, 23 Feb 2023 23:55:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#61722: [PATCH] cpio: Properly handle Unicode characters in file names. References: <87mt55hy3x.fsf@gmail.com> In-Reply-To: <87mt55hy3x.fsf@gmail.com> Resent-From: Maxim Cournoyer Original-Sender: "Debbugs-submit" Resent-CC: bug-guix@gnu.org Resent-Date: Fri, 24 Feb 2023 04:55:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 61722 X-GNU-PR-Package: guix X-GNU-PR-Keywords: To: 61722@debbugs.gnu.org Cc: Josselin Poiret , Tobias Geerinckx-Rice , Maxim Cournoyer , Simon Tournier , Mathieu Othacehe , Ludovic =?UTF-8?Q?Court=C3=A8s?= , Christopher Baines , Ricardo Wurmus Received: via spool by 61722-submit@debbugs.gnu.org id=B61722.167721446128942 (code B ref 61722); Fri, 24 Feb 2023 04:55:02 +0000 Received: (at 61722) by debbugs.gnu.org; 24 Feb 2023 04:54:21 +0000 Received: from localhost ([127.0.0.1]:35809 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVQ68-0007Wi-PV for submit@debbugs.gnu.org; Thu, 23 Feb 2023 23:54:21 -0500 Received: from mail-qt1-f180.google.com ([209.85.160.180]:34619) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVQ64-0007WS-Sr for 61722@debbugs.gnu.org; Thu, 23 Feb 2023 23:54:19 -0500 Received: by mail-qt1-f180.google.com with SMTP id b6so7348515qtb.1 for <61722@debbugs.gnu.org>; Thu, 23 Feb 2023 20:54:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=qxIAuzDUk9NOc7lSmjXWSF6qvuSQy9bMDeAJnbAWXP0=; b=p8beQd77lbN5U6MNYRHeZ+iLDhgi85JMFv400RpQ2rcotXiPMXOX2EgGSVunaHgNuV REJxUNetw73ICcxZJRM/GRh0gzQ3h3oHGrA770YYVGn6Ip3xSBCbrepmf7ubsILIdFkk Eamqnn0n5E9QWvApwtgdRIQopRhqM6wcLY7U7lPOHE3l9Ubi41xsTFkEP8Sk3TGTd4l6 UpghNOCHnmNefyX9++eAlQKOGTo3eijg8Ippe1lwOKrxcMD8S8SW2PKhmbF7zQK0jeZ0 T+tieuuVpUlAosHtXxA1o2yiUJRVFR4eKneUeRWS90dvSjaUG4+HQY5WJWIToT0f8cDb hhrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=qxIAuzDUk9NOc7lSmjXWSF6qvuSQy9bMDeAJnbAWXP0=; b=64dyfoJXzdvmGv2VdQV/3AnzRHzXTq4fLYEp09sfu0kW+rQszqDs1VL71Xeh6bpR3w k1vTjkavTK30ACY6ffOadUkeooK7uWzE8Vupl/YnB//DPZh57I8av+GC65Ky4g9FvfJ5 GcP7m+57XYarOpnhcox1iZkjnr3eWbXfycgkZrv3grapQQlm2K8CWYIum7VX4c4MaDmr 8apsk3GxGhmcpl4gVSizYygHdhBR3nXBV7rAFqIW3fEjmR1HP1wmNPdZKrdHdVooi843 1HCxyBkDzoc4Kol6bhm+LskmlGxIBXyMp8w++hCto3brGtnfJT3nnbhvjtPVnkTkptvJ 1K9g== X-Gm-Message-State: AO0yUKUgeGGfgaOTCNWmCyBfJhb+sXazuPt+WFcAQed9kYSRi0ySE1Lm 65DbfnFwc5jwx2qMAsEypBxqrDxTnpxjDtgv X-Google-Smtp-Source: AK7set8CDsV0r7LRJx2+yLMhW0f62DFQVoDfRxU7YIl/5xNOkM1oC4LDKPawe3xb6Tn9Ze79GML9EQ== X-Received: by 2002:ac8:5c08:0:b0:3b8:63fa:11be with SMTP id i8-20020ac85c08000000b003b863fa11bemr23126946qti.66.1677214451008; Thu, 23 Feb 2023 20:54:11 -0800 (PST) Received: from localhost.localdomain (dsl-10-129-1.b2b2c.ca. [72.10.129.1]) by smtp.gmail.com with ESMTPSA id i3-20020a37b803000000b0073bacce6ad7sm4115824qkf.82.2023.02.23.20.54.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Feb 2023 20:54:10 -0800 (PST) From: Maxim Cournoyer Date: Thu, 23 Feb 2023 23:54:01 -0500 Message-Id: <20230224045402.26444-1-maxim.cournoyer@gmail.com> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: bug-guix@gnu.org List-Id: Bug reports for GNU Guix List-Unsubscribe: , List-Archive: List-Post: X-Migadu-Queue-Id: 6E20E29597 X-Spam-Score: -0.88 X-Migadu-Spam-Score: -0.88 X-Migadu-Scanner: scn0.migadu.com List-Help: List-Subscribe: , Errors-To: bug-guix-bounces+larch=yhetil.org@gnu.org Sender: bug-guix-bounces+larch=yhetil.org@gnu.org X-Migadu-Flow: FLOW_IN X-Migadu-Country: US X-TUID: LwrlFBPjzC8y Fixes . * guix/cpio.scm (file->cpio-header): Compute the file name length in bytes rather than in characters. (file->cpio-header*, special-file->cpio-header*): Likewise. (write-cpio-archive): Likewise, and write the file name as UTF-8 bytes, not textually, to avoid encoding it as ISO-8859-1. --- guix/cpio.scm | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/guix/cpio.scm b/guix/cpio.scm index d4a7d5f1e0..8fd7552450 100644 --- a/guix/cpio.scm +++ b/guix/cpio.scm @@ -170,7 +170,8 @@ (define* (file->cpio-header file #:optional (file-name file) #:size (stat:size st) #:dev (stat:dev st) #:rdev (stat:rdev st) - #:name-size (string-length file-name)))) + #:name-size (bytevector-length + (string->utf8 file-name))))) (define* (file->cpio-header* file #:optional (file-name file) @@ -182,7 +183,8 @@ (define* (file->cpio-header* file (make-cpio-header #:mode (stat:mode st) #:nlink (stat:nlink st) #:size (stat:size st) - #:name-size (string-length file-name)))) + #:name-size (bytevector-length + (string->utf8 file-name))))) (define* (special-file->cpio-header* file device-type @@ -201,7 +203,8 @@ (define* (special-file->cpio-header* file permission-bits) #:nlink 1 #:rdev (device-number device-major device-minor) - #:name-size (string-length file-name))) + #:name-size (bytevector-length + (string->utf8 file-name)))) (define %trailer "TRAILER!!!") @@ -237,7 +240,7 @@ (define (dump-file file) ;; We're padding the header + following file name + trailing zero, and ;; the header is 110 byte long. - (write-padding (+ 110 1 (string-length file)) port) + (write-padding (+ 110 (bytevector-length (string->utf8 file)) 1) port) (case (mode->type (cpio-header-mode header)) ((regular) @@ -246,7 +249,7 @@ (define (dump-file file) (dump-port input port)))) ((symlink) (let ((target (readlink file))) - (put-string port target))) + (put-bytevector port (string->utf8 target)))) ((directory) #t) ((block-special) base-commit: c756c62cfdba8d4079be1ba9e370779b850f16b6 -- 2.39.1