Skip to content

Commit

Permalink
Squashme into Autoit commit. Fix bug introduced that leaks FD, tempfile.
Browse files Browse the repository at this point in the history
  • Loading branch information
micahsnyder committed Sep 7, 2022
1 parent b88e701 commit 9243b2e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
6 changes: 6 additions & 0 deletions libclamav/autoit.c
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,12 @@ static cl_error_t ea05(cli_ctx *ctx, const uint8_t *base, char *tmpd)
status = ret;
goto done;
}

close(tempfd);
tempfd = -1;
if (!ctx->engine->keeptmp) {
(void)cli_unlink(tempfile);
}
}

done:
Expand Down
14 changes: 7 additions & 7 deletions libclamav/others.c
Original file line number Diff line number Diff line change
Expand Up @@ -1298,18 +1298,18 @@ cl_error_t cli_unlink(const char *pathname)
* even if the user has permissions to delete the file. */
if (-1 == _chmod(pathname, _S_IWRITE)) {
char err[128];
cli_warnmsg("cli_unlink: _chmod failure - %s\n", cli_strerror(errno, err, sizeof(err)));
return CL_EUNLINK;
cli_warnmsg("cli_unlink: _chmod failure for %s - %s\n", pathname, cli_strerror(errno, err, sizeof(err)));
return 1;
} else if (unlink(pathname) == -1) {
char err[128];
cli_warnmsg("cli_unlink: unlink failure - %s\n", cli_strerror(errno, err, sizeof(err)));
return CL_EUNLINK;
cli_warnmsg("cli_unlink: unlink failure for %s - %s\n", pathname, cli_strerror(errno, err, sizeof(err)));
return 1;
}
return CL_SUCCESS;
return 0;
#else
char err[128];
cli_warnmsg("cli_unlink: unlink failure - %s\n", cli_strerror(errno, err, sizeof(err)));
return CL_EUNLINK;
cli_warnmsg("cli_unlink: unlink failure - %s\n", pathname, cli_strerror(errno, err, sizeof(err)));
return 1;
#endif
}
return CL_SUCCESS;
Expand Down

0 comments on commit 9243b2e

Please sign in to comment.