From 9a5b006cf76471e0ae3d38acc932c0da60b30d1b Mon Sep 17 00:00:00 2001 From: Olivier Gayot Date: Sun, 23 Dec 2018 02:04:56 +0100 Subject: Fail if the format is not supported Signed-off-by: Olivier Gayot --- stegmp.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stegmp.c b/stegmp.c index 825fd8f..87715dd 100644 --- a/stegmp.c +++ b/stegmp.c @@ -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) -- cgit v1.2.3