diff options
| author | Grant Likely <grant.likely@linaro.org> | 2013-06-13 07:57:44 -0400 |
|---|---|---|
| committer | Grant Likely <grant.likely@linaro.org> | 2013-06-13 17:12:15 -0400 |
| commit | 706b78f37fbed8d81b6061359f28a315fb9b1d73 (patch) | |
| tree | 1a68c4b3a1e6ebb3f5bb2a3da87a07c80cba6354 /scripts | |
| parent | 2a6a08ca5e3561e17346f8f87ce8dc88c0a8e42d (diff) | |
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')
| -rw-r--r-- | scripts/dtc/dtc-lexer.l | 2 | ||||
| -rw-r--r-- | scripts/dtc/dtc-lexer.lex.c_shipped | 232 |
2 files changed, 117 insertions, 117 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); | |||
| 71 | push_input_file(name); | 71 | push_input_file(name); |
| 72 | } | 72 | } |
| 73 | 73 | ||
| 74 | <*>^"#"(line)?{WS}+[0-9]+{WS}+{STRING}({WS}+[0-9]+)? { | 74 | <*>^"#"(line)?[ \t]+[0-9]+[ \t]+{STRING}([ \t]+[0-9]+)? { |
| 75 | char *line, *tmp, *fn; | 75 | char *line, *tmp, *fn; |
| 76 | /* skip text before line # */ | 76 | /* skip text before line # */ |
| 77 | line = yytext; | 77 | line = yytext; |
diff --git a/scripts/dtc/dtc-lexer.lex.c_shipped b/scripts/dtc/dtc-lexer.lex.c_shipped index a6c5fcdfc032..2d30f41778b7 100644 --- a/scripts/dtc/dtc-lexer.lex.c_shipped +++ b/scripts/dtc/dtc-lexer.lex.c_shipped | |||
| @@ -405,19 +405,19 @@ static yyconst flex_int16_t yy_accept[161] = | |||
| 405 | static yyconst flex_int32_t yy_ec[256] = | 405 | static yyconst flex_int32_t yy_ec[256] = |
| 406 | { 0, | 406 | { 0, |
| 407 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, | 407 | 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, |
| 408 | 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, | 408 | 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, |
| 409 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 409 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 410 | 1, 2, 4, 5, 6, 1, 1, 7, 8, 1, | 410 | 1, 2, 5, 6, 7, 1, 1, 8, 9, 1, |
| 411 | 1, 9, 10, 10, 11, 10, 12, 13, 14, 15, | 411 | 1, 10, 11, 11, 12, 11, 13, 14, 15, 16, |
| 412 | 15, 15, 15, 15, 15, 15, 15, 16, 1, 17, | 412 | 16, 16, 16, 16, 16, 16, 16, 17, 1, 18, |
| 413 | 18, 19, 10, 10, 20, 20, 20, 20, 20, 20, | 413 | 19, 20, 11, 11, 21, 21, 21, 21, 21, 21, |
| 414 | 21, 21, 21, 21, 21, 22, 21, 21, 21, 21, | 414 | 22, 22, 22, 22, 22, 23, 22, 22, 22, 22, |
| 415 | 21, 21, 21, 21, 23, 21, 21, 24, 21, 21, | 415 | 22, 22, 22, 22, 24, 22, 22, 25, 22, 22, |
| 416 | 1, 25, 26, 1, 21, 1, 20, 27, 28, 29, | 416 | 1, 26, 27, 1, 22, 1, 21, 28, 29, 30, |
| 417 | 417 | ||
| 418 | 30, 20, 21, 21, 31, 21, 21, 32, 33, 34, | 418 | 31, 21, 22, 22, 32, 22, 22, 33, 34, 35, |
| 419 | 35, 36, 21, 37, 38, 39, 40, 41, 21, 24, | 419 | 36, 37, 22, 38, 39, 40, 41, 42, 22, 25, |
| 420 | 42, 21, 43, 44, 45, 1, 1, 1, 1, 1, | 420 | 43, 22, 44, 45, 46, 1, 1, 1, 1, 1, |
| 421 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 421 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 422 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 422 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| 423 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, | 423 | 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, |
| @@ -434,36 +434,36 @@ static yyconst flex_int32_t yy_ec[256] = | |||
| 434 | 1, 1, 1, 1, 1 | 434 | 1, 1, 1, 1, 1 |
| 435 | } ; | 435 | } ; |
| 436 | 436 | ||
| 437 | static yyconst flex_int32_t yy_meta[46] = | 437 | static yyconst flex_int32_t yy_meta[47] = |
| 438 | { 0, | 438 | { 0, |
| 439 | 1, 1, 1, 1, 1, 2, 3, 1, 2, 2, | 439 | 1, 1, 1, 1, 1, 1, 2, 3, 1, 2, |
| 440 | 2, 4, 5, 5, 5, 6, 1, 1, 1, 7, | 440 | 2, 2, 4, 5, 5, 5, 6, 1, 1, 1, |
| 441 | 8, 8, 8, 8, 1, 1, 7, 7, 7, 7, | 441 | 7, 8, 8, 8, 8, 1, 1, 7, 7, 7, |
| 442 | 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, | 442 | 7, 8, 8, 8, 8, 8, 8, 8, 8, 8, |
| 443 | 8, 8, 3, 1, 1 | 443 | 8, 8, 8, 3, 1, 1 |
| 444 | } ; | 444 | } ; |
| 445 | 445 | ||
| 446 | static yyconst flex_int16_t yy_base[175] = | 446 | static yyconst flex_int16_t yy_base[175] = |
| 447 | { 0, | 447 | { 0, |
| 448 | 0, 388, 381, 40, 41, 386, 71, 385, 34, 44, | 448 | 0, 385, 378, 40, 41, 383, 72, 382, 34, 44, |
| 449 | 390, 395, 60, 62, 371, 112, 111, 111, 111, 104, | 449 | 388, 393, 61, 117, 368, 116, 115, 115, 115, 48, |
| 450 | 370, 106, 371, 342, 124, 119, 0, 144, 395, 0, | 450 | 367, 107, 368, 339, 127, 120, 0, 147, 393, 0, |
| 451 | 123, 0, 159, 153, 165, 167, 395, 130, 395, 382, | 451 | 127, 0, 133, 156, 168, 153, 393, 125, 393, 380, |
| 452 | 395, 0, 372, 122, 395, 157, 374, 379, 350, 21, | 452 | 393, 0, 369, 127, 393, 160, 371, 377, 347, 21, |
| 453 | 346, 349, 395, 395, 395, 395, 395, 362, 395, 395, | 453 | 343, 346, 393, 393, 393, 393, 393, 359, 393, 393, |
| 454 | 181, 346, 342, 395, 359, 0, 191, 343, 190, 351, | 454 | 183, 343, 339, 393, 356, 0, 183, 340, 187, 348, |
| 455 | 350, 0, 0, 0, 173, 362, 177, 367, 357, 329, | 455 | 347, 0, 0, 0, 178, 359, 195, 365, 354, 326, |
| 456 | 335, 328, 337, 331, 206, 329, 334, 327, 395, 338, | 456 | 332, 325, 334, 328, 204, 326, 331, 324, 393, 335, |
| 457 | 170, 314, 346, 345, 318, 325, 343, 158, 316, 212, | 457 | 150, 311, 343, 342, 315, 322, 340, 179, 313, 207, |
| 458 | 458 | ||
| 459 | 322, 319, 320, 395, 340, 336, 308, 305, 314, 304, | 459 | 319, 316, 317, 393, 337, 333, 305, 302, 311, 301, |
| 460 | 295, 138, 208, 220, 395, 292, 305, 265, 264, 254, | 460 | 310, 190, 338, 337, 393, 307, 322, 301, 305, 277, |
| 461 | 201, 222, 285, 275, 273, 270, 236, 235, 225, 115, | 461 | 208, 311, 307, 278, 271, 270, 248, 246, 213, 130, |
| 462 | 395, 395, 252, 216, 216, 217, 214, 230, 209, 220, | 462 | 393, 393, 263, 235, 207, 221, 218, 229, 213, 213, |
| 463 | 213, 239, 211, 217, 216, 209, 229, 395, 240, 225, | 463 | 206, 234, 218, 210, 208, 193, 219, 393, 223, 204, |
| 464 | 206, 169, 395, 395, 116, 106, 99, 54, 395, 395, | 464 | 176, 157, 393, 393, 120, 106, 97, 119, 393, 393, |
| 465 | 254, 260, 268, 272, 276, 282, 289, 293, 301, 309, | 465 | 245, 251, 259, 263, 267, 273, 280, 284, 292, 300, |
| 466 | 313, 319, 327, 335 | 466 | 304, 310, 318, 326 |
| 467 | } ; | 467 | } ; |
| 468 | 468 | ||
| 469 | static yyconst flex_int16_t yy_def[175] = | 469 | static yyconst flex_int16_t yy_def[175] = |
| @@ -489,108 +489,108 @@ static yyconst flex_int16_t yy_def[175] = | |||
| 489 | 160, 160, 160, 160 | 489 | 160, 160, 160, 160 |
| 490 | } ; | 490 | } ; |
| 491 | 491 | ||
| 492 | static yyconst flex_int16_t yy_nxt[441] = | 492 | static yyconst flex_int16_t yy_nxt[440] = |
| 493 | { 0, | 493 | { 0, |
| 494 | 12, 13, 14, 15, 16, 12, 17, 18, 12, 12, | 494 | 12, 13, 14, 13, 15, 16, 12, 17, 18, 12, |
| 495 | 12, 19, 12, 12, 12, 12, 20, 21, 22, 23, | 495 | 12, 12, 19, 12, 12, 12, 12, 20, 21, 22, |
| 496 | 23, 23, 23, 23, 12, 12, 23, 23, 23, 23, | 496 | 23, 23, 23, 23, 23, 12, 12, 23, 23, 23, |
| 497 | 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, | 497 | 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, |
| 498 | 23, 23, 12, 24, 12, 25, 34, 35, 35, 25, | 498 | 23, 23, 23, 12, 24, 12, 25, 34, 35, 35, |
| 499 | 81, 26, 26, 27, 27, 27, 34, 35, 35, 82, | 499 | 25, 81, 26, 26, 27, 27, 27, 34, 35, 35, |
| 500 | 28, 36, 36, 36, 36, 159, 29, 28, 28, 28, | 500 | 82, 28, 36, 36, 36, 53, 54, 29, 28, 28, |
| 501 | 28, 12, 13, 14, 15, 16, 30, 17, 18, 30, | 501 | 28, 28, 12, 13, 14, 13, 15, 16, 30, 17, |
| 502 | 30 | ||
