From 8ea847e563292da39a5589eb6aaaf877dda81e67 Mon Sep 17 00:00:00 2001 From: StaticSaga <61866965+StaticSaga@users.noreply.github.com> Date: Sat, 10 Jul 2021 13:59:58 +0200 Subject: [PATCH] bmp: Sanity check images --- stage23/lib/bmp.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/stage23/lib/bmp.c b/stage23/lib/bmp.c index a299caac..1b381c56 100644 --- a/stage23/lib/bmp.c +++ b/stage23/lib/bmp.c @@ -40,7 +40,10 @@ int bmp_open_image(struct image *image, struct file_handle *file) { if (memcmp(&header.bf_signature, "BM", 2) != 0) return -1; - if ((header.bi_bpp < 8) | ((header.bi_bpp % 8) != 0)) + if ((header.bi_bpp != 32) && (header.bi_bpp != 24)) + return -1; + + if (header.bi_compression) return -1; struct bmp_local *local = ext_mem_alloc(sizeof(struct bmp_local));