From: Sander Vanheule Date: Sat, 11 Jul 2020 20:58:07 +0000 (+0200) Subject: firmware-utils/tplink-safeloader: soft-version magic is data length X-Git-Url: http://git.openwrt.org/?a=commitdiff_plain;h=d583cca9e201f9b62baded2d1b8e75a60109159d;p=project%2Ffirmware-utils.git firmware-utils/tplink-safeloader: soft-version magic is data length The soft-version partition actually contains a header and trailing data: * header: {data length, [zero]} * data: {version, bcd encoded date, revision} The data length is currently treated as a magic number, but should contain the length of the partition data. This header is also present the following partitions (non-exhaustive): * string-based soft-version * support-list Signed-off-by: Sander Vanheule --- diff --git a/src/tplink-safeloader.c b/src/tplink-safeloader.c index 501b396..145e808 100644 --- a/src/tplink-safeloader.c +++ b/src/tplink-safeloader.c @@ -84,7 +84,7 @@ struct device_info { /** The content of the soft-version structure */ struct __attribute__((__packed__)) soft_version { - uint32_t magic; + uint32_t data_len; uint32_t zero; uint8_t pad1; uint8_t version_major; @@ -2153,7 +2153,8 @@ static struct image_partition_entry make_soft_version(uint32_t rev) { struct tm *tm = gmtime(&t); - s->magic = htonl(0x0000000c); + /* Partition contents size, minus 8 byte header and trailing byte */ + s->data_len = htonl(entry.size-9); s->zero = 0; s->pad1 = 0xff;