Skip to content

Commit

Permalink
Coverity 416446: Fix possible NULL dereference
Browse files Browse the repository at this point in the history
Missing a NULL-check before calling `cli_unlink()` which has no NULL
check of its own before calling `unlink`.
  • Loading branch information
val-ms committed Aug 8, 2023
1 parent 5893708 commit 4c34301
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions libclamav/udf.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ static cl_error_t writeWholeFile(cli_ctx *ctx, const char *const fileName, const
fd = -1;
}
if (!ctx->engine->keeptmp) {
if (cli_unlink(tmpf)) {
/* If status is already set to virus or something, that should take priority of the
* error unlinking the file. */
if (CL_CLEAN == status) {
status = CL_EUNLINK;
if (NULL != tmpf) {
if (cli_unlink(tmpf)) {
/* If status is already set to virus or something, that should take priority of the
* error unlinking the file. */
if (CL_CLEAN == status) {
status = CL_EUNLINK;
}
}
}
}
Expand Down

0 comments on commit 4c34301

Please sign in to comment.