Skip to content

Commit 4c8fe90

Browse files
committed
Limit pattern to fix stack overflow with some large strings
1 parent e6161e5 commit 4c8fe90

File tree

2 files changed

+108
-27
lines changed

2 files changed

+108
-27
lines changed

compiler_output_parser.hpp

+28-25
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ inline CompilerOutputLineInfo GetCompilerOutputLineInfo(std::string_view line)
6767
}
6868
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):[[:blank:]]+([iI]n
6969
//([cC]lass|[cC]onstructor|[dD]estructor|[fF]unction|[mM]ember [fF]unction).*)]]>
70-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):[[:blank:]]+([iI]n "
70+
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):[[:blank:]]+([iI]n "
7171
"([cC]lass|[cC]onstructor|[dD]estructor|[fF]unction|[mM]ember [fF]unction).*)">(line))
7272
{
7373
static constexpr CompilerRegexInfo compilerRegexInfo = {
@@ -76,7 +76,7 @@ inline CompilerOutputLineInfo GetCompilerOutputLineInfo(std::string_view line)
7676
}
7777
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):([0-9]+):[0-9]+:[[:blank:]]+(\[[[:blank:]]+[Ss]kipping [0-9]+ instantiation
7878
// contexts[[:blank:]]+\])]]>
79-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):([0-9]+):[0-9]+:[[:blank:]]+(\\[[[:blank:]]+[Ss]kipping "
79+
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):([0-9]+):[0-9]+:[[:blank:]]+(\\[[[:blank:]]+[Ss]kipping "
8080
"[0-9]+ instantiation contexts[[:blank:]]+\\])">(line))
8181
{
8282
static constexpr CompilerRegexInfo compilerRegexInfo = {.name = "'Skipping N instantiation contexts' info (2)",
@@ -88,7 +88,7 @@ inline CompilerOutputLineInfo GetCompilerOutputLineInfo(std::string_view line)
8888
}
8989
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):([0-9]+):[[:blank:]]+(\[[[:blank:]]+[Ss]kipping [0-9]+ instantiation
9090
// contexts[[:blank:]]+\])]]>
91-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):([0-9]+):[[:blank:]]+(\\[[[:blank:]]+[Ss]kipping "
91+
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):([0-9]+):[[:blank:]]+(\\[[[:blank:]]+[Ss]kipping "
9292
"[0-9]+ instantiation contexts[[:blank:]]+\\])">(line))
9393
{
9494
static constexpr CompilerRegexInfo compilerRegexInfo = {.name = "'Skipping N instantiation contexts' info",
@@ -99,35 +99,36 @@ inline CompilerOutputLineInfo GetCompilerOutputLineInfo(std::string_view line)
9999
POPULATE_INFO(ret, m, compilerRegexInfo);
100100
}
101101
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):[[:blank:]]+([Ii]n [Ii]nstantiation.*)]]>
102-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):[[:blank:]]+([Ii]n [Ii]nstantiation.*)">(line))
102+
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):[[:blank:]]+([Ii]n [Ii]nstantiation.*)">(line))
103103
{
104104
static constexpr CompilerRegexInfo compilerRegexInfo = {
105105
.name = "'In instantiation' warning", .type = CompilerOutputLineType::warning, .fileNameIdx = 1, .lineIdx = 0, .messageIdx = 2};
106106
POPULATE_INFO(ret, m, compilerRegexInfo);
107107
}
108108
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):([0-9]+):[0-9]+:[[:blank:]]+([Rr]equired from.*)]]>
109-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):([0-9]+):[0-9]+:[[:blank:]]+([Rr]equired from.*)">(line))
109+
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):([0-9]+):[0-9]+:[[:blank:]]+([Rr]equired from.*)">(line))
110110
{
111111
static constexpr CompilerRegexInfo compilerRegexInfo = {
112112
.name = "'Required from' warning", .type = CompilerOutputLineType::warning, .fileNameIdx = 1, .lineIdx = 2, .messageIdx = 3};
113113
POPULATE_INFO(ret, m, compilerRegexInfo);
114114
}
115115
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):([0-9]+):[0-9]+:[[:blank:]]+([Ii]nstantiated from .*)]]>
116-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):([0-9]+):[0-9]+:[[:blank:]]+([Ii]nstantiated from .*)">(line))
116+
else if (auto m =
117+
ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):([0-9]+):[0-9]+:[[:blank:]]+([Ii]nstantiated from .*)">(line))
117118
{
118119
static constexpr CompilerRegexInfo compilerRegexInfo = {
119120
.name = "'Instantiated from' info (2)", .type = CompilerOutputLineType::info, .fileNameIdx = 1, .lineIdx = 2, .messageIdx = 3};
120121
POPULATE_INFO(ret, m, compilerRegexInfo);
121122
}
122123
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):([0-9]+):[[:blank:]]+([Ii]nstantiated from .*)]]>
123-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):([0-9]+):[[:blank:]]+([Ii]nstantiated from .*)">(line))
124+
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):([0-9]+):[[:blank:]]+([Ii]nstantiated from .*)">(line))
124125
{
125126
static constexpr CompilerRegexInfo compilerRegexInfo = {
126127
.name = "'Instantiated from' info", .type = CompilerOutputLineType::info, .fileNameIdx = 1, .lineIdx = 2, .messageIdx = 3};
127128
POPULATE_INFO(ret, m, compilerRegexInfo);
128129
}
129130
//<![CDATA[windres.exe:[[:blank:]]([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):([0-9]+):[[:blank:]](.*)]]>
130-
else if (auto m = ctre::match<"windres.exe:[[:blank:]]([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):([0-9]+):[[:blank:]](.*)">(line))
131+
else if (auto m = ctre::match<"windres.exe:[[:blank:]]([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):([0-9]+):[[:blank:]](.*)">(line))
131132
{
132133
static constexpr CompilerRegexInfo compilerRegexInfo = {
133134
.name = "Resource compiler error", .type = CompilerOutputLineType::error, .fileNameIdx = 1, .lineIdx = 2, .messageIdx = 3};
@@ -141,21 +142,22 @@ inline CompilerOutputLineInfo GetCompilerOutputLineInfo(std::string_view line)
141142
POPULATE_INFO(ret, m, compilerRegexInfo);
142143
}
143144
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):([0-9]+):([0-9]+):[[:blank:]]([Ww]arning:[[:blank:]].*)]]>
144-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):([0-9]+):([0-9]+):[[:blank:]]([Ww]arning:[[:blank:]].*)">(line))
145+
else if (auto m =
146+
ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):([0-9]+):([0-9]+):[[:blank:]]([Ww]arning:[[:blank:]].*)">(line))
145147
{
146148
static constexpr CompilerRegexInfo compilerRegexInfo = {
147149
.name = "Preprocessor warning", .type = CompilerOutputLineType::warning, .fileNameIdx = 1, .lineIdx = 2, .messageIdx = 4};
148150
POPULATE_INFO(ret, m, compilerRegexInfo);
149151
}
150152
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):([0-9]+):[0-9]+:[[:blank:]]([Nn]ote:[[:blank:]].*)]]>
151-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):([0-9]+):[0-9]+:[[:blank:]]([Nn]ote:[[:blank:]].*)">(line))
153+
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):([0-9]+):[0-9]+:[[:blank:]]([Nn]ote:[[:blank:]].*)">(line))
152154
{
153155
static constexpr CompilerRegexInfo compilerRegexInfo = {
154156
.name = "Compiler note (2)", .type = CompilerOutputLineType::info, .fileNameIdx = 1, .lineIdx = 2, .messageIdx = 3};
155157
POPULATE_INFO(ret, m, compilerRegexInfo);
156158
}
157159
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):([0-9]+):[[:blank:]]([Nn]ote:[[:blank:]].*)]]>
158-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):([0-9]+):[[:blank:]]([Nn]ote:[[:blank:]].*)">(line))
160+
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):([0-9]+):[[:blank:]]([Nn]ote:[[:blank:]].*)">(line))
159161
{
160162
static constexpr CompilerRegexInfo compilerRegexInfo = {
161163
.name = "Compiler note", .type = CompilerOutputLineType::info, .fileNameIdx = 1, .lineIdx = 2, .messageIdx = 3};
@@ -169,74 +171,75 @@ inline CompilerOutputLineInfo GetCompilerOutputLineInfo(std::string_view line)
169171
POPULATE_INFO(ret, m, compilerRegexInfo);
170172
}
171173
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):([0-9]+):[0-9]+:[[:blank:]](.*)]]>
172-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):([0-9]+):[0-9]+:[[:blank:]](.*)">(line))
174+
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):([0-9]+):[0-9]+:[[:blank:]](.*)">(line))
173175
{
174176
static constexpr CompilerRegexInfo compilerRegexInfo = {
175177
.name = "Preprocessor error", .type = CompilerOutputLineType::error, .fileNameIdx = 1, .lineIdx = 2, .messageIdx = 3};
176178
POPULATE_INFO(ret, m, compilerRegexInfo);
177179
}
178180
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):([0-9]+):[0-9]+:[[:blank:]]([Ww]arning:[[:blank:]].*)]]>
179-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):([0-9]+):[0-9]+:[[:blank:]]([Ww]arning:[[:blank:]].*)">(line))
181+
else if (auto m =
182+
ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):([0-9]+):[0-9]+:[[:blank:]]([Ww]arning:[[:blank:]].*)">(line))
180183
{
181184
static constexpr CompilerRegexInfo compilerRegexInfo = {
182185
.name = "Compiler warning (2)", .type = CompilerOutputLineType::warning, .fileNameIdx = 1, .lineIdx = 2, .messageIdx = 3};
183186
POPULATE_INFO(ret, m, compilerRegexInfo);
184187
}
185188
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):([0-9]+):[[:blank:]]([Ww]arning:[[:blank:]].*)]]>
186-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):([0-9]+):[[:blank:]]([Ww]arning:[[:blank:]].*)">(line))
189+
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):([0-9]+):[[:blank:]]([Ww]arning:[[:blank:]].*)">(line))
187190
{
188191
static constexpr CompilerRegexInfo compilerRegexInfo = {
189192
.name = "Compiler warning", .type = CompilerOutputLineType::warning, .fileNameIdx = 1, .lineIdx = 2, .messageIdx = 3};
190193
POPULATE_INFO(ret, m, compilerRegexInfo);
191194
}
192195
//<![CDATA[[][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+\.o:([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):([0-9]+):[[:blank:]](undefined
193196
// reference.*)]]>
194-
else if (auto m = ctre::match<"[{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+\\.o:([{}()[:blank:]#%$~[:alnum:]!&_:+/"
195-
"\\\\\\.\\-]+):([0-9]+):[[:blank:]](undefined reference.*)">(line))
197+
else if (auto m = ctre::match<"[{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}\\.o:([{}()[:blank:]#%$~[:alnum:]!&_:+/"
198+
"\\\\\\.\\-]{1,512}):([0-9]+):[[:blank:]](undefined reference.*)">(line))
196199
{
197200
static constexpr CompilerRegexInfo compilerRegexInfo = {
198201
.name = "Undefined reference (2)", .type = CompilerOutputLineType::error, .fileNameIdx = 1, .lineIdx = 2, .messageIdx = 3};
199202
POPULATE_INFO(ret, m, compilerRegexInfo);
200203
}
201204
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):([0-9]+):[0-9]+:[[:blank:]](.*)]]>
202-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):([0-9]+):[0-9]+:[[:blank:]](.*)">(line))
205+
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):([0-9]+):[0-9]+:[[:blank:]](.*)">(line))
203206
{
204207
static constexpr CompilerRegexInfo compilerRegexInfo = {
205208
.name = "Compiler error (2)", .type = CompilerOutputLineType::error, .fileNameIdx = 1, .lineIdx = 2, .messageIdx = 3};
206209
POPULATE_INFO(ret, m, compilerRegexInfo);
207210
}
208211
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):([0-9]+):[[:blank:]](.*)]]>
209-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):([0-9]+):[[:blank:]](.*)">(line))
212+
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):([0-9]+):[[:blank:]](.*)">(line))
210213
{
211214
static constexpr CompilerRegexInfo compilerRegexInfo = {
212215
.name = "Compiler error", .type = CompilerOutputLineType::error, .fileNameIdx = 1, .lineIdx = 2, .messageIdx = 3};
213216
POPULATE_INFO(ret, m, compilerRegexInfo);
214217
}
215218
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):\(\.text\+[0-9a-fA-FxX]+\):[[:blank:]]([Ww]arning:[[:blank:]].*)]]>
216219
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/"
217-
"\\\\\\.\\-]+):\\(\\.text\\+[0-9a-fA-FxX]+\\):[[:blank:]]([Ww]arning:[[:blank:]].*)">(line))
220+
"\\\\\\.\\-]{1,512}):\\(\\.text\\+[0-9a-fA-FxX]+\\):[[:blank:]]([Ww]arning:[[:blank:]].*)">(line))
218221
{
219222
static constexpr CompilerRegexInfo compilerRegexInfo = {
220223
.name = "Linker warning", .type = CompilerOutputLineType::warning, .fileNameIdx = 1, .lineIdx = 0, .messageIdx = 2};
221224
POPULATE_INFO(ret, m, compilerRegexInfo);
222225
}
223226
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):([0-9]+):[0-9]+:[[:blank:]](.*)]]>
224-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):([0-9]+):[0-9]+:[[:blank:]](.*)">(line))
227+
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):([0-9]+):[0-9]+:[[:blank:]](.*)">(line))
225228
{
226229
static constexpr CompilerRegexInfo compilerRegexInfo = {
227230
.name = "Linker error", .type = CompilerOutputLineType::error, .fileNameIdx = 1, .lineIdx = 2, .messageIdx = 3};
228231
POPULATE_INFO(ret, m, compilerRegexInfo);
229232
}
230233
//<![CDATA[[][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+\(.text\+[0-9A-Za-z]+\):([[:blank:]A-Za-z0-9_:+/\.-]+):[[:blank:]](.*)]]>
231-
else if (auto m = ctre::match<"[{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+\\(.text\\+[0-9A-Za-z]+\\):([[:blank:]A-Za-z0-9_:+/"
232-
"\\.\\-]+):[[:blank:]](.*)">(line))
234+
else if (auto m = ctre::match<"[{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}\\(.text\\+[0-9A-Za-z]+\\):([[:blank:]A-Za-z0-9_:+/"
235+
"\\.\\-]{1,512}):[[:blank:]](.*)">(line))
233236
{
234237
static constexpr CompilerRegexInfo compilerRegexInfo = {
235238
.name = "Linker error (2)", .type = CompilerOutputLineType::error, .fileNameIdx = 1, .lineIdx = 0, .messageIdx = 2};
236239
POPULATE_INFO(ret, m, compilerRegexInfo);
237240
}
238241
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):\(\.text\+[0-9a-fA-FxX]+\):(.*)]]>
239-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):\\(\\.text\\+[0-9a-fA-FxX]+\\):(.*)">(line))
242+
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):\\(\\.text\\+[0-9a-fA-FxX]+\\):(.*)">(line))
240243
{
241244
static constexpr CompilerRegexInfo compilerRegexInfo = {
242245
.name = "Linker error (3)", .type = CompilerOutputLineType::error, .fileNameIdx = 1, .lineIdx = 0, .messageIdx = 2};
@@ -279,7 +282,7 @@ inline CompilerOutputLineInfo GetCompilerOutputLineInfo(std::string_view line)
279282
POPULATE_INFO(ret, m, compilerRegexInfo);
280283
}
281284
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):[[:blank:]](undefined reference.*)]]>
282-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):[[:blank:]](undefined reference.*)">(line))
285+
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):[[:blank:]](undefined reference.*)">(line))
283286
{
284287
static constexpr CompilerRegexInfo compilerRegexInfo = {
285288
.name = "Undefined reference", .type = CompilerOutputLineType::error, .fileNameIdx = 1, .lineIdx = 0, .messageIdx = 2};
@@ -307,7 +310,7 @@ inline CompilerOutputLineInfo GetCompilerOutputLineInfo(std::string_view line)
307310
POPULATE_INFO(ret, m, compilerRegexInfo);
308311
}
309312
//<![CDATA[([][{}()[:blank:]#%$~[:alnum:]!&_:+/\\\.-]+):[[:blank:]]+(duplicate section.*has different size)]]>
310-
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]+):[[:blank:]]+(duplicate section.*has different size)">(line))
313+
else if (auto m = ctre::match<"([{}()[:blank:]#%$~[:alnum:]!&_:+/\\\\\\.\\-]{1,512}):[[:blank:]]+(duplicate section.*has different size)">(line))
311314
{
312315
static constexpr CompilerRegexInfo compilerRegexInfo = {.name = "Linker warning (different sized sections)",
313316
.type = CompilerOutputLineType::warning,

0 commit comments

Comments
 (0)