Skip to content

Commit 6e7a065

Browse files
committed
Resolving conflict.
2 parents a4c7568 + bfdb28e commit 6e7a065

File tree

3 files changed

+37
-19
lines changed

3 files changed

+37
-19
lines changed

CHANGES

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,17 @@
2323

2424
* Fixed DROP action was disabled for Apache 2 module by mistake.
2525

26+
<<<<<<< HEAD
2627
* Fixed bug when use ctl:ruleRemoveByTag.
28+
=======
29+
* Fixed bug when use ctl:ruleRemoveTargetByTag.
30+
31+
* Fixed IIS and NGINX modules bugs.
32+
33+
* Fixed bug when @strmatch patterns use invalid escape sequence (Thanks Hideaki Hayashi).
34+
35+
* Fixed bugs in @verifySSN (Thanks Hideaki Hayashi).
36+
>>>>>>> upstream/master
2737

2838
* The doc/ directory now contains the instructions to access online documentation.
2939

apache2/re_operators.c

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2394,6 +2394,7 @@ static int msre_op_endsWith_execute(modsec_rec *msr, msre_rule *rule, msre_var *
23942394

23952395
static int msre_op_strmatch_param_init(msre_rule *rule, char **error_msg) {
23962396
const apr_strmatch_pattern *compiled_pattern;
2397+
char *processed = NULL;
23972398
const char *pattern = rule->op_param;
23982399
unsigned short int op_len;
23992400

@@ -2402,8 +2403,14 @@ static int msre_op_strmatch_param_init(msre_rule *rule, char **error_msg) {
24022403

24032404
op_len = strlen(pattern);
24042405

2406+
/* Process pattern */
2407+
processed = parse_pm_content(pattern, op_len, rule, error_msg);
2408+
if (processed == NULL) {
2409+
return 0;
2410+
}
2411+
24052412
/* Compile pattern */
2406-
compiled_pattern = apr_strmatch_precompile(rule->ruleset->mp, parse_pm_content(pattern, op_len, rule, error_msg), 1);
2413+
compiled_pattern = apr_strmatch_precompile(rule->ruleset->mp, processed, 1);
24072414
if (compiled_pattern == NULL) {
24082415
*error_msg = apr_psprintf(rule->ruleset->mp, "Error compiling pattern: %s", pattern);
24092416
return 0;
@@ -3163,40 +3170,35 @@ static int ssn_verify(modsec_rec *msr, const char *ssnumber, int len) {
31633170
int area, serial, grp;
31643171
int sequencial = 0;
31653172
int repetitions = 0;
3166-
int progression = 0;
31673173
char *str_area;
31683174
char *str_grp;
31693175
char *str_serial;
31703176

31713177
for (i = 0; i < len; i++) {
31723178
if (apr_isdigit(ssnumber[i])) {
3173-
num[i] = convert_to_int(ssnumber[i]);
3174-
digits++;
3179+
if (digits < 9)
3180+
num[digits] = convert_to_int(ssnumber[i]);
3181+
digits++;
31753182
}
31763183
}
31773184

31783185
/* Not a valid number */
31793186
if (digits != 9)
31803187
goto invalid;
31813188

3182-
digits = 0;
3183-
3184-
for (i=0; i < len-1; i++) {
3185-
progression = (num[i] - (num[i+1]-1));
3186-
repetitions = (num[i] - num[i+1]);
3189+
for (i=0; i < 8; i++) {
3190+
if (num[i] == (num[i+1]-1))
3191+
sequencial++;
31873192

3188-
if (repetitions != 0 )
3189-
sequencial = 1;
3190-
3191-
if (progression == 0)
3192-
digits++;
3193+
if (num[i] == num[i+1])
3194+
repetitions++;
31933195
}
31943196

3195-
/* We are blocking when all numbers were repeated */
3196-
if (sequencial == 0)
3197+
/* We are blocking when all numbers were sequencial or repeated */
3198+
if (sequencial == 8)
31973199
goto invalid;
31983200

3199-
if (digits == 8)
3201+
if (repetitions == 8)
32003202
goto invalid;
32013203

32023204
str_area = apr_psprintf(msr->mp,"%d%d%d",num[0],num[1],num[2]);

nginx/modsecurity/ngx_http_modsecurity.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,9 @@ ngx_http_do_read_upload_client_request_body(ngx_http_request_t *r)
488488
if (rb->buf->last == rb->buf->end) {
489489

490490
rc = ngx_http_process_request_body(r, rb->to_write);
491+
if(rc != NGX_OK) {
492+
return rc;
493+
}
491494

492495
rb->to_write = rb->bufs->next ? rb->bufs->next : rb->bufs;
493496
rb->buf->last = rb->buf->start;
@@ -555,7 +558,10 @@ ngx_http_do_read_upload_client_request_body(ngx_http_request_t *r)
555558
ngx_del_timer(c->read);
556559
}
557560

558-
ngx_http_process_request_body(r, rb->to_write);
561+
rc = ngx_http_process_request_body(r, rb->to_write);
562+
if(rc != NGX_OK) {
563+
return rc;
564+
}
559565

560566
return ngx_http_upload_body_handler(r);
561567
}
@@ -779,7 +785,7 @@ modsecurity_read_body_cb(request_rec *r, char *buf, unsigned int length,
779785
if (!ctx->body_pos) {
780786
ctx->body_pos = b->start;
781787
}
782-
if ((b->end - ctx->body_pos) > length) {
788+
if ((unsigned int)(b->end - ctx->body_pos) > length) {
783789
ngx_memcpy(buf, (char *) ctx->body_pos, length);
784790
ctx->processed += length;
785791
ctx->body_pos += length;

0 commit comments

Comments
 (0)