mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-30 11:44:32 +03:00
Fix segmentation fault if writing to audit log fails
A segmentation fault occurs if concurrent audit log format is enabled (SecAuditLogType Concurrent) and writing to the log fails.
This commit is contained in:
committed by
Felipe Zimmerle
parent
5342f36162
commit
607dfd229a
@@ -52,13 +52,18 @@ static int sec_auditlog_write(modsec_rec *msr, const char *data, unsigned int le
|
|||||||
msr_log(msr, 1, "Audit log: Failed writing (requested %" APR_SIZE_T_FMT
|
msr_log(msr, 1, "Audit log: Failed writing (requested %" APR_SIZE_T_FMT
|
||||||
" bytes, written %" APR_SIZE_T_FMT ")", nbytes, nbytes_written);
|
" bytes, written %" APR_SIZE_T_FMT ")", nbytes, nbytes_written);
|
||||||
|
|
||||||
|
/* Concurrent log format: Don't leak file handle. */
|
||||||
|
if (msr->txcfg->auditlog_type == AUDITLOG_CONCURRENT) {
|
||||||
|
apr_file_close(msr->new_auditlog_fd);
|
||||||
|
}
|
||||||
|
|
||||||
/* Set to NULL to prevent more than one error message on
|
/* Set to NULL to prevent more than one error message on
|
||||||
* out-of-disk-space events and to prevent further attempts
|
* out-of-disk-space events and to prevent further attempts
|
||||||
* to write to the same file in this request.
|
* to write to the same file in this request.
|
||||||
*
|
*
|
||||||
* Note that, as we opened the file through the pool mechanism of
|
* Serial log format: Note that, as we opened the file through the
|
||||||
* the APR, we do not need to close the file here. It will be closed
|
* pool mechanism of the APR, we do not need to close the file
|
||||||
* automatically at the end of the request.
|
* here. It will be closed automatically at the end of the request.
|
||||||
*/
|
*/
|
||||||
msr->new_auditlog_fd = NULL;
|
msr->new_auditlog_fd = NULL;
|
||||||
|
|
||||||
@@ -1181,7 +1186,10 @@ void sec_audit_logger(modsec_rec *msr) {
|
|||||||
|
|
||||||
/* From here on only concurrent-style processing. */
|
/* From here on only concurrent-style processing. */
|
||||||
|
|
||||||
apr_file_close(msr->new_auditlog_fd);
|
/* File handle might already be closed after write failure. */
|
||||||
|
if (msr->new_auditlog_fd) {
|
||||||
|
apr_file_close(msr->new_auditlog_fd);
|
||||||
|
}
|
||||||
|
|
||||||
/* Write an entry to the index file */
|
/* Write an entry to the index file */
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user