Browse Source

check for maximum of 16 MB cfgfs partition, more is not available by design, thx @tg for the info

Waldemar Brodkorb 11 years ago
parent
commit
e4938d7ddd
2 changed files with 9 additions and 1 deletions
  1. 1 1
      package/cfgfs/src/defs.h
  2. 8 0
      package/cfgfs/src/wraps.c

+ 1 - 1
package/cfgfs/src/defs.h

@@ -10,7 +10,7 @@
 #define DEFS_H
 
 #define DEF_FLASHBLOCK	65536		/* size of a flash block */
-#define DEF_FLASHPART	4194304		/* max size of the partition */
+#define DEF_FLASHPART	16777215	/* max size of the partition */
 
 #define FWCF_VER	0x01		/* major version of spec used */
 

+ 8 - 0
package/cfgfs/src/wraps.c

@@ -77,6 +77,14 @@ fwcf_pack(char *odata, size_t i, int algo, size_t *dstsz)
 
 	/* 12 bytes header, padding to 4-byte boundary, 4 bytes trailer */
 	k = ((j + 19) / 4) * 4;
+
+#if DEF_FLASHPART > 0xFFFFFF
+# error DEF_FLASHPART too large
+#endif
+       if (k > DEF_FLASHPART)
+               errx(1, "%lu bytes too large for flash partition of %lu KiB",
+                   (u_long)k, DEF_FLASHPART / 1024UL);
+
 	/* padded to size of flash block */
 #if (DEF_FLASHBLOCK & 3)
 # error DEF_FLASHBLOCK must be dword-aligned