Skip to content

Commit 9722758

Browse files
committed
fix: heap buffer overflow in acmp pm
1 parent 7f37ad4 commit 9722758

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

apache2/acmp.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -514,17 +514,18 @@ 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 */
519519
for (j = 0; j <= i; j++) child->text[j] = pattern[j];
520520
}
521521
if (i == length - 1) {
522522
if (child->is_last == 0) {
523523
parser->dict_count++;
524524
child->is_last = 1;
525-
child->pattern = apr_pcalloc(parser->pool, strlen(pattern) + 2);
525+
child->pattern = apr_pcalloc(parser->pool, length + 1);
526526
/* ENH: Check alloc succeded */
527-
strcpy(child->pattern, pattern);
527+
memcpy(child->pattern, pattern, length);
528+
child->pattern[length] = '\0';
528529
}
529530
child->callback = callback;
530531
child->callback_data = data;

0 commit comments

Comments
 (0)