Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sebastian Schrader
Kea
Commits
f2021d66
Commit
f2021d66
authored
Nov 13, 2015
by
Francis Dupont
Browse files
[4088fd] Added protection against integer overflow
parent
01b370bd
Changes
3
Hide whitespace changes
Inline
Side-by-side
src/lib/eval/lexer.cc
View file @
f2021d66
...
...
@@ -589,8 +589,8 @@ int yy_flex_debug = 1;
static
yyconst
flex_int16_t
yy_rule_linenum
[
17
]
=
{
0
,
83
,
87
,
93
,
10
1
,
1
07
,
1
17
,
1
2
3
,
1
37
,
1
38
,
1
39
,
14
0
,
14
1
,
14
2
,
1
43
,
1
44
,
1
46
83
,
87
,
93
,
10
8
,
1
14
,
1
24
,
13
0
,
1
44
,
1
45
,
1
46
,
14
7
,
14
8
,
14
9
,
1
50
,
1
51
,
1
53
}
;
/* The intent behind this definition is that it'll catch
...
...
@@ -1052,12 +1052,19 @@ YY_RULE_SETUP
std
::
string
tmp
(
yytext
+
1
);
tmp
.
resize
(
tmp
.
size
()
-
1
);
try
{
static_cast
<
void
>
(
boost
::
lexical_cast
<
int
>
(
tmp
));
}
catch
(
const
boost
::
bad_lexical_cast
&
)
{
// In fact it is not a valid number
return
isc
::
eval
::
EvalParser
::
make_STRING
(
tmp
,
loc
);
}
return
isc
::
eval
::
EvalParser
::
make_NUMBER
(
tmp
,
loc
);
}
YY_BREAK
case
4
:
YY_RULE_SETUP
#line 10
1
"lexer.ll"
#line 10
8
"lexer.ll"
{
// A string containing the "all" keyword.
...
...
@@ -1066,7 +1073,7 @@ YY_RULE_SETUP
YY_BREAK
case
5
:
YY_RULE_SETUP
#line 1
07
"lexer.ll"
#line 1
14
"lexer.ll"
{
// A string has been matched. It contains the actual string and single quotes.
// We need to get those quotes out of the way and just use its content, e.g.
...
...
@@ -1079,7 +1086,7 @@ YY_RULE_SETUP
YY_BREAK
case
6
:
YY_RULE_SETUP
#line 1
17
"lexer.ll"
#line 1
24
"lexer.ll"
{
// A hex string has been matched. It contains the '0x' or '0X' header
// followed by at least one hexadecimal digit.
...
...
@@ -1088,7 +1095,7 @@ YY_RULE_SETUP
YY_BREAK
case
7
:
YY_RULE_SETUP
#line 1
2
3 "lexer.ll"
#line 13
0
"lexer.ll"
{
// An integer was found.
std
::
string
tmp
(
yytext
);
...
...
@@ -1105,59 +1112,59 @@ YY_RULE_SETUP
YY_BREAK
case
8
:
YY_RULE_SETUP
#line 1
37
"lexer.ll"
#line 1
44
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_EQUAL
(
loc
);
YY_BREAK
case
9
:
YY_RULE_SETUP
#line 1
38
"lexer.ll"
#line 1
45
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_OPTION
(
loc
);
YY_BREAK
case
10
:
YY_RULE_SETUP
#line 1
39
"lexer.ll"
#line 1
46
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_SUBSTRING
(
loc
);
YY_BREAK
case
11
:
YY_RULE_SETUP
#line 14
0
"lexer.ll"
#line 14
7
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_LPAREN
(
loc
);
YY_BREAK
case
12
:
YY_RULE_SETUP
#line 14
1
"lexer.ll"
#line 14
8
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_RPAREN
(
loc
);
YY_BREAK
case
13
:
YY_RULE_SETUP
#line 14
2
"lexer.ll"
#line 14
9
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_LBRACKET
(
loc
);
YY_BREAK
case
14
:
YY_RULE_SETUP
#line 1
43
"lexer.ll"
#line 1
50
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_RBRACKET
(
loc
);
YY_BREAK
case
15
:
YY_RULE_SETUP
#line 1
44
"lexer.ll"
#line 1
51
"lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_COMA
(
loc
);
YY_BREAK
case
16
:
YY_RULE_SETUP
#line 1
46
"lexer.ll"
#line 1
53
"lexer.ll"
driver
.
error
(
loc
,
"Invalid character: "
+
std
::
string
(
yytext
));
YY_BREAK
case
YY_STATE_EOF
(
INITIAL
):
#line 14
7
"lexer.ll"
#line 1
5
4 "lexer.ll"
return
isc
::
eval
::
EvalParser
::
make_END
(
loc
);
YY_BREAK
case
17
:
YY_RULE_SETUP
#line 1
48
"lexer.ll"
#line 1
55
"lexer.ll"
ECHO
;
YY_BREAK
#line 116
1
"lexer.cc"
#line 116
8
"lexer.cc"
case
YY_END_OF_BUFFER
:
{
...
...
@@ -2245,7 +2252,7 @@ void yyfree (void * ptr )
/* %ok-for-header */
#line 1
48
"lexer.ll"
#line 1
55
"lexer.ll"
...
...
src/lib/eval/lexer.ll
View file @
f2021d66
...
...
@@ -95,6 +95,13 @@ blank [ \t]
std:
:string
tmp
(
yytext+
1
)
;
tmp
.
resize
(
tmp
.
size
()
-
1
)
;
try
{
static_cast
<
void
>(
boost:
:lexical_cast
<
int
>(
tmp
))
;
}
catch
(
const
boost:
:bad_lexical_cast
&
)
{
//
In
fact
it
is
not
a
valid
number
return
isc:
:
eval:
:
EvalParser:
:make_STRING
(
tmp
,
loc
)
;
}
return
isc:
:
eval:
:
EvalParser:
:make_NUMBER
(
tmp
,
loc
)
;
}
...
...
src/lib/eval/tests/context_unittest.cc
View file @
f2021d66
...
...
@@ -252,7 +252,13 @@ TEST_F(EvalContextTest, scanParseErrors) {
checkError
(
"option[65536]"
,
"<string>:1.8-12: Option code has invalid "
"value in 65536. Allowed range: 0..65535"
);
checkError
(
"option[12345678901234567890]"
,
"<string>:1.8-27: Failed to convert 12345678901234567890 "
"to an integer."
);
checkError
(
"option[123] < 'foo'"
,
"<string>:1.13: Invalid character: <"
);
checkError
(
"substring('foo','12345678901234567890','1')"
,
"<string>:1.17-38: syntax error, unexpected constant string, "
"expecting a number in a constant string"
);
}
// Tests some parser error cases
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment