summaryrefslogtreecommitdiffstats
path: root/libziparchive/zip_archive.cc
diff options
context:
space:
mode:
authorBrian Carlstrom <bdc@google.com>2014-01-24 18:26:15 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2014-01-24 18:26:15 +0000
commite490b6155e4e669dc594c36903cbf91e79a43efe (patch)
treebae8c388cad61be269f004a1f60664138671d405 /libziparchive/zip_archive.cc
parentc3af60aff5d097c717b19721f143499891d5ca3d (diff)
parent722357738fd8dea75d147dbc8d8d59c72c7ec7dd (diff)
downloadsystem_core-e490b6155e4e669dc594c36903cbf91e79a43efe.zip
system_core-e490b6155e4e669dc594c36903cbf91e79a43efe.tar.gz
system_core-e490b6155e4e669dc594c36903cbf91e79a43efe.tar.bz2
am 72235773: am e18df357: am 794b587b: Merge "Fix entry handling for 0 length entries."
* commit '722357738fd8dea75d147dbc8d8d59c72c7ec7dd': Fix entry handling for 0 length entries.
Diffstat (limited to 'libziparchive/zip_archive.cc')
-rw-r--r--libziparchive/zip_archive.cc9
1 files changed, 8 insertions, 1 deletions
diff --git a/libziparchive/zip_archive.cc b/libziparchive/zip_archive.cc
index 8436d49..a23d4ae 100644
--- a/libziparchive/zip_archive.cc
+++ b/libziparchive/zip_archive.cc
@@ -756,7 +756,7 @@ static int32_t FindEntry(const ZipArchive* archive, const int ent,
}
const off64_t data_offset = local_header_offset + kLFHLen + lfhNameLen + lfhExtraLen;
- if (data_offset >= cd_offset) {
+ if (data_offset > cd_offset) {
ALOGW("Zip: bad data offset %lld in zip", (off64_t) data_offset);
return kInvalidOffset;
}
@@ -1021,6 +1021,13 @@ int32_t ExtractEntryToFile(ZipArchiveHandle handle,
return kIoError;
}
+ // Don't attempt to map a region of length 0. We still need the
+ // ftruncate() though, since the API guarantees that we will truncate
+ // the file to the end of the uncompressed output.
+ if (declared_length == 0) {
+ return 0;
+ }
+
android::FileMap* map = MapFileSegment(fd, current_offset, declared_length,
false, kTempMappingFileName);
if (map == NULL) {