aboutsummaryrefslogtreecommitdiffstats
path: root/main/musl/0013-fix-the-use-of-uninitialized-value-in-regcomp.patch
blob: fe239ff6528a09a9c8649b70e51db9f59c9df299 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
From 51eeb6ebc94d965768143c45e9f39b0a7998bdbd Mon Sep 17 00:00:00 2001
From: Szabolcs Nagy <nsz@port70.net>
Date: Sat, 21 May 2016 15:21:38 +0200
Subject: [PATCH] fix the use of uninitialized value in regcomp

the num_submatches field of some ast nodes was not initialized in
tre_add_tag_{left,right}, but was accessed later.

this was a benign bug since the uninitialized values were never used
(these values are created during tre_add_tags and copied around during
tre_expand_ast where they are also used in computations, but nothing
in the final tnfa depends on them).
---
 src/regex/regcomp.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/src/regex/regcomp.c b/src/regex/regcomp.c
index 5fad98b..65f2fd0 100644
--- a/src/regex/regcomp.c
+++ b/src/regex/regcomp.c
@@ -1106,6 +1106,7 @@ tre_add_tag_left(tre_mem_t mem, tre_ast_node_t *node, int tag_id)
   c->right->firstpos = NULL;
   c->right->lastpos = NULL;
   c->right->num_tags = 0;
+  c->right->num_submatches = 0;
   node->obj = c;
   node->type = CATENATION;
   return REG_OK;
@@ -1136,6 +1137,7 @@ tre_add_tag_right(tre_mem_t mem, tre_ast_node_t *node, int tag_id)
   c->left->firstpos = NULL;
   c->left->lastpos = NULL;
   c->left->num_tags = 0;
+  c->left->num_submatches = 0;
   node->obj = c;
   node->type = CATENATION;
   return REG_OK;
-- 
2.9.1