File 0003-LHA-reader-UTF16-dirSep-must-match-machine-endianess.patch of Package libarchive

From 53da5cc81976d3e27be9e27f4beb964919c2084e Mon Sep 17 00:00:00 2001
From: Martin Matuska <martin@matuska.org>
Date: Thu, 9 Jan 2020 12:36:59 +0100
Subject: [PATCH 3/3] LHA reader UTF16: dirSep must match machine endianess

---
 libarchive/archive_read_support_format_lha.c | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/libarchive/archive_read_support_format_lha.c b/libarchive/archive_read_support_format_lha.c
index aa115f8..bff0f01 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? */
-- 
2.25.0
openSUSE Build Service is sponsored by