Hi Maxim,

Maxim Cournoyer <maxim.courno...@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



Reply via email to