diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2010-01-13 00:18:06 +0100 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2010-01-13 00:18:06 +0100 |
commit | b765729081399b6826c9d45d77c9c58ca2f32816 (patch) | |
tree | f96c3fc70526d98cb381629774f2f290fee2b168 | |
parent | eclair snapshot (diff) | |
download | android_bootable_recovery-b765729081399b6826c9d45d77c9c58ca2f32816.tar android_bootable_recovery-b765729081399b6826c9d45d77c9c58ca2f32816.tar.gz android_bootable_recovery-b765729081399b6826c9d45d77c9c58ca2f32816.tar.bz2 android_bootable_recovery-b765729081399b6826c9d45d77c9c58ca2f32816.tar.lz android_bootable_recovery-b765729081399b6826c9d45d77c9c58ca2f32816.tar.xz android_bootable_recovery-b765729081399b6826c9d45d77c9c58ca2f32816.tar.zst android_bootable_recovery-b765729081399b6826c9d45d77c9c58ca2f32816.zip |
Diffstat (limited to '')
-rw-r--r-- | mtdutils/mtdutils.c | 17 | ||||
-rw-r--r-- | verifier.c | 2 |
2 files changed, 13 insertions, 6 deletions
diff --git a/mtdutils/mtdutils.c b/mtdutils/mtdutils.c index fc067669b..8d3252059 100644 --- a/mtdutils/mtdutils.c +++ b/mtdutils/mtdutils.c @@ -283,19 +283,26 @@ static int read_block(const MtdPartition *partition, int fd, char *data) return -1; } - off_t pos = lseek(fd, 0, SEEK_CUR); + loff_t pos = lseek64(fd, 0, SEEK_CUR); + ssize_t size = partition->erase_size; + int mgbb; + while (pos + size <= (int) partition->size) { - if (lseek(fd, pos, SEEK_SET) != pos || read(fd, data, size) != size) { - fprintf(stderr, "mtd: read error at 0x%08lx (%s)\n", + if (lseek64(fd, pos, SEEK_SET) != pos || read(fd, data, size) != size) { + fprintf(stderr, "mtd: read error at 0x%08llx (%s)\n", pos, strerror(errno)); } else if (ioctl(fd, ECCGETSTATS, &after)) { fprintf(stderr, "mtd: ECCGETSTATS error (%s)\n", strerror(errno)); return -1; } else if (after.failed != before.failed) { - fprintf(stderr, "mtd: ECC errors (%d soft, %d hard) at 0x%08lx\n", + fprintf(stderr, "mtd: ECC errors (%d soft, %d hard) at 0x%08llx\n", after.corrected - before.corrected, after.failed - before.failed, pos); + } else if ((mgbb = ioctl(fd, MEMGETBADBLOCK, &pos))) { + fprintf(stderr, + "mtd: MEMGETBADBLOCK returned %d at 0x%08llx (errno=%d)\n", + mgbb, pos, errno); } else { int i; for (i = 0; i < size; ++i) { @@ -303,7 +310,7 @@ static int read_block(const MtdPartition *partition, int fd, char *data) return 0; // Success! } } - fprintf(stderr, "mtd: read all-zero block at 0x%08lx; skipping\n", + fprintf(stderr, "mtd: read all-zero block at 0x%08llx; skipping\n", pos); } diff --git a/verifier.c b/verifier.c index f2491a14a..164fb4a01 100644 --- a/verifier.c +++ b/verifier.c @@ -123,7 +123,7 @@ int verify_file(const char* path, const RSAPublicKey *pKeys, unsigned int numKey int i; for (i = 4; i < eocd_size-3; ++i) { if (eocd[i ] == 0x50 && eocd[i+1] == 0x4b && - eocd[i+2] == 0x05 && eocd[i+1] == 0x06) { + eocd[i+2] == 0x05 && eocd[i+3] == 0x06) { // if the sequence $50 $4b $05 $06 appears anywhere after // the real one, minzip will find the later (wrong) one, // which could be exploitable. Fail verification if |