From 312f029c8a2507eb4345f7c42ab5ded867255d08 Mon Sep 17 00:00:00 2001 From: Felipe Zimmerle Date: Wed, 20 Dec 2017 14:36:29 -0300 Subject: [PATCH 1/2] Updates the CHANGES files --- CHANGES | 7 ++++--- src/ngx_http_modsecurity_common.h | 28 ++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 3 deletions(-) diff --git a/CHANGES b/CHANGES index a669e53..a1ba664 100644 --- a/CHANGES +++ b/CHANGES @@ -1,5 +1,6 @@ -DD mmm YYYY - 1.0.0 + +v1.0.0 - 2017-Dec-20 -------------------- - * First version of the ModSecurity-nginx - [Felipe Zimmerle] + - First version of ModSecurity-nginx connector + diff --git a/src/ngx_http_modsecurity_common.h b/src/ngx_http_modsecurity_common.h index f2a4aa8..7d8ebcd 100644 --- a/src/ngx_http_modsecurity_common.h +++ b/src/ngx_http_modsecurity_common.h @@ -26,6 +26,34 @@ #include #include + +/** + * TAG_NUM: + * + * Alpha - 001 + * Beta - 002 + * Dev - 010 + * Rc1 - 051 + * Rc2 - 052 + * ... - ... + * Release- 100 + * + */ + +#define MODSECURITY_NGINX_MAJOR "1" +#define MODSECURITY_NGINX_MINOR "0" +#define MODSECURITY_NGINX_PATCHLEVEL "0" +#define MODSECURITY_NGINX_TAG "" +#define MODSECURITY_NGINX_TAG_NUM "100" + +#define MODSECURITY_NGINX_VERSION MODSECURITY_NGINX_MAJOR "." \ + MODSECURITY_NGINX_MINOR "." MODSECURITY_NGINX_PATCHLEVEL \ + MODSECURITY_NGINX_TAG + +#define MODSECURITY_NGINX_VERSION_NUM MODSECURITY_NGINX_MAJOR \ + MODSECURITY_NGINX_MINOR MODSECURITY_NGINX_PATCHLEVEL \ + MODSECURITY_NGINX_TAG_NUM + typedef struct { ngx_str_t name; ngx_str_t value; From 077d44c259226db71d257b361a164de780725f9e Mon Sep 17 00:00:00 2001 From: Andrei Belov Date: Wed, 4 Apr 2018 17:20:49 +0300 Subject: [PATCH 2/2] Fix memory leak in intervention processing intervention.log is being allocated via strdup() here: https://github.com/SpiderLabs/ModSecurity/blob/v3/master/src/transaction.cc#L1362 and should be freed by connector. --- src/ngx_http_modsecurity_module.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/ngx_http_modsecurity_module.c b/src/ngx_http_modsecurity_module.c index 7890437..12577fe 100644 --- a/src/ngx_http_modsecurity_module.c +++ b/src/ngx_http_modsecurity_module.c @@ -132,6 +132,7 @@ ngx_inline char *ngx_str_to_char(ngx_str_t a, ngx_pool_t *p) ngx_inline int ngx_http_modsecurity_process_intervention (Transaction *transaction, ngx_http_request_t *r) { + char *log = NULL; ModSecurityIntervention intervention; intervention.status = 200; intervention.url = NULL; @@ -145,11 +146,16 @@ ngx_http_modsecurity_process_intervention (Transaction *transaction, ngx_http_re return 0; } + log = intervention.log; if (intervention.log == NULL) { - intervention.log = "(no log message was specified)"; + log = "(no log message was specified)"; } - ngx_log_error(NGX_LOG_WARN, (ngx_log_t *)r->connection->log, 0, "%s", intervention.log); + ngx_log_error(NGX_LOG_WARN, (ngx_log_t *)r->connection->log, 0, "%s", log); + + if (intervention.log != NULL) { + free(intervention.log); + } if (intervention.url != NULL) {