Fix bug in APK entry alignment.
APK entry alignment logic assumes that input entries have zero-length comment and extra fields. When the assumption is broken, the logic silently breaks alignment of output entries. This happens, for example, when the APK to be signed is already aligned and thus may contain entries with non-empty extra fields. Given that APKs are not supposed to use comment and extra fields for anything useful and given that this signer already discards comment and extra fields of compressed entries, this change makes the signer discard comment and extra fields of STORED input entries as well. This unbreaks the existing alignment logic. Bug: 27814973 Change-Id: I8242b037e21ba7bcf45d0fe2afc8bfc47f1ec314
This commit is contained in:
parent
37aa85e8bb
commit
37a0ecd329
|
@ -544,6 +544,11 @@ class SignApk {
|
||||||
// Preserve the STORED method of the input entry.
|
// Preserve the STORED method of the input entry.
|
||||||
outEntry = new JarEntry(inEntry);
|
outEntry = new JarEntry(inEntry);
|
||||||
outEntry.setTime(timestamp);
|
outEntry.setTime(timestamp);
|
||||||
|
// Discard comment and extra fields of this entry to
|
||||||
|
// simplify alignment logic below and for consistency with
|
||||||
|
// how compressed entries are handled later.
|
||||||
|
outEntry.setComment(null);
|
||||||
|
outEntry.setExtra(null);
|
||||||
|
|
||||||
// 'offset' is the offset into the file at which we expect
|
// 'offset' is the offset into the file at which we expect
|
||||||
// the file data to begin. This is the value we need to
|
// the file data to begin. This is the value we need to
|
||||||
|
|
Loading…
Reference in New Issue