am 026ebe02: Merge "Recovery 64-bit compile issues"
* commit '026ebe0214d6c1c9b3ddc22c35e9ac37e5f622bc': Recovery 64-bit compile issues
This commit is contained in:
@@ -247,7 +247,7 @@ static int LoadPartitionContents(const char* filename, FileContents* file) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (next != read) {
|
if (next != read) {
|
||||||
printf("short read (%d bytes of %d) for partition \"%s\"\n",
|
printf("short read (%zu bytes of %zu) for partition \"%s\"\n",
|
||||||
read, next, partition);
|
read, next, partition);
|
||||||
free(file->data);
|
free(file->data);
|
||||||
file->data = NULL;
|
file->data = NULL;
|
||||||
@@ -274,7 +274,7 @@ static int LoadPartitionContents(const char* filename, FileContents* file) {
|
|||||||
if (memcmp(sha_so_far, parsed_sha, SHA_DIGEST_SIZE) == 0) {
|
if (memcmp(sha_so_far, parsed_sha, SHA_DIGEST_SIZE) == 0) {
|
||||||
// we have a match. stop reading the partition; we'll return
|
// we have a match. stop reading the partition; we'll return
|
||||||
// the data we've read so far.
|
// the data we've read so far.
|
||||||
printf("partition read matched size %d sha %s\n",
|
printf("partition read matched size %zu sha %s\n",
|
||||||
size[index[i]], sha1sum[index[i]]);
|
size[index[i]], sha1sum[index[i]]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -402,7 +402,7 @@ int WriteToPartition(unsigned char* data, size_t len,
|
|||||||
|
|
||||||
size_t written = mtd_write_data(ctx, (char*)data, len);
|
size_t written = mtd_write_data(ctx, (char*)data, len);
|
||||||
if (written != len) {
|
if (written != len) {
|
||||||
printf("only wrote %d of %d bytes to MTD %s\n",
|
printf("only wrote %zu of %zu bytes to MTD %s\n",
|
||||||
written, len, partition);
|
written, len, partition);
|
||||||
mtd_write_close(ctx);
|
mtd_write_close(ctx);
|
||||||
return -1;
|
return -1;
|
||||||
@@ -476,20 +476,20 @@ int WriteToPartition(unsigned char* data, size_t len,
|
|||||||
if (errno == EINTR) {
|
if (errno == EINTR) {
|
||||||
read_count = 0;
|
read_count = 0;
|
||||||
} else {
|
} else {
|
||||||
printf("verify read error %s at %d: %s\n",
|
printf("verify read error %s at %zu: %s\n",
|
||||||
partition, p, strerror(errno));
|
partition, p, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((size_t)read_count < to_read) {
|
if ((size_t)read_count < to_read) {
|
||||||
printf("short verify read %s at %d: %d %d %s\n",
|
printf("short verify read %s at %zu: %zd %zu %s\n",
|
||||||
partition, p, read_count, to_read, strerror(errno));
|
partition, p, read_count, to_read, strerror(errno));
|
||||||
}
|
}
|
||||||
so_far += read_count;
|
so_far += read_count;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (memcmp(buffer, data+p, to_read)) {
|
if (memcmp(buffer, data+p, to_read)) {
|
||||||
printf("verification failed starting at %d\n", p);
|
printf("verification failed starting at %zu\n", p);
|
||||||
start = p;
|
start = p;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
// format.
|
// format.
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -35,7 +36,7 @@
|
|||||||
* file, and update the SHA context with the output data as well.
|
* file, and update the SHA context with the output data as well.
|
||||||
* Return 0 on success.
|
* Return 0 on success.
|
||||||
*/
|
*/
|
||||||
int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size,
|
int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size __unused,
|
||||||
const Value* patch,
|
const Value* patch,
|
||||||
SinkFn sink, void* token, SHA_CTX* ctx,
|
SinkFn sink, void* token, SHA_CTX* ctx,
|
||||||
const Value* bonus_data) {
|
const Value* bonus_data) {
|
||||||
@@ -132,7 +133,7 @@ int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size,
|
|||||||
|
|
||||||
unsigned char* expanded_source = malloc(expanded_len);
|
unsigned char* expanded_source = malloc(expanded_len);
|
||||||
if (expanded_source == NULL) {
|
if (expanded_source == NULL) {
|
||||||
printf("failed to allocate %d bytes for expanded_source\n",
|
printf("failed to allocate %zu bytes for expanded_source\n",
|
||||||
expanded_len);
|
expanded_len);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@@ -163,7 +164,7 @@ int ApplyImagePatch(const unsigned char* old_data, ssize_t old_size,
|
|||||||
// We should have filled the output buffer exactly, except
|
// We should have filled the output buffer exactly, except
|
||||||
// for the bonus_size.
|
// for the bonus_size.
|
||||||
if (strm.avail_out != bonus_size) {
|
if (strm.avail_out != bonus_size) {
|
||||||
printf("source inflation short by %d bytes\n", strm.avail_out-bonus_size);
|
printf("source inflation short by %zu bytes\n", strm.avail_out-bonus_size);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
inflateEnd(&strm);
|
inflateEnd(&strm);
|
||||||
|
|||||||
+2
-1
@@ -319,7 +319,8 @@ static void local_socket_event_func(int fd, unsigned ev, void *_s)
|
|||||||
|
|
||||||
while(avail > 0) {
|
while(avail > 0) {
|
||||||
r = adb_read(fd, x, avail);
|
r = adb_read(fd, x, avail);
|
||||||
D("LS(%d): post adb_read(fd=%d,...) r=%d (errno=%d) avail=%d\n", s->id, s->fd, r, r<0?errno:0, avail);
|
D("LS(%d): post adb_read(fd=%d,...) r=%d (errno=%d) avail=%zu\n",
|
||||||
|
s->id, s->fd, r, r<0?errno:0, avail);
|
||||||
if(r > 0) {
|
if(r > 0) {
|
||||||
avail -= r;
|
avail -= r;
|
||||||
x += r;
|
x += r;
|
||||||
|
|||||||
+2
-2
@@ -713,7 +713,7 @@ int readx(int fd, void *ptr, size_t len)
|
|||||||
char *p = ptr;
|
char *p = ptr;
|
||||||
int r;
|
int r;
|
||||||
#if ADB_TRACE
|
#if ADB_TRACE
|
||||||
int len0 = len;
|
size_t len0 = len;
|
||||||
#endif
|
#endif
|
||||||
D("readx: fd=%d wanted=%d\n", fd, (int)len);
|
D("readx: fd=%d wanted=%d\n", fd, (int)len);
|
||||||
while(len > 0) {
|
while(len > 0) {
|
||||||
@@ -734,7 +734,7 @@ int readx(int fd, void *ptr, size_t len)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if ADB_TRACE
|
#if ADB_TRACE
|
||||||
D("readx: fd=%d wanted=%d got=%d\n", fd, len0, len0 - len);
|
D("readx: fd=%d wanted=%zu got=%zu\n", fd, len0, len0 - len);
|
||||||
dump_hex( ptr, len0 );
|
dump_hex( ptr, len0 );
|
||||||
#endif
|
#endif
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -388,7 +388,7 @@ static int bulk_read(int bulk_out, char *buf, size_t length)
|
|||||||
ret = adb_read(bulk_out, buf + count, length - count);
|
ret = adb_read(bulk_out, buf + count, length - count);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
if (errno != EINTR) {
|
if (errno != EINTR) {
|
||||||
D("[ bulk_read failed fd=%d length=%d count=%d ]\n",
|
D("[ bulk_read failed fd=%d length=%zu count=%zu ]\n",
|
||||||
bulk_out, length, count);
|
bulk_out, length, count);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include <sys/cdefs.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <sys/mman.h>
|
#include <sys/mman.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
@@ -55,7 +56,7 @@ minui_backend* open_fbdev() {
|
|||||||
return &my_backend;
|
return &my_backend;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fbdev_blank(minui_backend* backend, bool blank)
|
static void fbdev_blank(minui_backend* backend __unused, bool blank)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -174,7 +175,7 @@ static gr_surface fbdev_init(minui_backend* backend) {
|
|||||||
return gr_draw;
|
return gr_draw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static gr_surface fbdev_flip(minui_backend* backend) {
|
static gr_surface fbdev_flip(minui_backend* backend __unused) {
|
||||||
if (double_buffered) {
|
if (double_buffered) {
|
||||||
// Change gr_draw to point to the buffer currently displayed,
|
// Change gr_draw to point to the buffer currently displayed,
|
||||||
// then flip the driver so we're displaying the other buffer
|
// then flip the driver so we're displaying the other buffer
|
||||||
@@ -189,7 +190,7 @@ static gr_surface fbdev_flip(minui_backend* backend) {
|
|||||||
return gr_draw;
|
return gr_draw;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void fbdev_exit(minui_backend* backend) {
|
static void fbdev_exit(minui_backend* backend __unused) {
|
||||||
close(fb_fd);
|
close(fb_fd);
|
||||||
fb_fd = -1;
|
fb_fd = -1;
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -95,7 +95,7 @@ int res_create_surface(const char* name, gr_surface* pSurface) {
|
|||||||
png_read_info(png_ptr, info_ptr);
|
png_read_info(png_ptr, info_ptr);
|
||||||
|
|
||||||
int color_type, bit_depth;
|
int color_type, bit_depth;
|
||||||
size_t width, height;
|
png_uint_32 width, height;
|
||||||
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth,
|
png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth,
|
||||||
&color_type, NULL, NULL, NULL);
|
&color_type, NULL, NULL, NULL);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -177,11 +177,11 @@ get_args(int *argc, char ***argv) {
|
|||||||
stage = strndup(boot.stage, sizeof(boot.stage));
|
stage = strndup(boot.stage, sizeof(boot.stage));
|
||||||
|
|
||||||
if (boot.command[0] != 0 && boot.command[0] != 255) {
|
if (boot.command[0] != 0 && boot.command[0] != 255) {
|
||||||
LOGI("Boot command: %.*s\n", sizeof(boot.command), boot.command);
|
LOGI("Boot command: %.*s\n", (int)sizeof(boot.command), boot.command);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (boot.status[0] != 0 && boot.status[0] != 255) {
|
if (boot.status[0] != 0 && boot.status[0] != 255) {
|
||||||
LOGI("Boot status: %.*s\n", sizeof(boot.status), boot.status);
|
LOGI("Boot status: %.*s\n", (int)sizeof(boot.status), boot.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- if arguments weren't supplied, look in the bootloader control block
|
// --- if arguments weren't supplied, look in the bootloader control block
|
||||||
|
|||||||
@@ -57,9 +57,9 @@ void write_tagged(FILE *out, const char *line, const char *tag, int number) {
|
|||||||
const char *end = line + strlen(line);
|
const char *end = line + strlen(line);
|
||||||
while (end > line && isspace(end[-1])) --end;
|
while (end > line && isspace(end[-1])) --end;
|
||||||
if (number > 0) {
|
if (number > 0) {
|
||||||
fprintf(out, "%.*s%s%d%s", end - line, line, tag, number, end);
|
fprintf(out, "%.*s%s%d%s", (int)(end - line), line, tag, number, end);
|
||||||
} else {
|
} else {
|
||||||
fprintf(out, "%.*s%s%s", end - line, line, tag, end);
|
fprintf(out, "%.*s%s%s", (int)(end - line), line, tag, end);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -866,7 +866,7 @@ Value* FileGetPropFn(const char* name, State* state, int argc, Expr* argv[]) {
|
|||||||
|
|
||||||
buffer = malloc(st.st_size+1);
|
buffer = malloc(st.st_size+1);
|
||||||
if (buffer == NULL) {
|
if (buffer == NULL) {
|
||||||
ErrorAbort(state, "%s: failed to alloc %lld bytes", name, st.st_size+1);
|
ErrorAbort(state, "%s: failed to alloc %lld bytes", name, (long long)st.st_size+1);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -879,7 +879,7 @@ Value* FileGetPropFn(const char* name, State* state, int argc, Expr* argv[]) {
|
|||||||
|
|
||||||
if (fread(buffer, 1, st.st_size, f) != st.st_size) {
|
if (fread(buffer, 1, st.st_size, f) != st.st_size) {
|
||||||
ErrorAbort(state, "%s: failed to read %lld bytes from %s",
|
ErrorAbort(state, "%s: failed to read %lld bytes from %s",
|
||||||
name, st.st_size+1, filename);
|
name, (long long)st.st_size+1, filename);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|||||||
+7
-7
@@ -152,7 +152,7 @@ int verify_file(const char* path, const Certificate* pKeys, unsigned int numKeys
|
|||||||
|
|
||||||
size_t comment_size = footer[4] + (footer[5] << 8);
|
size_t comment_size = footer[4] + (footer[5] << 8);
|
||||||
size_t signature_start = footer[0] + (footer[1] << 8);
|
size_t signature_start = footer[0] + (footer[1] << 8);
|
||||||
LOGI("comment is %d bytes; signature %d bytes from end\n",
|
LOGI("comment is %zu bytes; signature %zu bytes from end\n",
|
||||||
comment_size, signature_start);
|
comment_size, signature_start);
|
||||||
|
|
||||||
if (signature_start <= FOOTER_SIZE) {
|
if (signature_start <= FOOTER_SIZE) {
|
||||||
@@ -292,24 +292,24 @@ int verify_file(const char* path, const Certificate* pKeys, unsigned int numKeys
|
|||||||
if (pKeys[i].key_type == Certificate::RSA) {
|
if (pKeys[i].key_type == Certificate::RSA) {
|
||||||
if (sig_der_length < RSANUMBYTES) {
|
if (sig_der_length < RSANUMBYTES) {
|
||||||
// "signature" block isn't big enough to contain an RSA block.
|
// "signature" block isn't big enough to contain an RSA block.
|
||||||
LOGI("signature is too short for RSA key %d\n", i);
|
LOGI("signature is too short for RSA key %zu\n", i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!RSA_verify(pKeys[i].rsa, sig_der, RSANUMBYTES,
|
if (!RSA_verify(pKeys[i].rsa, sig_der, RSANUMBYTES,
|
||||||
hash, pKeys[i].hash_len)) {
|
hash, pKeys[i].hash_len)) {
|
||||||
LOGI("failed to verify against RSA key %d\n", i);
|
LOGI("failed to verify against RSA key %zu\n", i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGI("whole-file signature verified against RSA key %d\n", i);
|
LOGI("whole-file signature verified against RSA key %zu\n", i);
|
||||||
free(sig_der);
|
free(sig_der);
|
||||||
return VERIFY_SUCCESS;
|
return VERIFY_SUCCESS;
|
||||||
} else if (pKeys[i].key_type == Certificate::EC
|
} else if (pKeys[i].key_type == Certificate::EC
|
||||||
&& pKeys[i].hash_len == SHA256_DIGEST_SIZE) {
|
&& pKeys[i].hash_len == SHA256_DIGEST_SIZE) {
|
||||||
p256_int r, s;
|
p256_int r, s;
|
||||||
if (!dsa_sig_unpack(sig_der, sig_der_length, &r, &s)) {
|
if (!dsa_sig_unpack(sig_der, sig_der_length, &r, &s)) {
|
||||||
LOGI("Not a DSA signature block for EC key %d\n", i);
|
LOGI("Not a DSA signature block for EC key %zu\n", i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,11 +317,11 @@ int verify_file(const char* path, const Certificate* pKeys, unsigned int numKeys
|
|||||||
p256_from_bin(hash, &p256_hash);
|
p256_from_bin(hash, &p256_hash);
|
||||||
if (!p256_ecdsa_verify(&(pKeys[i].ec->x), &(pKeys[i].ec->y),
|
if (!p256_ecdsa_verify(&(pKeys[i].ec->x), &(pKeys[i].ec->y),
|
||||||
&p256_hash, &r, &s)) {
|
&p256_hash, &r, &s)) {
|
||||||
LOGI("failed to verify against EC key %d\n", i);
|
LOGI("failed to verify against EC key %zu\n", i);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOGI("whole-file signature verified against EC key %d\n", i);
|
LOGI("whole-file signature verified against EC key %zu\n", i);
|
||||||
free(sig_der);
|
free(sig_der);
|
||||||
return VERIFY_SUCCESS;
|
return VERIFY_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
Reference in New Issue
Block a user