summaryrefslogtreecommitdiff
path: root/tools/sfspl.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/sfspl.c')
-rw-r--r--tools/sfspl.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/tools/sfspl.c b/tools/sfspl.c
index c76420ce21b..516e96e8dd9 100644
--- a/tools/sfspl.c
+++ b/tools/sfspl.c
@@ -70,11 +70,14 @@ static int sfspl_verify_header(unsigned char *buf, int size,
printf("Truncated file\n");
return EXIT_FAILURE;
}
+ if ((size_t)size > hdr_size + file_size)
+ printf("File too long, expected %u bytes\n",
+ hdr_size + file_size);
if (hdr->version != DEFAULT_VERSION) {
printf("Unknown file format version\n");
return EXIT_FAILURE;
}
- crc_check = crc32(0, &buf[hdr_size], size - hdr_size);
+ crc_check = crc32(0, &buf[hdr_size], file_size);
if (crc_check != crc) {
printf("Incorrect CRC32\n");
return EXIT_FAILURE;