[source] firmware-utils: fix dgn3500sum compiler warnings
LEDE Commits
lede-commits at lists.infradead.org
Mon Jun 26 11:12:34 PDT 2017
mkresin pushed a commit to source.git, branch lede-17.01:
https://git.lede-project.org/6c03b293bb2ba86f22ea6e20dd0266892932f585
commit 6c03b293bb2ba86f22ea6e20dd0266892932f585
Author: Mathias Kresin <dev at kresin.me>
AuthorDate: Mon Jun 26 19:22:52 2017 +0200
firmware-utils: fix dgn3500sum compiler warnings
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 at kresin.me>
---
tools/firmware-utils/Makefile | 2 +-
tools/firmware-utils/src/dgn3500sum.c | 5 ++---
2 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/tools/firmware-utils/Makefile b/tools/firmware-utils/Makefile
index 69cba69..337d635 100644
--- a/tools/firmware-utils/Makefile
+++ b/tools/firmware-utils/Makefile
@@ -73,7 +73,7 @@ define Host/Compile
$(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)
diff --git a/tools/firmware-utils/src/dgn3500sum.c b/tools/firmware-utils/src/dgn3500sum.c
index 00a0c5f..eb80e6c 100644
--- a/tools/firmware-utils/src/dgn3500sum.c
+++ b/tools/firmware-utils/src/dgn3500sum.c
@@ -103,7 +103,7 @@ int main(int argc, char** argv)
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) {
@@ -117,7 +117,7 @@ int main(int argc, char** argv)
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)
@@ -147,7 +147,6 @@ int main(int argc, char** argv)
start = strtol(argv[2], &endptr, 16);
p = buffer+start;
- sum1 = 0;
for(i = 0; i < count - start; i++)
{
sum1 += p[i];
More information about the lede-commits
mailing list