]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
suggested changes by kientzle
authorChris Brown <77508021+peakschris@users.noreply.github.com>
Fri, 8 Aug 2025 23:41:51 +0000 (19:41 -0400)
committerChris Brown <77508021+peakschris@users.noreply.github.com>
Fri, 8 Aug 2025 23:41:51 +0000 (19:41 -0400)
libarchive/archive_read_support_format_mtree.c

index 421892ef3d9f40734dcd54ca02611661e7106ad2..f508a8af153d98adb21a7b5d24974469beef4486 100644 (file)
@@ -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') {