From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mp11.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by ms5.migadu.com with LMTPS id EEYPDnq7+GPWbAAAbAwnHQ (envelope-from ) for ; Fri, 24 Feb 2023 14:28:26 +0100 Received: from aspmx1.migadu.com ([2001:41d0:2:bcc0::]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) by mp11.migadu.com with LMTPS id aEkTDnq7+GNuLwEA9RJhRA (envelope-from ) for ; Fri, 24 Feb 2023 14:28:26 +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 F148035FD0 for ; Fri, 24 Feb 2023 14:28:25 +0100 (CET) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pVY7H-0007Uf-Tj; Fri, 24 Feb 2023 08:28:03 -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 1pVY7H-0007UK-27 for bug-guix@gnu.org; Fri, 24 Feb 2023 08:28: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 1pVY7G-0006F2-Ks for bug-guix@gnu.org; Fri, 24 Feb 2023 08:28:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1pVY7G-0005s1-3d for bug-guix@gnu.org; Fri, 24 Feb 2023 08:28:02 -0500 X-Loop: help-debbugs@gnu.org Subject: bug#61722: [PATCH v2] 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 13:28: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: patch To: 61722@debbugs.gnu.org Cc: Josselin Poiret , Tobias Geerinckx-Rice , Maxim Cournoyer , Simon Tournier , mhw@netris.org, Ludovic =?UTF-8?Q?Court=C3=A8s?= , Christopher Baines , Ricardo Wurmus , Mathieu Othacehe Received: via spool by 61722-submit@debbugs.gnu.org id=B61722.167724522922495 (code B ref 61722); Fri, 24 Feb 2023 13:28:02 +0000 Received: (at 61722) by debbugs.gnu.org; 24 Feb 2023 13:27:09 +0000 Received: from localhost ([127.0.0.1]:36294 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVY6O-0005ql-Ny for submit@debbugs.gnu.org; Fri, 24 Feb 2023 08:27:09 -0500 Received: from mail-qt1-f171.google.com ([209.85.160.171]:38788) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1pVY6L-0005qE-QY for 61722@debbugs.gnu.org; Fri, 24 Feb 2023 08:27:07 -0500 Received: by mail-qt1-f171.google.com with SMTP id c18so845139qte.5 for <61722@debbugs.gnu.org>; Fri, 24 Feb 2023 05:27:05 -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=ZKmtD7gym9fRnRLy59I2bPiAlj5zNGbmKfPYhQ474g8=; b=ME+fUCEzwqKp0LxhGsxWw3owrOnpQP1QDQCnGCYm8e6xez60m/xGK1z+osrSUQOD5G 8W8nVX02lnNqqZRSDQIuSz3rYY+Vr+lQ7lUPvAOeq/3MUTbzdAwxdLFwk6vClGBakkax /LiDpIdHlSBFAHV/kZJ/z7TVaNCldhOIyawEOAi3WmtsBzqgBLqqWxctlS4rJt9p9Qje YVeuCMCGn1HIZx0oHNIWDBz2sal/bscRXPnD8UB50AcCM7f5XV979HpLPy1jwAZpt1vg bqPi8Pl2xLy0wWbCbHWT64uTB9ZR9flkHs4As7kQh8YQnjb3GAU0LyW9W+iTjvVc43+X sKQg== 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=ZKmtD7gym9fRnRLy59I2bPiAlj5zNGbmKfPYhQ474g8=; b=kZCL41PIbFxnyOLdxKGS8UCWv88hYrlr1vvPNPHiuT8UG21Y6RCC0NxE3o5oTF9FO2 0Y7gJsIdJDMbJBLbN8/aPvTFYYw3uU1YJWC2wTla6t5K/U6pb2rbNWl1GvIdlmfQ9NuK wrdqRIpowY2t8QRXXubK2yDpXuK6SfxcxNMayRiZKP0WZf3/XD9PkJSw9lndsfhHRp+c 21JByWj1p3l9sSg6QsXEKdEcwstO0SkUoY0fTi3BVPcbn3F+v04bHvdwKBZIX6cNPGJP +fQkPXI/XklcpPyCLdPlJwTgu+bfKycdhM4ZP9+sTF0ChaJItL/l1cHBduUJDf+iznem /W+A== X-Gm-Message-State: AO0yUKXudeklIeUE6+K+Xq+h9OhVeyMPuV7hwNi5rVsCL9yxn9GjYCL+ RfRku7zOHEI7wXa8ZN6p+Z0r21JMEem23ftS X-Google-Smtp-Source: AK7set/537hGr+ai80Ai5YJaM5YeXYj8ZCHqM0RFPpvD5iqJZDkt3Xlj8MZfSOU0zr4mVd8vMORP8Q== X-Received: by 2002:ac8:5c55:0:b0:3b6:694f:d710 with SMTP id j21-20020ac85c55000000b003b6694fd710mr14794098qtj.50.1677245219971; Fri, 24 Feb 2023 05:26:59 -0800 (PST) Received: from localhost.localdomain (dsl-141-27.b2b2c.ca. [66.158.141.27]) by smtp.gmail.com with ESMTPSA id 66-20020a370345000000b0073ba92629e1sm5239412qkd.23.2023.02.24.05.26.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 24 Feb 2023 05:26:59 -0800 (PST) From: Maxim Cournoyer Date: Fri, 24 Feb 2023 08:26:51 -0500 Message-Id: <20230224132652.4617-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: 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-Country: US X-Migadu-Flow: FLOW_IN ARC-Seal: i=1; s=key1; d=yhetil.org; t=1677245306; a=rsa-sha256; cv=none; b=cIPItdvNAkwHQTsB6F+JEHOMhIu2CUgi5PNcFXpCqTzQfB8QFhqGkLnClrR/7XXdoLRzSi nXv4DJe9rPFL+riYzD2BOKD5+5rccsf9rrsX+/NF1MOup4CERKyvUbR04azC715TbtIVbU tcUeEanjVW7OMj5Cv5CK6nJ+1f6h4CQWrc9forub5FzJK9PdtK3WQuDEsLfZoo4CEYBbGc K1mZIHmpTy25UjeqEuFNviJi99HKspaZKbvjlDSTcPe9oPrKaGPTmwiQ8J7JVUEqhQrmX4 AjUFN7JggxHk9xwm/sRVnRw9KUw95dSMA8rDflXIIGrq67p1vqH/bIILXRTeUA== ARC-Authentication-Results: i=1; aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=ME+fUCEz; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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" ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=yhetil.org; s=key1; t=1677245306; 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=ZKmtD7gym9fRnRLy59I2bPiAlj5zNGbmKfPYhQ474g8=; b=f0RV+Zk2JFh3t5bTYThf0x7EJIR8jm7kA+nOl8wUCVPkeRYkzqvHb1KROoVx99EfAUrd9E oVsazhWo/cDQxE9MTizZY17XJuBzCIe10mrdKVEtdh8JecDQJK1zMUCh63+W2UKMeOrAqx +M/kU8qBkbRNlAwLtNTgCFbaqgSAzItd7+SDjyKPGxy1PNC8flfQkssMXdm9ur3BRaDzC0 zvC6JkQvvUVCGR8wad+2z0VQabf+b3rFGBzniQgjbSm2REshGhfe6ibOf5fkD3GTBxYlpv p1GUpm1sOn5pO/vRpSUdXCNtL8atfhlbawrFApGr/AkZHraWfBcW4ITeClvf8g== X-Migadu-Spam-Score: -0.08 X-Spam-Score: -0.08 X-Migadu-Queue-Id: F148035FD0 X-Migadu-Scanner: scn1.migadu.com Authentication-Results: aspmx1.migadu.com; dkim=fail ("headers rsa verify failed") header.d=gmail.com header.s=20210112 header.b=ME+fUCEz; dmarc=fail reason="SPF not aligned (relaxed)" header.from=gmail.com (policy=none); 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" X-TUID: c+zQ8jV47GWP 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. --- Changes in v2: - Use string-utf8-length guix/cpio.scm | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/guix/cpio.scm b/guix/cpio.scm index d4a7d5f1e0..876f61ea3c 100644 --- a/guix/cpio.scm +++ b/guix/cpio.scm @@ -170,7 +170,7 @@ (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 (string-utf8-length file-name)))) (define* (file->cpio-header* file #:optional (file-name file) @@ -182,7 +182,7 @@ (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 (string-utf8-length file-name)))) (define* (special-file->cpio-header* file device-type @@ -201,7 +201,7 @@ (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 (string-utf8-length file-name))) (define %trailer "TRAILER!!!") @@ -237,7 +237,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 (string-utf8-length file) 1) port) (case (mode->type (cpio-header-mode header)) ((regular) @@ -246,7 +246,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