From 90a3b968fd89d47c9d991c672d8f69994b2ea23e Mon Sep 17 00:00:00 2001 From: iceman1001 Date: Mon, 24 Jul 2023 15:24:53 +0200 Subject: [PATCH] coverity dont think we check if we got enough bytes to operate on. The sizeof the bmp_header_t gives a bit, we would need more ... --- client/src/cmdhfwaveshare.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/client/src/cmdhfwaveshare.c b/client/src/cmdhfwaveshare.c index 8df62bcc1..12e5320e3 100644 --- a/client/src/cmdhfwaveshare.c +++ b/client/src/cmdhfwaveshare.c @@ -1064,7 +1064,13 @@ static int CmdHF14AWSLoadBmp(const char *Cmd) { size_t bytes_read = 0; if (loadFile_safe(filename, ".bmp", (void **)&bmp, &bytes_read) != PM3_SUCCESS) { PrintAndLogEx(WARNING, "Could not find file " _YELLOW_("%s"), filename); - return PM3_EIO; + return PM3_EFILE; + } + if (bmp == NULL) { + return PM3_EMALLOC; + } + if (bytes_read < sizeof(bmp_header_t)) { + return PM3_ESOFT; } int depth = picture_bit_depth(bmp, bytes_read, model_nr);