summaryrefslogtreecommitdiff
path: root/base/mapped_file_test.cpp
diff options
context:
space:
mode:
authorElliott Hughes <enh@google.com>2019-12-16 16:16:16 -0800
committerElliott Hughes <enh@google.com>2019-12-17 08:39:09 -0800
commitfba2a1a1ec9bdce1ba2988250318d854c4e37957 (patch)
treeda3ab50e39caca2204b0e54f15b0f7f3f7d7a7eb /base/mapped_file_test.cpp
parent5a07ae1422f932bc8e2c7faa037508d80f246d0d (diff)
Fix SEGV in libziparchive with malformed zip file.
d77c99ebc3d896501531e9522b690c4a0e971aff changed MappedFile to return a bogus zero-length mapping on failure rather than nullptr. None of the calling code was changed, though, and it seems like doing so would be a bad idea. Revert that part of the change. Add missing tests, and tidy up some of the logging. Also remove single-use or obfuscatory constants from the tests. The new "empty.zip" was created by using zip(1) to create a zip file with one entry, then using `zip -d` to remove it. The new "zero-size-cd.zip" was created by using zip(1) to create a zip file containing a single empty file, and then hex editing the two byte "size of the central directory" field in the "end of central directory record" structure at the end of the file. (This is equivalent to, but much smaller than, the example zip file provided by the bug reporter.) Bug: http://b/145925341 Test: treehugger Change-Id: Iff64673bce7dae886ccbc9dd6c2bbe18de19f9d2
Diffstat (limited to 'base/mapped_file_test.cpp')
-rw-r--r--base/mapped_file_test.cpp2
1 files changed, 0 insertions, 2 deletions
diff --git a/base/mapped_file_test.cpp b/base/mapped_file_test.cpp
index 3629108c9..d21703c78 100644
--- a/base/mapped_file_test.cpp
+++ b/base/mapped_file_test.cpp
@@ -44,8 +44,6 @@ TEST(mapped_file, zero_length_mapping) {
ASSERT_TRUE(tf.fd != -1);
auto m = android::base::MappedFile::FromFd(tf.fd, 4096, 0, PROT_READ);
- ASSERT_NE(nullptr, m);
- EXPECT_TRUE((bool)*m);
EXPECT_EQ(0u, m->size());
EXPECT_NE(nullptr, m->data());
}