• R/O
  • HTTP
  • SSH
  • HTTPS

コミット

タグ
未設定

よく使われているワード(クリックで追加)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


コミットメタ情報

リビジョン25065fcd192d9958c03e107985aea41d651e4a16 (tree)
日時2020-06-10 18:07:26
作者Ralf Habacker <ralf.habacker@free...>
コミッターNick Clifton

ログメッセージ

Fix the windmc program to conform to the behaviour of mc.exe by rejecting lines that reach end-of-file without a terminating newline character.

PR 26082
* mclex.c (yylex): Reject lines that reach end-of-file without a
terminating newline character.

変更サマリ

差分

--- a/binutils/ChangeLog
+++ b/binutils/ChangeLog
@@ -1,3 +1,9 @@
1+2020-06-10 Ralf Habacker <ralf.habacker@freenet.de>
2+
3+ PR 26082
4+ * mclex.c (yylex): Reject lines that reach end-of-file without a
5+ terminating newline character.
6+
17 2020-06-08 Nick Clifton <nickc@redhat.com>
28
39 PR 26093
--- a/binutils/mclex.c
+++ b/binutils/mclex.c
@@ -323,6 +323,21 @@ mc_token (const unichar *t, size_t len)
323323 return -1;
324324 }
325325
326+/* Skip characters in input_stream_pos up to and including a newline
327+ character. Returns non-zero if the newline was found, zero otherwise. */
328+
329+static int
330+skip_until_eol (void)
331+{
332+ while (input_stream_pos[0] != 0 && input_stream_pos[0] != '\n')
333+ ++input_stream_pos;
334+ if (input_stream_pos[0] == 0)
335+ return 0;
336+ if (input_stream_pos[0] == '\n')
337+ ++input_stream_pos;
338+ return 1;
339+}
340+
326341 int
327342 yylex (void)
328343 {
@@ -334,29 +349,28 @@ yylex (void)
334349 fatal ("Input stream not setuped.\n");
335350 return -1;
336351 }
352+
337353 if (mclex_want_line)
338354 {
339355 start_token = input_stream_pos;
340356 if (input_stream_pos[0] == 0)
341357 return -1;
358+ /* PR 26082: Reject a period followed by EOF. */
359+ if (input_stream_pos[0] == '.' && input_stream_pos[1] == 0)
360+ return -1;
342361 if (input_stream_pos[0] == '.'
343362 && (input_stream_pos[1] == '\n'
344363 || (input_stream_pos[1] == '\r' && input_stream_pos[2] == '\n')))
345364 {
346365 mclex_want_line = FALSE;
347- while (input_stream_pos[0] != 0 && input_stream_pos[0] != '\n')
348- ++input_stream_pos;
349- if (input_stream_pos[0] == '\n')
350- ++input_stream_pos;
351- return MCENDLINE;
366+ return skip_until_eol () ? MCENDLINE : -1;
352367 }
353- while (input_stream_pos[0] != 0 && input_stream_pos[0] != '\n')
354- ++input_stream_pos;
355- if (input_stream_pos[0] == '\n')
356- ++input_stream_pos;
368+ if (!skip_until_eol ())
369+ return -1;
357370 yylval.ustr = get_diff (input_stream_pos, start_token);
358371 return MCLINE;
359372 }
373+
360374 while ((ch = input_stream_pos[0]) <= 0x20)
361375 {
362376 if (ch == 0)
@@ -404,10 +418,8 @@ yylex (void)
404418 {
405419 case ';':
406420 ++start_token;
407- while (input_stream_pos[0] != '\n' && input_stream_pos[0] != 0)
408- ++input_stream_pos;
409- if (input_stream_pos[0] == '\n')
410- input_stream_pos++;
421+ if (!skip_until_eol ())
422+ return -1;
411423 yylval.ustr = get_diff (input_stream_pos, start_token);
412424 return MCCOMMENT;
413425 case '=':