From 94b616c830a2895d30234e711e9ea8d62714b3f7 Mon Sep 17 00:00:00 2001 From: Andres Mejia Date: Sat, 26 Jan 2013 12:01:13 -0500 Subject: [PATCH] Add checks for proper return value reading past EOF in RAR archives. --- libarchive/test/test_read_format_rar.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/libarchive/test/test_read_format_rar.c b/libarchive/test/test_read_format_rar.c index 7bb89ffc2..bf107bc66 100644 --- a/libarchive/test/test_read_format_rar.c +++ b/libarchive/test/test_read_format_rar.c @@ -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) == -- 2.47.2