Просмотр исходного кода

fix file too large error handling

Andrey Rys 1 год назад
Родитель
Сommit
078c25569d
1 измененных файлов с 2 добавлено и 2 удалено
  1. 2 2
      spl_tool/jh7110_uboot_spl.c

+ 2 - 2
spl_tool/jh7110_uboot_spl.c

@@ -31,7 +31,7 @@ struct __attribute__((__packed__)) ubootsplhdr {
 
 static struct ubootsplhdr ubsplhdr;
 
-static char ubootspl[131072-0x400];
+static char ubootspl[131072-sizeof(struct ubootsplhdr)+1];
 static char outpath[PATH_MAX];
 
 #define DEFVERSID 0x01010101
@@ -76,7 +76,7 @@ int main(int argc, char **argv)
 
 	sz = (size_t)read(fd, ubootspl, sizeof(ubootspl));
 	if (sz == NOSIZE) xerror(errno, argv[1]);
-	if (sz >= (sizeof(ubootspl) - sizeof(struct ubootsplhdr)))
+	if (sz >= (sizeof(ubootspl)))
 		xerror(0, "File too large! Please rebuild your SPL with -Os. Maximum allowed size is 130048 bytes.");
 	v = htole32((uint32_t)sz);
 	ubsplhdr.fsiz = v;