From aa062531aa3e740b6cf7d3690fd5310e7fdf03f2 Mon Sep 17 00:00:00 2001 From: Doug Zongker Date: Thu, 28 Jan 2010 16:47:20 -0800 Subject: [PATCH] fix parsing of dumpkeys output %i can't be used to read unsigned ints (though it happens to work with bionic). Change to %x and %u as appropriate. Change-Id: I8ea9ca16a939501757cf70fc5953abee26c8231c http://b/2402231 - Parser for /res/keys interprets n0inv as a signed int --- install.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/install.c b/install.c index 7710cec..bb9924a 100644 --- a/install.c +++ b/install.c @@ -275,7 +275,7 @@ load_keys(const char* filename, int* numKeys) { ++*numKeys; out = realloc(out, *numKeys * sizeof(RSAPublicKey)); RSAPublicKey* key = out + (*numKeys - 1); - if (fscanf(f, " { %i , %i , { %i", + if (fscanf(f, " { %i , 0x%x , { %u", &(key->len), &(key->n0inv), &(key->n[0])) != 3) { goto exit; } @@ -284,11 +284,11 @@ load_keys(const char* filename, int* numKeys) { goto exit; } for (i = 1; i < key->len; ++i) { - if (fscanf(f, " , %i", &(key->n[i])) != 1) goto exit; + if (fscanf(f, " , %u", &(key->n[i])) != 1) goto exit; } - if (fscanf(f, " } , { %i", &(key->rr[0])) != 1) goto exit; + if (fscanf(f, " } , { %u", &(key->rr[0])) != 1) goto exit; for (i = 1; i < key->len; ++i) { - if (fscanf(f, " , %i", &(key->rr[i])) != 1) goto exit; + if (fscanf(f, " , %u", &(key->rr[i])) != 1) goto exit; } fscanf(f, " } } ");