Skip to content

Commit 8c658f0

Browse files
authored
Merge pull request #3543 from airween/v3/parserfix
fix: nullptr dereference in seclang scanner
2 parents d3d5924 + ff5c4f5 commit 8c658f0

File tree

4 files changed

+791
-775
lines changed

4 files changed

+791
-775
lines changed

src/parser/driver.cc

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,14 @@ int Driver::parse(const std::string &f, const std::string &ref) {
144144
scan_begin();
145145
yy::seclang_parser parser(*this);
146146
parser.set_debug_level(trace_parsing);
147-
int res = parser.parse();
147+
int res;
148+
try {
149+
res = parser.parse();
150+
} catch (...) {
151+
scan_end();
152+
m_parserError << "Parser exception caught during rule parsing." << std::endl;
153+
return 1;
154+
}
148155
scan_end();
149156

150157
/*

src/parser/seclang-parser.hh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333

3434
/**
35-
** \file seclang-parser.tab.hh
35+
** \file y.tab.h
3636
** Define the yy::parser class.
3737
*/
3838

@@ -42,8 +42,8 @@
4242
// especially those whose name start with YY_ or yy_. They are
4343
// private implementation details that can be changed or removed.
4444

45-
#ifndef YY_YY_SECLANG_PARSER_TAB_HH_INCLUDED
46-
# define YY_YY_SECLANG_PARSER_TAB_HH_INCLUDED
45+
#ifndef YY_YY_SECLANG_PARSER_HH_INCLUDED
46+
# define YY_YY_SECLANG_PARSER_HH_INCLUDED
4747
// "%code requires" blocks.
4848
#line 10 "seclang-parser.yy"
4949

@@ -8892,4 +8892,4 @@ switch (yykind)
88928892

88938893

88948894

8895-
#endif // !YY_YY_SECLANG_PARSER_TAB_HH_INCLUDED
8895+
#endif // !YY_YY_SECLANG_PARSER_HH_INCLUDED

0 commit comments

Comments
 (0)