@@ -132,6 +132,7 @@ ngx_inline char *ngx_str_to_char(ngx_str_t a, ngx_pool_t *p)
132
132
ngx_inline int
133
133
ngx_http_modsecurity_process_intervention (Transaction * transaction , ngx_http_request_t * r )
134
134
{
135
+ char * log = NULL ;
135
136
ModSecurityIntervention intervention ;
136
137
intervention .status = 200 ;
137
138
intervention .url = NULL ;
@@ -145,11 +146,16 @@ ngx_http_modsecurity_process_intervention (Transaction *transaction, ngx_http_re
145
146
return 0 ;
146
147
}
147
148
149
+ log = intervention .log ;
148
150
if (intervention .log == NULL ) {
149
- intervention . log = "(no log message was specified)" ;
151
+ log = "(no log message was specified)" ;
150
152
}
151
153
152
- ngx_log_error (NGX_LOG_WARN , (ngx_log_t * )r -> connection -> log , 0 , "%s" , intervention .log );
154
+ ngx_log_error (NGX_LOG_WARN , (ngx_log_t * )r -> connection -> log , 0 , "%s" , log );
155
+
156
+ if (intervention .log != NULL ) {
157
+ free (intervention .log );
158
+ }
153
159
154
160
if (intervention .url != NULL )
155
161
{
@@ -496,6 +502,8 @@ ngx_http_modsecurity_create_main_conf(ngx_conf_t *cf)
496
502
{
497
503
ngx_http_modsecurity_conf_t * conf ;
498
504
505
+ ngx_log_error (NGX_LOG_NOTICE , cf -> log , 0 , MODSECURITY_NGINX_WHOAMI );
506
+
499
507
/* ngx_pcalloc already sets all of this scructure to zeros. */
500
508
conf = ngx_http_modsecurity_create_conf (cf );
501
509
@@ -515,7 +523,7 @@ ngx_http_modsecurity_create_main_conf(ngx_conf_t *cf)
515
523
}
516
524
517
525
/* Provide our connector information to LibModSecurity */
518
- msc_set_connector_info (conf -> modsec , "ModSecurity-nginx v0.1.1-beta" );
526
+ msc_set_connector_info (conf -> modsec , MODSECURITY_NGINX_WHOAMI );
519
527
msc_set_log_cb (conf -> modsec , ngx_http_modsecurity_log );
520
528
521
529
return conf ;
@@ -545,6 +553,7 @@ static void *ngx_http_modsecurity_create_conf(ngx_conf_t *cf)
545
553
conf -> enable = NGX_CONF_UNSET ;
546
554
conf -> sanity_checks_enabled = NGX_CONF_UNSET ;
547
555
conf -> rules_set = msc_create_rules_set ();
556
+ conf -> modsec = NULL ;
548
557
conf -> pool = cf -> pool ;
549
558
550
559
cln = ngx_pool_cleanup_add (cf -> pool , 0 );
@@ -652,9 +661,11 @@ ngx_http_modsecurity_config_cleanup(void *data)
652
661
653
662
old_pool = ngx_http_modsecurity_pcre_malloc_init (t -> pool );
654
663
msc_rules_cleanup (t -> rules_set );
664
+ msc_cleanup (t -> modsec );
655
665
ngx_http_modsecurity_pcre_malloc_done (old_pool );
656
666
657
667
t -> rules_set = NULL ;
668
+ t -> modsec = NULL ;
658
669
}
659
670
660
671
0 commit comments