aboutsummaryrefslogtreecommitdiffstats
path: root/tools/firmware-utils/src
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2016-08-24 09:30:56 +0200
committerMatthias Schiffer <mschiffer@universe-factory.net>2016-12-20 14:38:47 +0100
commitd58e8a90769e2f65e26960555c972237a18068f5 (patch)
tree2057642fea8638380a93ad658c185aaad8392651 /tools/firmware-utils/src
parentc21af889bbd34fd62502c9b1fa1dc2fee7b2f2f2 (diff)
downloadupstream-d58e8a90769e2f65e26960555c972237a18068f5.tar.gz
upstream-d58e8a90769e2f65e26960555c972237a18068f5.tar.bz2
upstream-d58e8a90769e2f65e26960555c972237a18068f5.zip
firmware-utils/tplink-safeloader: make vendor data optional
Restructure the code a bit to allow for omitting vendor data when generating factory images. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'tools/firmware-utils/src')
-rw-r--r--tools/firmware-utils/src/tplink-safeloader.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/tools/firmware-utils/src/tplink-safeloader.c b/tools/firmware-utils/src/tplink-safeloader.c
index 2dedaa656c..7fb5e89530 100644
--- a/tools/firmware-utils/src/tplink-safeloader.c
+++ b/tools/firmware-utils/src/tplink-safeloader.c
@@ -449,10 +449,6 @@ static void put_partitions(uint8_t *buffer, const struct image_partition_entry *
base += parts[i].size;
}
-
- image_pt++;
-
- memset(image_pt, 0xff, end-image_pt);
}
/** Generates and writes the image MD5 checksum */
@@ -492,12 +488,14 @@ static void * generate_factory_image(const char *vendor, const struct image_part
if (!image)
error(1, errno, "malloc");
+ memset(image, 0xff, *len);
put32(image, *len);
- size_t vendor_len = strlen(vendor);
- put32(image+0x14, vendor_len);
- memcpy(image+0x18, vendor, vendor_len);
- memset(image+0x18+vendor_len, 0xff, 4092-vendor_len);
+ if (vendor) {
+ size_t vendor_len = strlen(vendor);
+ put32(image+0x14, vendor_len);
+ memcpy(image+0x18, vendor, vendor_len);
+ }
put_partitions(image + 0x1014, parts);
put_md5(image+0x04, image+0x14, *len-0x14);