]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Fuzz the mtree reader: Extract the sample file and add it to the list of fuzz-test...
authorTim Kientzle <kientzle@gmail.com>
Sun, 1 Nov 2009 22:27:45 +0000 (17:27 -0500)
committerTim Kientzle <kientzle@gmail.com>
Sun, 1 Nov 2009 22:27:45 +0000 (17:27 -0500)
SVN-Revision: 1573

libarchive/test/test_fuzz.c
libarchive/test/test_read_format_mtree.c
libarchive/test/test_read_format_mtree.mtree.uu [new file with mode: 0644]

index 07d8e4c7810cba28a14f541f4be6d4b86423acb3..71b020c782e6cf367f11a989d0a8b2d93d3eeaf3 100644 (file)
@@ -50,19 +50,20 @@ static struct {
        int uncompress; /* If 1, decompress the file before fuzzing. */
        const char *name;
 } files[] = {
-       {0, "test_fuzz_1.iso.Z"},
+       {0, "test_fuzz_1.iso.Z"}, /* Exercise compress decompressor. */
        {1, "test_fuzz_1.iso.Z"},
-       {0, "test_compat_bzip2_1.tbz"}, /* Fuzz the compressed file. */
-       {1, "test_compat_bzip2_1.tbz"}, /* Fuzz the uncompressed file. */
+       {0, "test_compat_bzip2_1.tbz"}, /* Exercise bzip2 decompressor. */
+       {1, "test_compat_bzip2_1.tbz"},
        {0, "test_compat_gtar_1.tar"},
-       {0, "test_compat_gzip_1.tgz"},
-       {0, "test_compat_gzip_2.tgz"},
+       {0, "test_compat_gzip_1.tgz"}, /* Exercise gzip decompressor. */
+       {0, "test_compat_gzip_2.tgz"}, /* Exercise gzip decompressor. */
        {0, "test_compat_tar_hardlink_1.tar"},
-       {0, "test_compat_xz_1.txz"},
+       {0, "test_compat_xz_1.txz"}, /* Exercise xz decompressor. */
        {0, "test_compat_zip_1.zip"},
        {0, "test_read_format_ar.ar"},
        {0, "test_read_format_cpio_bin_be.cpio"},
        {0, "test_read_format_gtar_sparse_1_17_posix10_modified.tar"},
+       {0, "test_read_format_mtree.mtree"},
        {0, "test_read_format_tar_empty_filename.tar"},
        {0, "test_read_format_zip.zip"},
        {1, NULL}
index 87205bee5c3d4aa932bef00574ad2b1afcf59e4a..b4717dc9835a8b61a14e9179b14d8734f562842f 100644 (file)
 #include "test.h"
 __FBSDID("$FreeBSD: src/lib/libarchive/test/test_read_format_mtree.c,v 1.4 2008/09/18 04:13:36 kientzle Exp $");
 
-/* Single entry with a hardlink. */
-static unsigned char archive[] = {
-       "#mtree\n"
-       "file type=file uid=18 mode=0123 size=3\n"
-       "dir type=dir\n"
-       " file\\040with\\040space type=file uid=18\n"
-       " ..\n"
-       "file\\040with\\040space type=file\n"
-       "dir2 type=dir\n"
-       " dir3a type=dir\n"
-       "  indir3a type=file\n"
-       "dir2/fullindir2 type=file mode=0777\n"
-       "  ..\n"
-       " indir2 type=file\n"
-       " dir3b type=dir\n"
-       "  indir3b type=file\n"
-       "  ..\n"
-       " ..\n"
-       "notindir type=file\n"
-       "dir2/fullindir2 mode=0644\n"
-};
-
 DEFINE_TEST(test_read_format_mtree)
 {
+       const char reffile[] = "test_read_format_mtree.mtree";
        char buff[16];
        struct archive_entry *ae;
        struct archive *a;
        FILE *f;
 
+       extract_reference_file(reffile);
+
        /*
         * An access error occurred on some platform when mtree
         * format handling open a directory. It is for through
@@ -68,8 +49,7 @@ DEFINE_TEST(test_read_format_mtree)
            archive_read_support_compression_all(a));
        assertEqualIntA(a, ARCHIVE_OK,
            archive_read_support_format_all(a));
-       assertEqualIntA(a, ARCHIVE_OK,
-           archive_read_open_memory(a, archive, sizeof(archive)));
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_open_file(a, reffile, 11));
 
        /*
         * Read "file", whose data is available on disk.
diff --git a/libarchive/test/test_read_format_mtree.mtree.uu b/libarchive/test/test_read_format_mtree.mtree.uu
new file mode 100644 (file)
index 0000000..d582205
--- /dev/null
@@ -0,0 +1,11 @@
+begin 644 test_read_format_mtree.mtree
+M(VUT<F5E"F9I;&4@='EP93UF:6QE('5I9#TQ."!M;V1E/3`Q,C,@<VEZ93TS
+M"F1I<B!T>7!E/61I<@H@9FEL95PP-#!W:71H7#`T,'-P86-E('1Y<&4]9FEL
+M92!U:60],3@*("XN"F9I;&5<,#0P=VET:%PP-#!S<&%C92!T>7!E/69I;&4*
+M9&ER,B!T>7!E/61I<@H@9&ER,V$@='EP93UD:7(*("!I;F1I<C-A('1Y<&4]
+M9FEL90ID:7(R+V9U;&QI;F1I<C(@='EP93UF:6QE(&UO9&4],#<W-PH@("XN
+M"B!I;F1I<C(@='EP93UF:6QE"B!D:7(S8B!T>7!E/61I<@H@(&EN9&ER,V(@
+M='EP93UF:6QE"B`@+BX*("XN"FYO=&EN9&ER('1Y<&4]9FEL90ID:7(R+V9U
+3;&QI;F1I<C(@;6]D93TP-C0T"@``
+`
+end