summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTazyFoundSoup <gardendistrict0x0@outlook.com>2026-03-11 15:55:01 +1100
committerTazyFoundSoup <gardendistrict0x0@outlook.com>2026-03-11 15:55:01 +1100
commit98a89ce0eafa488c5ebbe963a8a601cac6739e87 (patch)
treed3b65bbd5a2eec535a4dfc10d9c157d78f0c64d2
parenta1b13c1da9c9d8a97ecf1771e46576820b6373a6 (diff)
fix(bmp): Fail BITMAP header parsing if header is not correct size
-rw-r--r--include/tinyff/result.h3
-rw-r--r--src/format/image/bmp.c4
2 files changed, 6 insertions, 1 deletions
diff --git a/include/tinyff/result.h b/include/tinyff/result.h
index 43bcf98..b2bf31c 100644
--- a/include/tinyff/result.h
+++ b/include/tinyff/result.h
@@ -27,6 +27,9 @@ typedef enum {
// PNG
FF_RESULT_ERROR_INVALID_PNG_SIGNATURE,
+
+ // BMP
+ FF_RESULT_ERROR_INVALID_BMP_HEADER,
// Archive (more general archives terms)
FF_RESULT_ERROR_DECOMPRESSION_FAILURE,
diff --git a/src/format/image/bmp.c b/src/format/image/bmp.c
index e565b16..dde7d7e 100644
--- a/src/format/image/bmp.c
+++ b/src/format/image/bmp.c
@@ -69,7 +69,9 @@ ff_result ff_bmp_header_handler(uint8_t *buf, size_t len, ff_bmp_ctx *ctx) {
(void) ctx;
if (len != FF_BMP_HEADER_SIZE) {
-
+ ff_dprintf("bmp: bitmap header is not correct size (expected 14, got %d)\n", len);
+ ctx->last_error = FF_RESULT_ERROR_INVALID_BMP_HEADER;
+ return FF_RESULT_ERROR_INVALID_BMP_HEADER;
}
return FF_RESULT_WARN_NO_IMPL;