]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
The fuzz tester uncovered an infinite loop in the recovery code that
authorTim Kientzle <kientzle@gmail.com>
Sun, 29 Nov 2009 23:09:46 +0000 (18:09 -0500)
committerTim Kientzle <kientzle@gmail.com>
Sun, 29 Nov 2009 23:09:46 +0000 (18:09 -0500)
searches forward for the next undamaged cpio header.  This occurred
when the number of bytes returned by the next read operation happened
to be exactly the size of a cpio header.  In this case, an off-by-one
error caused this code to decide that it didn't have enough bytes to
examine and then to loop around and ask for the exact same bytes again.

SVN-Revision: 1686

libarchive/archive_read_support_format_cpio.c

index 3c96ecfce1349bcd07700ecda2c869741653bdf2..2cb719b3ec183d16623094d127cad54c751ecac1 100644 (file)
@@ -356,7 +356,7 @@ find_newc_header(struct archive_read *a)
                 * Scan ahead until we find something that looks
                 * like an odc header.
                 */
-               while (p + sizeof(struct cpio_newc_header) < q) {
+               while (p + sizeof(struct cpio_newc_header) <= q) {
                        switch (p[5]) {
                        case '1':
                        case '2':
@@ -490,7 +490,7 @@ find_odc_header(struct archive_read *a)
                 * Scan ahead until we find something that looks
                 * like an odc header.
                 */
-               while (p + sizeof(struct cpio_odc_header) < q) {
+               while (p + sizeof(struct cpio_odc_header) <= q) {
                        switch (p[5]) {
                        case '7':
                                if (memcmp("070707", p, 6) == 0