From: Chris Brown <77508021+peakschris@users.noreply.github.com> Date: Fri, 8 Aug 2025 23:41:51 +0000 (-0400) Subject: suggested changes by kientzle X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=da65b39c063c2615a31791269fead1a779a643b7;p=thirdparty%2Flibarchive.git suggested changes by kientzle --- diff --git a/libarchive/archive_read_support_format_mtree.c b/libarchive/archive_read_support_format_mtree.c index 421892ef3..f508a8af1 100644 --- a/libarchive/archive_read_support_format_mtree.c +++ b/libarchive/archive_read_support_format_mtree.c @@ -1073,7 +1073,8 @@ read_mtree(struct archive_read *a, struct mtree *mtree) /* Non-printable characters are not allowed */ for (s = p;s < p + len - 1; s++) { if (!isprint((unsigned char)*s) && *s != '\t') { - fprintf(stderr, "non-printing character 0x%02X\n", (unsigned char)(*s)); + archive_set_error(&a->archive, ARCHIVE_ERRNO_FILE_FORMAT, + "Non-printable character 0x%02X", (unsigned char)(*s)); r = ARCHIVE_FATAL; break; } @@ -2149,14 +2150,12 @@ readline(struct archive_read *a, struct mtree *mtree, char **start, } else if (u[0] == '\\') { if (u[1] == '\n') { /* Trim escaped newline. */ - /* Check if there's a '\r' before the '\n' for CRLF */ - if (u > mtree->line.s && u[-1] == '\r') { - /* Escaped CRLF - remove '\r\\\n' (3 chars) */ - total_size -= 3; - } else { - /* Escaped LF - remove '\\\n' (2 chars) */ - total_size -= 2; - } + total_size -= 2; + mtree->line.s[total_size] = '\0'; + break; + } else if (u[1] == '\r' && u[2] == '\n') { + /* Trim escaped CRLF. */ + total_size -= 3; mtree->line.s[total_size] = '\0'; break; } else if (u[1] != '\0') {