diff options
author | Grant Likely <grant.likely@linaro.org> | 2013-06-13 12:57:44 +0100 |
---|---|---|
committer | Grant Likely <grant.likely@linaro.org> | 2013-06-13 22:12:15 +0100 |
commit | 706b78f37fbed8d81b6061359f28a315fb9b1d73 (patch) | |
tree | 1a68c4b3a1e6ebb3f5bb2a3da87a07c80cba6354 /scripts/dtc/dtc-lexer.l | |
parent | 2a6a08ca5e3561e17346f8f87ce8dc88c0a8e42d (diff) | |
download | linux-706b78f37fbed8d81b6061359f28a315fb9b1d73.tar.gz linux-706b78f37fbed8d81b6061359f28a315fb9b1d73.tar.bz2 linux-706b78f37fbed8d81b6061359f28a315fb9b1d73.zip |
dtc: ensure #line directives don't consume data from the next line
Previously, the #line parsing regex ended with ({WS}+[0-9]+)?. The {WS}
could match line-break characters. If the #line directive did not contain
the optional flags field at the end, this could cause any integer data on
the next line to be consumed as part of the #line directive parsing. This
could cause syntax errors (i.e. #line parsing consuming the leading 0
from a hex literal 0x1234, leaving x1234 to be parsed as cell data,
which is a syntax error), or invalid compilation results (i.e. simply
consuming literal 1234 as part of the #line processing, thus removing it
from the cell data).
Fix this by replacing {WS} with [ \t] so that it can't match line-breaks.
Convert all instances of {WS}, even though the other instances should be
irrelevant for any well-formed #line directive. This is done for
consistency and ultimate safety.
[Cherry picked from DTC commit a1ee6f068e1c8dbc62873645037a353d7852d5cc]
Reported-by: Ian Campbell <Ian.Campbell@citrix.com>
Signed-off-by: Stephen Warren <swarren@nvidia.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Grant Likely <grant.likely@secretlab.ca>
Diffstat (limited to 'scripts/dtc/dtc-lexer.l')
-rw-r--r-- | scripts/dtc/dtc-lexer.l | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/scripts/dtc/dtc-lexer.l b/scripts/dtc/dtc-lexer.l index 254d5af88956..3b41bfca636c 100644 --- a/scripts/dtc/dtc-lexer.l +++ b/scripts/dtc/dtc-lexer.l @@ -71,7 +71,7 @@ static int pop_input_file(void); push_input_file(name); } -<*>^"#"(line)?{WS}+[0-9]+{WS}+{STRING}({WS}+[0-9]+)? { +<*>^"#"(line)?[ \t]+[0-9]+[ \t]+{STRING}([ \t]+[0-9]+)? { char *line, *tmp, *fn; /* skip text before line # */ line = yytext; |