diff options
| author | TazyFoundSoup <gardendistrict0x0@outlook.com> | 2026-02-16 18:30:44 +1100 |
|---|---|---|
| committer | TazyFoundSoup <gardendistrict0x0@outlook.com> | 2026-02-16 18:30:44 +1100 |
| commit | b8de9285970775d539f09f7bc81d3eae24e410e9 (patch) | |
| tree | 0adb6e6052ea37b466f6015ae08af4e5cd44ee4e /src/format | |
| parent | 73e9f1417d98a2b414ccc43308fd798a92f37e4e (diff) | |
feat(bmp): Implement ff_bmp_isvalid function for BMP signature validation
Diffstat (limited to 'src/format')
| -rw-r--r-- | src/format/image/bmp.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/format/image/bmp.c b/src/format/image/bmp.c new file mode 100644 index 0000000..d947a83 --- /dev/null +++ b/src/format/image/bmp.c @@ -0,0 +1,27 @@ +#include "tinyff/image/bmp.h" +#include "tinyff/dbg.h" +#include "bmp.h" + +ff_result ff_bmp_isvalid(ff_stream* stream) +{ + ff_dprintf("png: validating signature\n"); + + char raw_sig[2]; + if (stream->read(raw_sig, 2, stream->user) != 2) { + ff_dprintf("bmp: failed to read signature bytes\n"); + return FF_RESULT_ERROR_INVALID_FILE; + } + + ff_dprintf( + "bmp: signature read: %02X %02X \n", + raw_sig[0], raw_sig[1] + ); + + if (memcmp(raw_sig, BMP_SIGNATURE, 2) != 0) { + ff_dprintf("bmp: signature mismatch\n"); + return FF_RESULT_ERROR_INVALID_PNG_SIGNITURE; + } + + ff_dprintf("bmp: signature valid\n"); + return FF_RESULT_OK; +}
\ No newline at end of file |
