mirror of
https://github.com/owasp-modsecurity/ModSecurity.git
synced 2025-09-29 11:16:33 +03:00
Many null pointer checks
This commit is contained in:
@@ -35,6 +35,7 @@
|
||||
* the size counters, update the hash context.
|
||||
*/
|
||||
static int sec_auditlog_write(modsec_rec *msr, const char *data, unsigned int len) {
|
||||
assert(msr != NULL);
|
||||
apr_size_t nbytes_written, nbytes = len;
|
||||
apr_status_t rc;
|
||||
|
||||
@@ -86,6 +87,8 @@ static int sec_auditlog_write(modsec_rec *msr, const char *data, unsigned int le
|
||||
* some of the fields to make the log line shorter than _limit bytes.
|
||||
*/
|
||||
char *construct_log_vcombinedus_limited(modsec_rec *msr, int _limit, int *was_limited) {
|
||||
assert(msr != NULL);
|
||||
assert(was_limited != NULL);
|
||||
char *hostname;
|
||||
char *local_user, *remote_user;
|
||||
char *referer, *user_agent, *uniqueid;
|
||||
@@ -397,6 +400,7 @@ static void sec_auditlog_write_producer_header(modsec_rec *msr) {
|
||||
* Ouput the Producer header into a JSON generator
|
||||
*/
|
||||
static void sec_auditlog_write_producer_header_json(modsec_rec *msr, yajl_gen g) {
|
||||
assert(msr != NULL);
|
||||
char **signatures = NULL;
|
||||
int i;
|
||||
|
||||
@@ -512,6 +516,7 @@ static msre_rule *return_chained_rule(const msre_rule *current, modsec_rec *msr)
|
||||
* \retval 1 On Success
|
||||
*/
|
||||
static int chained_is_matched(modsec_rec *msr, const msre_rule *next_rule) {
|
||||
assert(msr != NULL);
|
||||
int i = 0;
|
||||
const msre_rule *rule = NULL;
|
||||
|
||||
@@ -530,6 +535,7 @@ static int chained_is_matched(modsec_rec *msr, const msre_rule *next_rule) {
|
||||
* Write detailed information about performance metrics into a JSON generator
|
||||
*/
|
||||
static void format_performance_variables_json(modsec_rec *msr, yajl_gen g) {
|
||||
assert(msr != NULL);
|
||||
yajl_string(g, "stopwatch");
|
||||
yajl_gen_map_open(g);
|
||||
|
||||
@@ -550,6 +556,8 @@ static void format_performance_variables_json(modsec_rec *msr, yajl_gen g) {
|
||||
* Write detailed information about a rule and its actionset into a JSON generator
|
||||
*/
|
||||
static void write_rule_json(modsec_rec *msr, const msre_rule *rule, yajl_gen g) {
|
||||
assert(msr != NULL);
|
||||
assert(rule != NULL);
|
||||
const apr_array_header_t *tarr;
|
||||
const apr_table_entry_t *telts;
|
||||
int been_opened = 0;
|
||||
@@ -740,10 +748,13 @@ void sec_audit_logger_json(modsec_rec *msr) {
|
||||
|
||||
/* Lock the mutex, but only if we are using serial format. */
|
||||
if (msr->txcfg->auditlog_type != AUDITLOG_CONCURRENT) {
|
||||
rc = apr_global_mutex_lock(msr->modsecurity->auditlog_lock);
|
||||
if (rc != APR_SUCCESS) {
|
||||
msr_log(msr, 1, "Audit log: Failed to lock global mutex: %s",
|
||||
get_apr_error(msr->mp, rc));
|
||||
if (!msr->modsecurity->auditlog_lock) msr_log(msr, 1, "Audit log: Global mutex was not created");
|
||||
else {
|
||||
rc = apr_global_mutex_lock(msr->modsecurity->auditlog_lock);
|
||||
if (rc != APR_SUCCESS) {
|
||||
msr_log(msr, 1, "Audit log: Failed to lock global mutex: %s",
|
||||
get_apr_error(msr->mp, rc));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user