From: Mark H Weaver <mhw@netris.org>
To: Maxim Cournoyer <maxim.cournoyer@gmail.com>, 61722@debbugs.gnu.org
Cc: "Josselin Poiret" <dev@jpoiret.xyz>,
"Christopher Baines" <mail@cbaines.net>,
"Maxim Cournoyer" <maxim.cournoyer@gmail.com>,
"Simon Tournier" <zimon.toutoune@gmail.com>,
"Mathieu Othacehe" <othacehe@gnu.org>,
"Ludovic Courtès" <ludo@gnu.org>,
"Tobias Geerinckx-Rice" <me@tobias.gr>,
"Ricardo Wurmus" <rekado@elephly.net>
Subject: bug#61722: [PATCH] cpio: Properly handle Unicode characters in file names.
Date: Fri, 24 Feb 2023 06:46:21 -0500 [thread overview]
Message-ID: <87bklj70bb.fsf@netris.org> (raw)
In-Reply-To: <20230224045402.26444-1-maxim.cournoyer@gmail.com>
Hi Maxim,
Maxim Cournoyer <maxim.cournoyer@gmail.com> writes:
> Fixes <https://issues.guix.gnu.org/61722>.
>
> * 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)))))
(string-utf8-length file-name) would produce the same result more
efficiently.
Regards,
Mark
next prev parent reply other threads:[~2023-02-24 11:48 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-23 3:14 bug#61722: (guix cpio) produces corrupted archives when there are non-ASCII filenames Maxim Cournoyer
2023-02-24 4:54 ` bug#61722: [PATCH] cpio: Properly handle Unicode characters in file names Maxim Cournoyer
2023-02-24 11:46 ` Mark H Weaver [this message]
2023-02-24 13:26 ` bug#61722: [PATCH v2] " Maxim Cournoyer
2023-02-25 19:52 ` bug#61722: (guix cpio) produces corrupted archives when there are non-ASCII filenames Maxim Cournoyer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87bklj70bb.fsf@netris.org \
--to=mhw@netris.org \
--cc=61722@debbugs.gnu.org \
--cc=dev@jpoiret.xyz \
--cc=ludo@gnu.org \
--cc=mail@cbaines.net \
--cc=maxim.cournoyer@gmail.com \
--cc=me@tobias.gr \
--cc=othacehe@gnu.org \
--cc=rekado@elephly.net \
--cc=zimon.toutoune@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/guix.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.