Skip to content

Commit 3654bce

Browse files
authored
Merge pull request #3545 from airween/v2/acmppmfix
fix: heap buffer overflow in acmp pm
2 parents 7de5586 + 86668b0 commit 3654bce

1 file changed

Lines changed: 7 additions & 4 deletions

File tree

apache2/acmp.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -514,17 +514,20 @@ apr_status_t acmp_add_pattern(ACMP *parser, const char *pattern,
514514
child->pattern = "";
515515
child->letter = letter;
516516
child->depth = i;
517-
child->text = apr_pcalloc(parser->pool, strlen(pattern) + 2);
517+
child->text = apr_pcalloc(parser->pool, i + 2);
518518
/* ENH: Check alloc succeded */
519-
for (j = 0; j <= i; j++) child->text[j] = pattern[j];
519+
for (j = 0; j <= i; j++) {
520+
child->text[j] = pattern[j];
521+
}
520522
}
521523
if (i == length - 1) {
522524
if (child->is_last == 0) {
523525
parser->dict_count++;
524526
child->is_last = 1;
525-
child->pattern = apr_pcalloc(parser->pool, strlen(pattern) + 2);
527+
child->pattern = apr_pcalloc(parser->pool, length + 1);
526528
/* ENH: Check alloc succeded */
527-
strcpy(child->pattern, pattern);
529+
memcpy(child->pattern, pattern, length);
530+
child->pattern[length] = '\0';
528531
}
529532
child->callback = callback;
530533
child->callback_data = data;

0 commit comments

Comments
 (0)