file2bin() may return NULL, which is set to tmp, which is passed to memcpy. Add explicit check for it. Fixes: CID 229904. --- src/evmctl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/evmctl.c b/src/evmctl.c index a6d07c9..d6e0b2c 100644 --- a/src/evmctl.c +++ b/src/evmctl.c @@ -821,7 +821,15 @@ static int verify_ima(const char *file) if (sigfile) { void *tmp = file2bin(file, "sig", &len); - assert(len <= sizeof(sig)); + if (!tmp) { + log_err("Failed reading: %s\n", file); + return -1; + } + if (len > sizeof(sig)) { + log_err("Signature file is too big: %s\n", file); + free(tmp); + return -1; + } memcpy(sig, tmp, len); free(tmp); } else { -- 2.11.0