@@ -807,10 +807,10 @@ ngx_http_modsecurity_save_headers_out_visitor(void *data,
807
807
{
808
808
ngx_http_request_t * r = data ;
809
809
ngx_table_elt_t * h , he , * new_h ;
810
- ngx_http_upstream_header_t * hh ;
811
- ngx_http_upstream_main_conf_t * umcf ;
810
+ // ngx_http_upstream_header_t *hh;
811
+ // ngx_http_upstream_main_conf_t *umcf;
812
812
813
- umcf = ngx_http_get_module_main_conf (r , ngx_http_upstream_module );
813
+ // umcf = ngx_http_get_module_main_conf(r, ngx_http_upstream_module);
814
814
815
815
h = & he ;
816
816
@@ -829,31 +829,37 @@ ngx_http_modsecurity_save_headers_out_visitor(void *data,
829
829
830
830
h -> hash = ngx_hash_key (h -> lowcase_key , h -> key .len );
831
831
832
- hh = ngx_hash_find (& umcf -> headers_in_hash , h -> hash ,
833
- h -> lowcase_key , h -> key .len );
834
-
835
- if ( hh ) {
836
- /* copy all */
837
- if ( hh -> copy_handler ( r , h , hh -> conf ) != NGX_OK ) {
838
- return 0 ;
839
- }
840
- } else {
841
- /* Add the response header directly to headers_out if not present in
842
- * the hash. This is done to passthrough such response headers.
843
- * Remember the response headers were cleared earlier using
844
- * ngx_http_clean_header(r) call in ngx_http_modsecurity_save_headers_out.
845
- */
846
-
847
- new_h = ngx_list_push ( & r -> headers_out . headers );
848
- if ( new_h == NULL ) {
849
- return NGX_ERROR ;
850
- }
832
+ // hh = ngx_hash_find(&umcf->headers_in_hash, h->hash,
833
+ // h->lowcase_key, h->key.len);
834
+
835
+ // While using proxy_pass with a combination of other factores
836
+ // there seems to be a memory corruption if we use hh->copy_handler.
837
+ // Temporary using new_h. This demand a further investigation.
838
+ //
839
+ //if (hh) {
840
+ // /* copy all */
841
+ // if (hh->copy_handler(r, h, hh->conf) != NGX_OK) {
842
+ // return 0;
843
+ // }
844
+ //} else {
845
+
846
+ /* Add the response header directly to headers_out if not present in
847
+ * the hash. This is done to passthrough such response headers.
848
+ * Remember the response headers were cleared earlier using
849
+ * ngx_http_clean_header(r) call in ngx_http_modsecurity_save_headers_out.
850
+ */
851
851
852
- new_h -> hash = h -> hash ;
853
- new_h -> key = h -> key ;
854
- new_h -> value = h -> value ;
852
+ new_h = ngx_list_push ( & r -> headers_out . headers ) ;
853
+ if ( new_h == NULL ) {
854
+ return NGX_ERROR ;
855
855
}
856
856
857
+ new_h -> hash = h -> hash ;
858
+ new_h -> key = h -> key ;
859
+ new_h -> value = h -> value ;
860
+
861
+ // }
862
+
857
863
ngx_log_debug2 (NGX_LOG_DEBUG_HTTP , r -> connection -> log , 0 ,
858
864
"ModSecurity: save headers out: \"%V: %V\"" ,
859
865
& h -> key , & h -> value );
0 commit comments