From d5715c5d2de0a92e1b5c1feb9f19ecfe361e291f Mon Sep 17 00:00:00 2001 From: Narayan Kamath Date: Wed, 4 Oct 2017 18:23:09 +0100 Subject: [PATCH] Revert "Fix full-eng build breakage due to dbacd826a100f2c." This reverts commit 6e39c88b1e4ea00e76e0d66e764a63b5d8c883fc. This change should not have automerged to nyc-dev. Still investigating why that's the case. Test: make --- libziparchive/zip_archive_test.cc | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/libziparchive/zip_archive_test.cc b/libziparchive/zip_archive_test.cc index 46ca67ec5..b8db6a4d3 100644 --- a/libziparchive/zip_archive_test.cc +++ b/libziparchive/zip_archive_test.cc @@ -613,7 +613,7 @@ TEST(ziparchive, StreamUncompressedBadCrc) { // Manual changes : // [2] = 0xff // Corrupt the LFH signature of entry 0. // [3] = 0xff // Corrupt the LFH signature of entry 0. -static const uint8_t kZipFileWithBrokenLfhSignature[] = { +static const std::vector kZipFileWithBrokenLfhSignature{ //[lfh-sig-----------], [lfh contents--------------------------------- 0x50, 0x4b, 0xff, 0xff, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x77, 0x80, //-------------------------------------------------------------------- @@ -644,16 +644,12 @@ static const uint8_t kZipFileWithBrokenLfhSignature[] = { 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x00, 0x00}; TEST(ziparchive, BrokenLfhSignature) { - char kTempFilePattern[] = "zip_archive_input_XXXXXX"; - int fd = make_temporary_file(kTempFilePattern); - ASSERT_NE(-1, fd); - - ASSERT_EQ(static_cast(sizeof(kZipFileWithBrokenLfhSignature)), - TEMP_FAILURE_RETRY(write(fd, kZipFileWithBrokenLfhSignature, - sizeof(kZipFileWithBrokenLfhSignature)))); + TemporaryFile tmp_file; + ASSERT_NE(-1, tmp_file.fd); + ASSERT_TRUE(android::base::WriteFully(tmp_file.fd, &kZipFileWithBrokenLfhSignature[0], + kZipFileWithBrokenLfhSignature.size())); ZipArchiveHandle handle; - ASSERT_EQ(-1, OpenArchiveFd(fd, "LeadingNonZipBytes", &handle)); - close(fd); + ASSERT_EQ(-1, OpenArchiveFd(tmp_file.fd, "LeadingNonZipBytes", &handle)); } int main(int argc, char** argv) {