From: datauwu Date: Mon, 6 Jul 2026 13:51:15 +0000 (+0800) Subject: tar: fix 1-byte OOB read in SUN.holesdata parsing X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=40b92de1def08e4fc319d55702785f82cedb7ef2;p=thirdparty%2Flibarchive.git tar: fix 1-byte OOB read in SUN.holesdata parsing header_pax_extension() passes PAX attribute values without the trailing newline to pax_attribute(). The SUN.holesdata parser read one byte past the supplied value when the last numeric field ended at the value boundary. Handle length == 0 before checking *e. --- diff --git a/libarchive/archive_read_support_format_tar.c b/libarchive/archive_read_support_format_tar.c index e07cfdb63..1c0441db6 100644 --- a/libarchive/archive_read_support_format_tar.c +++ b/libarchive/archive_read_support_format_tar.c @@ -3448,13 +3448,10 @@ pax_attribute_SUN_holesdata(struct archive_read *a, struct tar *tar, return (ARCHIVE_FATAL); tar->sparse_last->hole = hole; } - if (length == 0 || *e == '\n') { - if (length == 0 && *e == '\n') { - return (ARCHIVE_OK); - } else { - return (ARCHIVE_WARN); - } - } + if (length == 0) + return (ARCHIVE_OK); + if (*e == '\n') + return (ARCHIVE_WARN); p = e + 1; length--; hole = hole == 0;