2
1

0001-naxsi_src-naxsi_runtime.c-fix-build-without-x_forwar.patch 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. From 8ea5218b07f715e9616a846bf305633ef1b3aa2a Mon Sep 17 00:00:00 2001
  2. From: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  3. Date: Sat, 14 Aug 2021 11:46:08 +0200
  4. Subject: [PATCH] naxsi_src/naxsi_runtime.c: fix build without x_forwarded_for
  5. x_forwarded_for is not available if realip, geo, geoip or proxy modules
  6. aren't enabled resulting in the following build failure since version
  7. 1.1a and
  8. https://github.com/nbs-system/naxsi/commit/07a056ccd36bc3c5c40dc17991db226cb8cf6241:
  9. /home/buildroot/autobuild/instance-3/output-1/build/nginx-naxsi-1.3/naxsi_src/naxsi_runtime.c: In function 'ngx_http_naxsi_data_parse':
  10. /home/buildroot/autobuild/instance-3/output-1/build/nginx-naxsi-1.3/naxsi_src/naxsi_runtime.c:2846:20: error: 'ngx_http_headers_in_t' has no member named 'x_forwarded_for'
  11. if (r->headers_in.x_forwarded_for.nelts >= 1) {
  12. ^
  13. Fixes:
  14. - http://autobuild.buildroot.org/results/cdbc1536f6b5de3d4c836efa2f0dcaf0cdbb1462
  15. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
  16. [Upstream status: https://github.com/nbs-system/naxsi/pull/568]
  17. ---
  18. naxsi_src/naxsi_runtime.c | 7 ++++++-
  19. 1 file changed, 6 insertions(+), 1 deletion(-)
  20. diff --git a/naxsi_src/naxsi_runtime.c b/naxsi_src/naxsi_runtime.c
  21. index 28e0b29..6a723d2 100644
  22. --- a/naxsi_src/naxsi_runtime.c
  23. +++ b/naxsi_src/naxsi_runtime.c
  24. @@ -2842,10 +2842,12 @@ ngx_http_naxsi_data_parse(ngx_http_request_ctx_t* ctx, ngx_http_request_t* r)
  25. unsigned int n = 0;
  26. ngx_table_elt_t** h = NULL;
  27. ngx_array_t a;
  28. +#if (NGX_HTTP_X_FORWARDED_FOR)
  29. if (r->headers_in.x_forwarded_for.nelts >= 1) {
  30. a = r->headers_in.x_forwarded_for;
  31. n = a.nelts;
  32. }
  33. +#endif
  34. if (n >= 1)
  35. h = a.elts;
  36. if (n >= 1) {
  37. @@ -2879,6 +2881,7 @@ ngx_http_naxsi_update_current_ctx_status(ngx_http_request_ctx_t* ctx,
  38. /*cr, sc, cf, ctx*/
  39. if (cf->check_rules && ctx->special_scores) {
  40. +#if (NGX_HTTP_X_FORWARDED_FOR)
  41. if (r->headers_in.x_forwarded_for.nelts >= 1) {
  42. a = r->headers_in.x_forwarded_for;
  43. n = a.nelts;
  44. @@ -2896,7 +2899,9 @@ ngx_http_naxsi_update_current_ctx_status(ngx_http_request_ctx_t* ctx,
  45. memcpy(ip.data, h[0]->value.data, ip.len);
  46. ignore = nx_can_ignore_ip(&ip, cf) || nx_can_ignore_cidr(&ip, cf);
  47. }
  48. - } else {
  49. + } else
  50. +#endif
  51. + {
  52. ngx_str_t* ip = &r->connection->addr_text;
  53. NX_DEBUG(_debug_whitelist_ignore,
  54. NGX_LOG_DEBUG_HTTP,
  55. --
  56. 2.30.2