From: Martin Matuska Date: Thu, 9 Jan 2020 11:36:59 +0000 (+0100) Subject: LHA reader UTF16: dirSep must match machine endianess X-Git-Tag: v3.4.2~47 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=96970037ca0822e64ac14146c44679d02d4fee9f;p=thirdparty%2Flibarchive.git LHA reader UTF16: dirSep must match machine endianess --- diff --git a/libarchive/archive_read_support_format_lha.c b/libarchive/archive_read_support_format_lha.c index aa115f87d..bff0f01f4 100644 --- a/libarchive/archive_read_support_format_lha.c +++ b/libarchive/archive_read_support_format_lha.c @@ -1293,14 +1293,19 @@ lha_read_file_extended_header(struct archive_read *a, struct lha *lha, * Convert directory delimiter from 0xFFFF * to '/' for local system. */ - const uint16_t dirSep = '/'; /* UTF-16LE */ + uint16_t dirSep; + uint16_t d = 1; + if (archive_be16dec(&d) == 1) + dirSep = 0x2F00; + else + dirSep = 0x002F; + /* UTF-16LE character */ uint16_t *utf16name = (uint16_t *)lha->dirname.s; for (i = 0; i < lha->dirname.length / 2; i++) { if (utf16name[i] == 0xFFFF) { - archive_le16enc(utf16name + i, - dirSep); + utf16name[i] = dirSep; } } /* Is last character directory separator? */