Skip to content

Commit 8484662

Browse files
committed
modsecurity: unnecessary const cast
Also fix style and remove nonsense comment.
1 parent 0e2858d commit 8484662

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed

src/ngx_http_modsecurity_header_filter.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,9 @@ ngx_http_modsecurity_header_filter(ngx_http_request_t *r)
7777
continue;
7878
}
7979

80-
/*
81-
* Doing this ugly cast here, explanation on the request_header
82-
*/
8380
msc_add_n_response_header(ctx->modsec_transaction,
84-
(const unsigned char *) header[i].key.data, header[i].key.len,
85-
(const unsigned char *) header[i].value.data, header[i].value.len);
81+
header[i].key.data, header[i].key.len,
82+
header[i].value.data, header[i].value.len);
8683
}
8784

8885
/* prepare extra paramters for msc_process_response_headers() */

src/ngx_http_modsecurity_rewrite.c

Lines changed: 11 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -234,46 +234,35 @@ ngx_http_modsecurity_process_url(ngx_http_request_t *r)
234234
static ngx_int_t
235235
ngx_http_modsecurity_process_req_header(ngx_http_request_t *r)
236236
{
237+
ngx_uint_t i;
237238
ngx_pool_t *old_pool;
239+
ngx_list_part_t *part;
240+
ngx_table_elt_t *header;
238241
ngx_http_modsecurity_ctx_t *ctx;
239242

240243
ctx = ngx_http_get_module_ctx(r, ngx_http_modsecurity_module);
241244
if (ctx == NULL) {
242245
return NGX_ERROR;
243246
}
244247

245-
/**
246-
* Since incoming request headers are already in place, lets send it to ModSecurity
247-
*
248-
*/
249-
ngx_list_part_t *part = &r->headers_in.headers.part;
250-
ngx_table_elt_t *data = part->elts;
251-
ngx_uint_t i = 0;
252-
for (i = 0 ; /* void */ ; i++) {
248+
part = &r->headers_in.headers.part;
249+
header = part->elts;
250+
251+
for (i = 0; /* void */; i++) {
252+
253253
if (i >= part->nelts) {
254254
if (part->next == NULL) {
255255
break;
256256
}
257257

258258
part = part->next;
259-
data = part->elts;
259+
header = part->elts;
260260
i = 0;
261261
}
262262

263-
/**
264-
* By using u_char (utf8_t) I believe nginx is hoping to deal
265-
* with utf8 strings.
266-
* Casting those into to unsigned char * in order to pass
267-
* it to ModSecurity, it will handle with those later.
268-
*
269-
*/
270-
271-
dd("Adding request header: %.*s with value %.*s", (int)data[i].key.len, data[i].key.data, (int) data[i].value.len, data[i].value.data);
272263
msc_add_n_request_header(ctx->modsec_transaction,
273-
(const unsigned char *) data[i].key.data,
274-
data[i].key.len,
275-
(const unsigned char *) data[i].value.data,
276-
data[i].value.len);
264+
header[i].key.data, header[i].key.len,
265+
header[i].value.data, header[i].value.len);
277266
}
278267

279268
/**

0 commit comments

Comments
 (0)