diff options
author | Olivier Gayot <og@satcom1.com> | 2018-12-23 02:04:56 +0100 |
---|---|---|
committer | Olivier Gayot <og@satcom1.com> | 2018-12-23 02:06:52 +0100 |
commit | 9a5b006cf76471e0ae3d38acc932c0da60b30d1b (patch) | |
tree | 673eab04d00886971d971f3de3bcd93e98b3fd7c | |
parent | 6d95df26508747cd5c511684f3981ac97550408e (diff) |
Fail if the format is not supported
Signed-off-by: Olivier Gayot <og@satcom1.com>
-rw-r--r-- | stegmp.c | 8 |
1 files changed, 6 insertions, 2 deletions
@@ -232,7 +232,9 @@ static int stegmp_parse_headers(const unsigned char *addr, size_t orig_size, bmpp->data_offset = packed_header.data_offset; bmpp->size = packed_header.bmp_size; - stegmp_parse_dib_header(addr + sizeof(packed_header), orig_size, bmpp); + if (stegmp_parse_dib_header(addr + sizeof(packed_header), orig_size, bmpp) < 0) { + return -1; + } return 0; } @@ -246,6 +248,7 @@ static int stegmp(const char *bmp_file, FILE *input) struct stat stat; struct bitmap bmp; FILE *fh = fopen(bmp_file, "r+"); + int ret = 0; if (fh == NULL) { fprintf(stderr, "%s: %m\n", bmp_file); @@ -273,12 +276,13 @@ static int stegmp(const char *bmp_file, FILE *input) } else { fprintf(stderr, "unable to parse headers: %s\n", bmp_strerror(bmp_errno)); + ret = -1; } munmap(addr, stat.st_size); fclose(fh); - return 0; + return ret; } static inline int stegmp_read(const char *bmp_file) |