aboutsummaryrefslogtreecommitdiffstats
path: root/openbsc/src/ipaccess/ipaccess-firmware.c
diff options
context:
space:
mode:
authorHolger Hans Peter Freyther <zecke@selfish.org>2009-12-27 14:03:11 +0100
committerHolger Hans Peter Freyther <zecke@selfish.org>2009-12-27 14:07:40 +0100
commit30b9ecda334693a3ae1157254bf90d7347f7900c (patch)
treed35bad306c6c9ac1b1e7ed79bad371de33478eea /openbsc/src/ipaccess/ipaccess-firmware.c
parenta25b20c174840602be2bf096f54bb9203c214c58 (diff)
[ipaccess] Verify the size part of the header
Diffstat (limited to 'openbsc/src/ipaccess/ipaccess-firmware.c')
-rw-r--r--openbsc/src/ipaccess/ipaccess-firmware.c12
1 files changed, 12 insertions, 0 deletions
diff --git a/openbsc/src/ipaccess/ipaccess-firmware.c b/openbsc/src/ipaccess/ipaccess-firmware.c
index 4349f99da..8fdc2e9a4 100644
--- a/openbsc/src/ipaccess/ipaccess-firmware.c
+++ b/openbsc/src/ipaccess/ipaccess-firmware.c
@@ -52,6 +52,7 @@ static char more_magic[] = { 0x10, 0x02, 0x00, 0x0 };
static void analyze_file(int fd)
{
struct sdp_firmware *firmware_header;
+ struct stat stat;
char buf[4096];
int rc;
@@ -80,6 +81,17 @@ static void analyze_file(int fd)
printf("text2: %.64s\n", firmware_header->text2);
printf("time: %.8s\n", firmware_header->time);
printf("date: %.8s\n", firmware_header->date);
+
+ /* verify the file */
+ if (fstat(fd, &stat) == -1) {
+ perror("Can not stat the file");
+ return;
+ }
+
+ if (ntohl(firmware_header->file_length) != stat.st_size) {
+ fprintf(stderr, "The filesize and the header do not match.\n");
+ return;
+ }
}
int main(int argc, char** argv)