Skip to content

Commit f6a5442

Browse files
committed
rename DDEBUG to MODSECURITY_DDEBUG
change way MODSECURITY_SANITY_CHECKS defined these changes allow managing both these defines through CFLGAS redefinition and do not pollute other modules w/ unexpected defines
1 parent b1c7aaf commit f6a5442

8 files changed

+35
-33
lines changed

src/ddebug.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
#include <ngx_core.h>
1414

1515
/*
16-
* #undef DDEBUG
17-
* #define DDEBUG 1
16+
* #undef MODSECURITY_DDEBUG
17+
* #define MODSECURITY_DDEBUG 1
1818
*/
1919

2020
/*
@@ -26,9 +26,11 @@
2626
* If performance is not a concern, it is safe to keep it set.
2727
*
2828
*/
29+
#ifndef MODSECURITY_SANITY_CHECKS
2930
#define MODSECURITY_SANITY_CHECKS 1
31+
#endif
3032

31-
#if defined(DDEBUG) && (DDEBUG)
33+
#if defined(MODSECURITY_DDEBUG) && (MODSECURITY_DDEBUG)
3234

3335
# if (NGX_HAVE_VARIADIC_MACROS)
3436

@@ -65,7 +67,7 @@ static void dd(const char *fmt, ...) {
6567

6668
#endif
6769

68-
#if defined(DDEBUG) && (DDEBUG)
70+
#if defined(MODSECURITY_DDEBUG) && (MODSECURITY_DDEBUG)
6971

7072
#define dd_check_read_event_handler(r) \
7173
dd("r->read_event_handler = %s", \

src/ngx_http_modsecurity_body_filter.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
*
1414
*/
1515

16-
#ifndef DDEBUG
17-
#define DDEBUG 0
16+
#ifndef MODSECURITY_DDEBUG
17+
#define MODSECURITY_DDEBUG 0
1818
#endif
1919
#include "ddebug.h"
2020

@@ -38,7 +38,7 @@ ngx_http_modsecurity_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
3838
int buffer_fully_loadead = 0;
3939
ngx_chain_t *chain = in;
4040
ngx_http_modsecurity_ctx_t *ctx = NULL;
41-
#ifdef MODSECURITY_SANITY_CHECKS
41+
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
4242
ngx_http_modsecurity_loc_conf_t *loc_cf = NULL;
4343
ngx_list_part_t *part = &r->headers_out.headers.part;
4444
ngx_table_elt_t *data = part->elts;
@@ -57,7 +57,7 @@ ngx_http_modsecurity_body_filter(ngx_http_request_t *r, ngx_chain_t *in)
5757
return ngx_http_next_body_filter(r, in);
5858
}
5959

60-
#ifdef MODSECURITY_SANITY_CHECKS
60+
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
6161
loc_cf = ngx_http_get_module_loc_conf(r, ngx_http_modsecurity);
6262
if (loc_cf != NULL && loc_cf->sanity_checks_enabled != NGX_CONF_UNSET)
6363
{

src/ngx_http_modsecurity_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ ngx_int_t ngx_http_modsecurity_body_filter(ngx_http_request_t *r, ngx_chain_t *i
9898
/* ngx_http_modsecurity_header_filter.c */
9999
ngx_int_t ngx_http_modsecurity_header_filter_init(void);
100100
ngx_int_t ngx_http_modsecurity_header_filter(ngx_http_request_t *r);
101-
#ifdef MODSECURITY_SANITY_CHECKS
101+
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
102102
int ngx_http_modescurity_store_ctx_header(ngx_http_request_t *r, ngx_str_t *name, ngx_str_t *value);
103103
#endif
104104

src/ngx_http_modsecurity_header_filter.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
*
1414
*/
1515

16-
#ifndef DDEBUG
17-
#define DDEBUG 0
16+
#ifndef MODSECURITY_DDEBUG
17+
#define MODSECURITY_DDEBUG 0
1818
#endif
1919
#include "ddebug.h"
2020

@@ -99,7 +99,7 @@ ngx_http_modsecurity_header_out_t ngx_http_modsecurity_headers_out[] = {
9999
};
100100

101101

102-
#ifdef MODSECURITY_SANITY_CHECKS
102+
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
103103
int
104104
ngx_http_modescurity_store_ctx_header(ngx_http_request_t *r, ngx_str_t *name, ngx_str_t *value)
105105
{
@@ -166,7 +166,7 @@ ngx_http_modsecurity_resolv_header_server(ngx_http_request_t *r, ngx_str_t name,
166166
value.len = h->value.len;
167167
}
168168

169-
#ifdef MODSECURITY_SANITY_CHECKS
169+
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
170170
ngx_http_modescurity_store_ctx_header(r, &name, &value);
171171
#endif
172172

@@ -195,7 +195,7 @@ ngx_http_modsecurity_resolv_header_date(ngx_http_request_t *r, ngx_str_t name, o
195195
date.len = h->value.len;
196196
}
197197

198-
#ifdef MODSECURITY_SANITY_CHECKS
198+
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
199199
ngx_http_modescurity_store_ctx_header(r, &name, &date);
200200
#endif
201201

@@ -222,7 +222,7 @@ ngx_http_modsecurity_resolv_header_content_length(ngx_http_request_t *r, ngx_str
222222
value.data = (unsigned char *)buf;
223223
value.len = strlen(buf);
224224

225-
#ifdef MODSECURITY_SANITY_CHECKS
225+
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
226226
ngx_http_modescurity_store_ctx_header(r, &name, &value);
227227
#endif
228228
return msc_add_n_response_header(ctx->modsec_transaction,
@@ -246,7 +246,7 @@ ngx_http_modsecurity_resolv_header_content_type(ngx_http_request_t *r, ngx_str_t
246246
if (r->headers_out.content_type.len > 0)
247247
{
248248

249-
#ifdef MODSECURITY_SANITY_CHECKS
249+
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
250250
ngx_http_modescurity_store_ctx_header(r, &name, &r->headers_out.content_type);
251251
#endif
252252

@@ -279,7 +279,7 @@ ngx_http_modsecurity_resolv_header_last_modified(ngx_http_request_t *r, ngx_str_
279279
value.data = buf;
280280
value.len = (int)(p-buf);
281281

282-
#ifdef MODSECURITY_SANITY_CHECKS
282+
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
283283
ngx_http_modescurity_store_ctx_header(r, &name, &value);
284284
#endif
285285

@@ -315,7 +315,7 @@ ngx_http_modsecurity_resolv_header_connection(ngx_http_request_t *r, ngx_str_t n
315315
value.data = buf;
316316
value.len = strlen((char *)buf);
317317

318-
#ifdef MODSECURITY_SANITY_CHECKS
318+
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
319319
ngx_http_modescurity_store_ctx_header(r, &name2, &value);
320320
#endif
321321

@@ -332,7 +332,7 @@ ngx_http_modsecurity_resolv_header_connection(ngx_http_request_t *r, ngx_str_t n
332332
value.data = (u_char *) connection;
333333
value.len = strlen(connection);
334334

335-
#ifdef MODSECURITY_SANITY_CHECKS
335+
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
336336
ngx_http_modescurity_store_ctx_header(r, &name, &value);
337337
#endif
338338

@@ -353,7 +353,7 @@ ngx_http_modsecurity_resolv_header_transfer_encoding(ngx_http_request_t *r, ngx_
353353

354354
ctx = ngx_http_get_module_ctx(r, ngx_http_modsecurity);
355355

356-
#ifdef MODSECURITY_SANITY_CHECKS
356+
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
357357
ngx_http_modescurity_store_ctx_header(r, &name, &value);
358358
#endif
359359

@@ -380,7 +380,7 @@ ngx_http_modsecurity_resolv_header_vary(ngx_http_request_t *r, ngx_str_t name, o
380380

381381
ctx = ngx_http_get_module_ctx(r, ngx_http_modsecurity);
382382

383-
#ifdef MODSECURITY_SANITY_CHECKS
383+
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
384384
ngx_http_modescurity_store_ctx_header(r, &name, &value);
385385
#endif
386386

@@ -486,7 +486,7 @@ ngx_http_modsecurity_header_filter(ngx_http_request_t *r)
486486
i = 0;
487487
}
488488

489-
#ifdef MODSECURITY_SANITY_CHECKS
489+
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
490490
ngx_http_modescurity_store_ctx_header(r, &data[i].key, &data[i].value);
491491
#endif
492492

src/ngx_http_modsecurity_log.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
*
1414
*/
1515

16-
#ifndef DDEBUG
17-
#define DDEBUG 0
16+
#ifndef MODSECURITY_DDEBUG
17+
#define MODSECURITY_DDEBUG 0
1818
#endif
1919
#include "ddebug.h"
2020

src/ngx_http_modsecurity_module.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
*
1414
*/
1515

16-
#ifndef DDEBUG
17-
#define DDEBUG 0
16+
#ifndef MODSECURITY_DDEBUG
17+
#define MODSECURITY_DDEBUG 0
1818
#endif
1919
#include "ddebug.h"
2020

@@ -107,7 +107,7 @@ ngx_http_modsecurity_process_intervention (Transaction *transaction, ngx_http_re
107107
r->headers_out.location = location;
108108
r->headers_out.location->hash = 1;
109109

110-
#ifdef MODSECURITY_SANITY_CHECKS
110+
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
111111
ngx_http_modescurity_store_ctx_header(r, &location->key, &location->value);
112112
#endif
113113

@@ -137,7 +137,7 @@ ngx_http_modsecurity_cleanup(void *data)
137137

138138
msc_transaction_cleanup(ctx->modsec_transaction);
139139

140-
#ifdef MODSECURITY_SANITY_CHECKS
140+
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
141141
/*
142142
* Purge stored context headers. Memory allocated for individual stored header
143143
* name/value pair will be freed automatically when r->pool is destroyed.
@@ -181,7 +181,7 @@ ngx_http_modsecurity_create_ctx(ngx_http_request_t *r)
181181
cln->handler = ngx_http_modsecurity_cleanup;
182182
cln->data = ctx;
183183

184-
#ifdef MODSECURITY_SANITY_CHECKS
184+
#if defined(MODSECURITY_SANITY_CHECKS) && (MODSECURITY_SANITY_CHECKS)
185185
ctx->sanity_headers_out = ngx_array_create(r->pool, 12, sizeof(ngx_http_modsecurity_header_t));
186186
if (ctx->sanity_headers_out == NULL) {
187187
return NGX_CONF_ERROR;

src/ngx_http_modsecurity_pre_access.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
*
1414
*/
1515

16-
#ifndef DDEBUG
17-
#define DDEBUG 0
16+
#ifndef MODSECURITY_DDEBUG
17+
#define MODSECURITY_DDEBUG 0
1818
#endif
1919
#include "ddebug.h"
2020

src/ngx_http_modsecurity_rewrite.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
*
1414
*/
1515

16-
#ifndef DDEBUG
17-
#define DDEBUG 0
16+
#ifndef MODSECURITY_DDEBUG
17+
#define MODSECURITY_DDEBUG 0
1818
#endif
1919
#include "ddebug.h"
2020

0 commit comments

Comments
 (0)