Skip to content

Commit

Permalink
Merge pull request #260 from defanator/pcre2
Browse files Browse the repository at this point in the history
Support for building with nginx configured with PCRE2
  • Loading branch information
martinhsv authored Apr 13, 2022
2 parents 2497e6a + dc9db25 commit 58e1ce2
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ngx_http_modsecurity_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,13 @@ extern ngx_module_t ngx_http_modsecurity_module;
int ngx_http_modsecurity_process_intervention (Transaction *transaction, ngx_http_request_t *r, ngx_int_t early_log);
ngx_http_modsecurity_ctx_t *ngx_http_modsecurity_create_ctx(ngx_http_request_t *r);
char *ngx_str_to_char(ngx_str_t a, ngx_pool_t *p);
#if (NGX_PCRE2)
#define ngx_http_modsecurity_pcre_malloc_init(x) NULL
#define ngx_http_modsecurity_pcre_malloc_done(x) (void)x
#else
ngx_pool_t *ngx_http_modsecurity_pcre_malloc_init(ngx_pool_t *pool);
void ngx_http_modsecurity_pcre_malloc_done(ngx_pool_t *old_pool);
#endif

/* ngx_http_modsecurity_body_filter.c */
ngx_int_t ngx_http_modsecurity_body_filter_init(void);
Expand Down
2 changes: 2 additions & 0 deletions src/ngx_http_modsecurity_module.c
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ static void ngx_http_modsecurity_cleanup_rules(void *data);
* https://github.com/openresty/lua-nginx-module/blob/master/src/ngx_http_lua_pcrefix.c
*/

#if !(NGX_PCRE2)
static void *(*old_pcre_malloc)(size_t);
static void (*old_pcre_free)(void *ptr);
static ngx_pool_t *ngx_http_modsec_pcre_pool = NULL;
Expand Down Expand Up @@ -103,6 +104,7 @@ ngx_http_modsecurity_pcre_malloc_done(ngx_pool_t *old_pool)
pcre_free = old_pcre_free;
}
}
#endif

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

0 comments on commit 58e1ce2

Please sign in to comment.