Merge "libziparchive: fix issue with a directory with one file"
This commit is contained in:
commit
b054582b90
Binary file not shown.
|
@ -824,7 +824,7 @@ static int32_t FindEntry(const ZipArchive* archive, const int ent,
|
|||
// name in the central directory.
|
||||
if (lfh->file_name_length == nameLen) {
|
||||
const off64_t name_offset = local_header_offset + sizeof(LocalFileHeader);
|
||||
if (name_offset + lfh->file_name_length >= cd_offset) {
|
||||
if (name_offset + lfh->file_name_length > cd_offset) {
|
||||
ALOGW("Zip: Invalid declared length");
|
||||
return kInvalidOffset;
|
||||
}
|
||||
|
|
|
@ -171,6 +171,22 @@ TEST(ziparchive, FindEntry) {
|
|||
CloseArchive(handle);
|
||||
}
|
||||
|
||||
TEST(ziparchive, TestInvalidDeclaredLength) {
|
||||
ZipArchiveHandle handle;
|
||||
ASSERT_EQ(0, OpenArchiveWrapper("declaredlength.zip", &handle));
|
||||
|
||||
void* iteration_cookie;
|
||||
ASSERT_EQ(0, StartIteration(handle, &iteration_cookie, NULL));
|
||||
|
||||
ZipEntryName name;
|
||||
ZipEntry data;
|
||||
|
||||
ASSERT_EQ(Next(iteration_cookie, &data, &name), 0);
|
||||
ASSERT_EQ(Next(iteration_cookie, &data, &name), 0);
|
||||
|
||||
CloseArchive(handle);
|
||||
}
|
||||
|
||||
TEST(ziparchive, ExtractToMemory) {
|
||||
ZipArchiveHandle handle;
|
||||
ASSERT_EQ(0, OpenArchiveWrapper(kValidZip, &handle));
|
||||
|
|
Loading…
Reference in New Issue