Skip to content

Commit

Permalink
Fix a potential infinite loop in the Windows resource parser.
Browse files Browse the repository at this point in the history
	PR 26082
	* mclex.c (yylex): Add test for an empty input stream.
  • Loading branch information
goatshriek authored and nickclifton committed Jun 5, 2020
1 parent 9c65eea commit 8affa48
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 8 deletions.
5 changes: 5 additions & 0 deletions binutils/ChangeLog
@@ -1,3 +1,8 @@
2020-06-05 Joel Anderson <joelanderson333@gmail.com>

PR 26082
* mclex.c (yylex): Add test for an empty input stream.

2020-06-04 Stephen Casner <casner@acm.org>

* testsuite/binutils-all/pr25662-pdp11.s: Alternate source file
Expand Down
18 changes: 10 additions & 8 deletions binutils/mclex.c
Expand Up @@ -337,17 +337,19 @@ yylex (void)
if (mclex_want_line)
{
start_token = input_stream_pos;
if (input_stream_pos[0] == 0)
return -1;
if (input_stream_pos[0] == '.'
&& (input_stream_pos[1] == '\n'
|| (input_stream_pos[1] == '\r' && input_stream_pos[2] == '\n')))
{
mclex_want_line = FALSE;
while (input_stream_pos[0] != 0 && input_stream_pos[0] != '\n')
++input_stream_pos;
if (input_stream_pos[0] == '\n')
++input_stream_pos;
return MCENDLINE;
}
{
mclex_want_line = FALSE;
while (input_stream_pos[0] != 0 && input_stream_pos[0] != '\n')
++input_stream_pos;
if (input_stream_pos[0] == '\n')
++input_stream_pos;
return MCENDLINE;
}
while (input_stream_pos[0] != 0 && input_stream_pos[0] != '\n')
++input_stream_pos;
if (input_stream_pos[0] == '\n')
Expand Down

0 comments on commit 8affa48

Please sign in to comment.