From: Tim Kientzle Date: Sun, 6 Dec 2009 07:36:55 +0000 (-0500) Subject: Further refine the index number checks for cpio and extend X-Git-Tag: v2.8.0~115 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c840fa440dcc7ee67d902cb85c560528178eb3da;p=thirdparty%2Flibarchive.git Further refine the index number checks for cpio and extend them to newc as well. This is in preparation for work to generate synthetic index numbers when writing cpio formats, in order to avoid truncation problems. SVN-Revision: 1704 --- diff --git a/libarchive/test/test_write_format_cpio_newc.c b/libarchive/test/test_write_format_cpio_newc.c index 0843ee6cf..d0d5ac8c3 100644 --- a/libarchive/test/test_write_format_cpio_newc.c +++ b/libarchive/test/test_write_format_cpio_newc.c @@ -52,7 +52,7 @@ DEFINE_TEST(test_write_format_cpio_newc) { struct archive *a; struct archive_entry *entry; - char *buff, *e; + char *buff, *e, *file; size_t buffsize = 100000; size_t used; @@ -124,9 +124,10 @@ DEFINE_TEST(test_write_format_cpio_newc) e = buff; /* First entry is "file" */ + file = e; assert(is_hex(e, 110)); /* Entire header is hex digits. */ assertEqualMem(e + 0, "070701", 6); /* Magic */ - assertEqualMem(e + 6, "00000059", 8); /* ino */ + assert(memcmp(e + 6, "00000000", 8) != 0); /* ino != 0 */ assertEqualMem(e + 14, "000081b4", 8); /* Mode */ assertEqualMem(e + 22, "00000050", 8); /* uid */ assertEqualMem(e + 30, "0000005a", 8); /* gid */ @@ -167,7 +168,8 @@ DEFINE_TEST(test_write_format_cpio_newc) /* Third entry is "lnk" */ assert(is_hex(e, 110)); /* Entire header is hex digits. */ assertEqualMem(e + 0, "070701", 6); /* Magic */ - assertEqualMem(e + 6, "00000058", 8); /* ino */ + assert(memcmp(e + 6, file + 6, 8) != 0); /* ino != file ino */ + assert(memcmp(e + 6, "00000000", 8) != 0); /* ino != 0 */ assertEqualMem(e + 14, "0000a1b4", 8); /* Mode */ assertEqualMem(e + 22, "00000053", 8); /* uid */ assertEqualMem(e + 30, "0000005d", 8); /* gid */ diff --git a/libarchive/test/test_write_format_cpio_odc.c b/libarchive/test/test_write_format_cpio_odc.c index dc4b74503..c06634da8 100644 --- a/libarchive/test/test_write_format_cpio_odc.c +++ b/libarchive/test/test_write_format_cpio_odc.c @@ -139,7 +139,7 @@ DEFINE_TEST(test_write_format_cpio_odc) assert(is_octal(e, 76)); /* Entire header is octal digits. */ assertEqualMem(e + 0, "070707", 6); /* Magic */ assertEqualMem(e + 6, "000014", 6); /* dev */ - /* assertEqualMem(e + 12, "000131", 6); *//* ino */ + assert(memcmp(e + 12, "000000", 6) != 0); /* ino must be != 0 */ assertEqualMem(e + 18, "100664", 6); /* Mode */ assertEqualMem(e + 24, "000120", 6); /* uid */ assertEqualMem(e + 30, "000132", 6); /* gid */ @@ -189,7 +189,8 @@ DEFINE_TEST(test_write_format_cpio_odc) assert(is_octal(e, 76)); /* Entire header is octal digits. */ assertEqualMem(e + 0, "070707", 6); /* Magic */ assertEqualMem(e + 6, "000014", 6); /* dev */ - assert(memcmp(e + 12, file + 12, 6) != 0); /* ino must not match */ + assert(memcmp(e + 12, file + 12, 6) != 0); /* ino must != file ino */ + assert(memcmp(e + 12, "000000", 6) != 0); /* ino must != 0 */ assertEqualMem(e + 18, "120664", 6); /* Mode */ assertEqualMem(e + 24, "000130", 6); /* uid */ assertEqualMem(e + 30, "000142", 6); /* gid */