From 81825840d3bd3afa8e6bb6bcf4d3c3e009ed849f Mon Sep 17 00:00:00 2001 From: Tim Kientzle Date: Sun, 1 Nov 2009 17:27:45 -0500 Subject: [PATCH] Fuzz the mtree reader: Extract the sample file and add it to the list of fuzz-test inputs. SVN-Revision: 1573 --- libarchive/test/test_fuzz.c | 13 +++++---- libarchive/test/test_read_format_mtree.c | 28 +++---------------- .../test/test_read_format_mtree.mtree.uu | 11 ++++++++ 3 files changed, 22 insertions(+), 30 deletions(-) create mode 100644 libarchive/test/test_read_format_mtree.mtree.uu diff --git a/libarchive/test/test_fuzz.c b/libarchive/test/test_fuzz.c index 07d8e4c78..71b020c78 100644 --- a/libarchive/test/test_fuzz.c +++ b/libarchive/test/test_fuzz.c @@ -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} diff --git a/libarchive/test/test_read_format_mtree.c b/libarchive/test/test_read_format_mtree.c index 87205bee5..b4717dc98 100644 --- a/libarchive/test/test_read_format_mtree.c +++ b/libarchive/test/test_read_format_mtree.c @@ -25,35 +25,16 @@ #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 index 000000000..d58220544 --- /dev/null +++ b/libarchive/test/test_read_format_mtree.mtree.uu @@ -0,0 +1,11 @@ +begin 644 test_read_format_mtree.mtree +M(VUT7!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;F1I7!E/61I<@H@(&EN9&ER,V(@ +M='EP93UF:6QE"B`@+BX*("XN"FYO=&EN9&ER('1Y<&4]9FEL90ID:7(R+V9U +3;&QI;F1I