]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Test integer parsing at the limits of 64-bit integers.
authorTim Kientzle <kientzle@gmail.com>
Sat, 3 Sep 2011 18:22:57 +0000 (14:22 -0400)
committerTim Kientzle <kientzle@gmail.com>
Sat, 3 Sep 2011 18:22:57 +0000 (14:22 -0400)
SVN-Revision: 3672

libarchive/test/test_read_format_mtree.c
libarchive/test/test_read_format_mtree.mtree.uu

index 1f39e27d174101a170703f0671c7c4f070e4504d..1d2e84152fa928c387df2699c3679eec322a727e 100644 (file)
@@ -33,6 +33,11 @@ test_read_format_mtree1(void)
        struct archive_entry *ae;
        struct archive *a;
        FILE *f;
+       // Compute min and max 64-bit signed twos-complement values
+       // without relying on overflow.  This assumes that long long
+       // is at least 64 bits.
+       const static long long max_int64 = ((((long long)1) << 62) - 1) + (((long long)1) << 62);
+       const static long long min_int64 = - (((long long)1) << 62) - (((long long)1) << 62);
 
        extract_reference_file(reffile);
 
@@ -104,8 +109,32 @@ test_read_format_mtree1(void)
        assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
        assertEqualString(archive_entry_pathname(ae), "notindir");
 
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualString(archive_entry_pathname(ae), "dir2/emptyfile");
+       assertEqualInt(archive_entry_size(ae), 0);
+
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualString(archive_entry_pathname(ae), "dir2/smallfile");
+       assertEqualInt(archive_entry_size(ae), 1);
+
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualString(archive_entry_pathname(ae), "dir2/bigfile");
+       assertEqualInt(archive_entry_size(ae), max_int64);
+
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualString(archive_entry_pathname(ae), "dir2/toobigfile");
+       assertEqualInt(archive_entry_size(ae), max_int64);
+
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualString(archive_entry_pathname(ae), "dir2/veryoldfile");
+       assertEqualInt(archive_entry_mtime(ae), min_int64);
+
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_next_header(a, &ae));
+       assertEqualString(archive_entry_pathname(ae), "dir2/toooldfile");
+       assertEqualInt(archive_entry_mtime(ae), min_int64);
+
        assertEqualIntA(a, ARCHIVE_EOF, archive_read_next_header(a, &ae));
-       assertEqualInt(12, archive_file_count(a));
+       assertEqualInt(18, archive_file_count(a));
        assertEqualInt(ARCHIVE_OK, archive_read_close(a));
        assertEqualInt(ARCHIVE_OK, archive_read_free(a));
 }
index 1634d0015f51b57c1f4d389d44483189ae6b8e57..993875fe70fbe2c5d05411f0524fc29a538d0963 100644 (file)
@@ -1,5 +1,3 @@
-$FreeBSD: head/lib/libarchive/test/test_read_format_mtree.mtree.uu 201247 2009-12-30 05:59:21Z kientzle $
-
 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
@@ -8,6 +6,13 @@ 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"@``
+M;&QI;F1I<C(@;6]D93TP-C0T"F1I<C(O96UP='EF:6QE('1Y<&4]9FEL92!S
+M:7IE/3!X,`ID:7(R+W-M86QL9FEL92!T>7!E/69I;&4@<VEZ93TP,#`P,#`P
+M,#`P,#`P,#`P,#`P,#`P,#`P,#`P,#$*9&ER,B]B:6=F:6QE('1Y<&4]9FEL
+M92!S:7IE/3DR,C,S-S(P,S8X-30W-S4X,#<*9&ER,B]T;V]B:6=F:6QE('1Y
+M<&4]9FEL92!S:7IE/3DR,C,S-S(P,S8X-30W-S4X,#@*9&ER,B]V97)Y;VQD
+M9FEL92!T>7!E/69I;&4@=&EM93TM.3(R,S,W,C`S-C@U-#<W-3@P.`ID:7(R
+M+W1O;V]L9&9I;&4@='EP93UF:6QE('1I;64]+3DR,C,S-S(P,S8X-30W-S4X
+$,#D*"@``
 `
 end