From 2f92d5555302a00a5a10154d8413235888d27c7f Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Fri, 8 Jul 2016 20:49:53 +0200 Subject: mbn: Updated file parsing to newer file version to suppresss warning Note: the parsed data is not actually used. The personalization just involves replacing the last N bytes of the file with the blob data (of size N) returned by the signing server. However this at least suppresses a warning message and helps identifying newer format versions. --- src/mbn.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/mbn.c') diff --git a/src/mbn.c b/src/mbn.c index a01e3cb..a4f514e 100644 --- a/src/mbn.c +++ b/src/mbn.c @@ -36,10 +36,17 @@ mbn_file* mbn_parse(unsigned char* data, unsigned int size) mbn->size = size; memcpy(mbn->data, data, size); /* FIXME: header parsing is not big endian safe */ - memcpy(&mbn->header, data, sizeof(mbn_header)); - mbn->parsed_size = mbn->header.data_size + sizeof(mbn_header); + if (memcmp(data, MBN_V2_MAGIC, MBN_V2_MAGIC_SIZE) == 0) { + mbn->version = 2; + memcpy(&mbn->header.v2, data, sizeof(mbn_header_v2)); + mbn->parsed_size = mbn->header.v2.data_size + sizeof(mbn_header_v2); + } else if (memcmp(data, MBN_V1_MAGIC, MBN_V1_MAGIC_SIZE) == 0) { + mbn->version = 1; + memcpy(&mbn->header.v1, data, sizeof(mbn_header_v1)); + mbn->parsed_size = mbn->header.v1.data_size + sizeof(mbn_header_v1); + } if (mbn->parsed_size != mbn->size) { - debug("WARNING: size mismatch when parsing MBN file.\n"); + info("WARNING: size mismatch when parsing MBN file. Continuing anyway.\n"); } return mbn; } -- cgit v1.1-32-gdbae