Skip to content

Commit 58e1ce2

Browse files
authored
Merge pull request #260 from defanator/pcre2
Support for building with nginx configured with PCRE2
2 parents 2497e6a + dc9db25 commit 58e1ce2

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

Diff for: src/ngx_http_modsecurity_common.h

+5
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,13 @@ extern ngx_module_t ngx_http_modsecurity_module;
140140
int ngx_http_modsecurity_process_intervention (Transaction *transaction, ngx_http_request_t *r, ngx_int_t early_log);
141141
ngx_http_modsecurity_ctx_t *ngx_http_modsecurity_create_ctx(ngx_http_request_t *r);
142142
char *ngx_str_to_char(ngx_str_t a, ngx_pool_t *p);
143+
#if (NGX_PCRE2)
144+
#define ngx_http_modsecurity_pcre_malloc_init(x) NULL
145+
#define ngx_http_modsecurity_pcre_malloc_done(x) (void)x
146+
#else
143147
ngx_pool_t *ngx_http_modsecurity_pcre_malloc_init(ngx_pool_t *pool);
144148
void ngx_http_modsecurity_pcre_malloc_done(ngx_pool_t *old_pool);
149+
#endif
145150

146151
/* ngx_http_modsecurity_body_filter.c */
147152
ngx_int_t ngx_http_modsecurity_body_filter_init(void);

Diff for: src/ngx_http_modsecurity_module.c

+2
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ static void ngx_http_modsecurity_cleanup_rules(void *data);
3838
* https://github.com/openresty/lua-nginx-module/blob/master/src/ngx_http_lua_pcrefix.c
3939
*/
4040

41+
#if !(NGX_PCRE2)
4142
static void *(*old_pcre_malloc)(size_t);
4243
static void (*old_pcre_free)(void *ptr);
4344
static ngx_pool_t *ngx_http_modsec_pcre_pool = NULL;
@@ -103,6 +104,7 @@ ngx_http_modsecurity_pcre_malloc_done(ngx_pool_t *old_pool)
103104
pcre_free = old_pcre_free;
104105
}
105106
}
107+
#endif
106108

107109
/*
108110
* ngx_string's are not null-terminated in common case, so we need to convert

0 commit comments

Comments
 (0)