]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
Add checks for proper return value reading past EOF in RAR archives.
authorAndres Mejia <amejia004@gmail.com>
Sat, 26 Jan 2013 17:01:13 +0000 (12:01 -0500)
committerAndres Mejia <amejia004@gmail.com>
Sat, 26 Jan 2013 17:01:13 +0000 (12:01 -0500)
libarchive/test/test_read_format_rar.c

index 7bb89ffc25fa8b65cd6721a35c81f4a763c2ff25..bf107bc661fcadc8e029fa2ebe819f13f0d82d91 100644 (file)
@@ -1237,6 +1237,15 @@ DEFINE_TEST(test_read_format_rar_multivolume_seek_data)
   assertEqualInt(file_size + 20, archive_seek_data(a, 20, SEEK_END));
   assertEqualInt(file_size - 20, archive_seek_data(a, -20, SEEK_END));
 
+  /*
+   * Attempt to read from the end of the file. These should return
+   * 0 for end of file.
+   */
+  assertEqualInt(file_size, archive_seek_data(a, 0, SEEK_END));
+  assertA(0 == archive_read_data(a, buff, sizeof(buff)));
+  assertEqualInt(file_size + 40, archive_seek_data(a, 40, SEEK_CUR));
+  assertA(0 == archive_read_data(a, buff, sizeof(buff)));
+
   /* Seek to the end minus 64 bytes */
   assertA(0 == archive_seek_data(a, 0, SEEK_SET));
   assertA(file_size - (int)sizeof(buff) ==