Fix the start offset when calculating the signature header value

This commit is contained in:
Ben Gruver 2013-11-10 21:44:54 -08:00
parent 20f675b86b
commit b49126325f
2 changed files with 8 additions and 2 deletions

View File

@ -51,9 +51,15 @@ public class HeaderItem {
public static final int CHECKSUM_OFFSET = 8; public static final int CHECKSUM_OFFSET = 8;
// this is the start of the checksumed data
public static final int CHECKSUM_DATA_START_OFFSET = 12;
public static final int SIGNATURE_OFFSET = 12; public static final int SIGNATURE_OFFSET = 12;
public static final int SIGNATURE_SIZE = 20; public static final int SIGNATURE_SIZE = 20;
// this is the start of the sha-1 hashed data
public static final int SIGNATURE_DATA_START_OFFSET = 32;
public static final int FILE_SIZE_OFFSET = 32;
public static final int HEADER_SIZE_OFFSET = 36; public static final int HEADER_SIZE_OFFSET = 36;
public static final int ENDIAN_TAG_OFFSET = 40; public static final int ENDIAN_TAG_OFFSET = 40;

View File

@ -236,7 +236,7 @@ public abstract class DexWriter<
} }
byte[] buffer = new byte[4 * 1024]; byte[] buffer = new byte[4 * 1024];
InputStream input = dataStore.readAt(HeaderItem.HEADER_SIZE_OFFSET); InputStream input = dataStore.readAt(HeaderItem.SIGNATURE_DATA_START_OFFSET);
int bytesRead = input.read(buffer); int bytesRead = input.read(buffer);
while (bytesRead >= 0) { while (bytesRead >= 0) {
md.update(buffer, 0, bytesRead); md.update(buffer, 0, bytesRead);
@ -258,7 +258,7 @@ public abstract class DexWriter<
Adler32 a32 = new Adler32(); Adler32 a32 = new Adler32();
byte[] buffer = new byte[4 * 1024]; byte[] buffer = new byte[4 * 1024];
InputStream input = dataStore.readAt(HeaderItem.SIGNATURE_OFFSET); InputStream input = dataStore.readAt(HeaderItem.CHECKSUM_DATA_START_OFFSET);
int bytesRead = input.read(buffer); int bytesRead = input.read(buffer);
while (bytesRead >= 0) { while (bytesRead >= 0) {
a32.update(buffer, 0, bytesRead); a32.update(buffer, 0, bytesRead);