The sum variable need to be initialised, otherwise it will points to
random stack memory and a bogus image checksum might be calculated.
While at it, fix the segfault in case the product region code isn't
specified and enable compiler warnings which had revealed all the code
issues.
Signed-off-by: Mathias Kresin <dev@kresin.me>
$(call cc,mkdcs932, -Wall)
$(call cc,mkheader_gemtek,-lz)
$(call cc,mkrtn56uimg, -lz)
- $(call cc,dgn3500sum)
+ $(call cc,dgn3500sum, -Wall)
$(call cc,edimax_fw_header, -Wall)
$(call cc,mkmerakifw sha1, -Wall)
$(call cc,mkmerakifw-old, -Wall)
unsigned long start, i;
char *endptr, *buffer, *p;
int count; // size of file in bytes
- unsigned short sum, sum1;
+ unsigned short sum = 0, sum1 = 0;
char sumbuf[9];
if(argc < 3) {
printf("ERROR: File not writeable!\n");
return 1;
}
- if(argc = 4)
+ if(argc == 4)
{
printf("%s: PID type: %s\n", argv[0], argv[3]);
if(strcmp(argv[3], "DE")==0)
start = strtol(argv[2], &endptr, 16);
p = buffer+start;
- sum1 = 0;
for(i = 0; i < count - start; i++)
{
sum1 += p[i];