Fix zipalign alignment error
Problem: Zipalign operates over several false assumptions. First it assumes that zip entries are in the same order in the body and in the Central Direcotry. Second, it assumes there are not space between entries. This makes alignment incorrect when these asserts are not true. Solution: Don't align entries by tracking bias based on input zip entry location. Calculate the expected alignment based on the out- put zip file and correct with extra padding. Fixes: 162117652 Test: Units Tests Change-Id: Ia179338f658cab18a377cba2c7c8e629089a2785
This commit is contained in:
@@ -22,3 +22,29 @@ TEST(Align, Unaligned) {
|
||||
int result = process(src.c_str(), dst.c_str(), 4, true, false, 4096);
|
||||
ASSERT_EQ(0, result);
|
||||
}
|
||||
|
||||
// Align a zip featuring a hole at the beginning. The
|
||||
// hole in the archive is a delete entry in the Central
|
||||
// Directory.
|
||||
TEST(Align, Holes) {
|
||||
const std::string src = GetTestPath("holes.zip");
|
||||
const std::string dst = GetTestPath("holes_out.zip");
|
||||
|
||||
int processed = process(src.c_str(), dst.c_str(), 4, true, false, 4096);
|
||||
ASSERT_EQ(0, processed);
|
||||
|
||||
int verified = verify(dst.c_str(), 4, false, true);
|
||||
ASSERT_EQ(0, verified);
|
||||
}
|
||||
|
||||
// Align a zip where LFH order and CD entries differ.
|
||||
TEST(Align, DifferenteOrders) {
|
||||
const std::string src = GetTestPath("diffOrders.zip");
|
||||
const std::string dst = GetTestPath("diffOrders_out.zip");
|
||||
|
||||
int processed = process(src.c_str(), dst.c_str(), 4, true, false, 4096);
|
||||
ASSERT_EQ(0, processed);
|
||||
|
||||
int verified = verify(dst.c_str(), 4, false, true);
|
||||
ASSERT_EQ(0, verified);
|
||||
}
|
||||
|
Reference in New Issue
Block a user