public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "cvs-commit at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug preprocessor/103026] Implement warning for Unicode bidi override characters  [CVE-2021-42574]
Date: Wed, 17 Nov 2021 22:33:53 +0000	[thread overview]
Message-ID: <bug-103026-4-Oha4surEF8@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-103026-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103026

--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by David Malcolm <dmalcolm@gcc.gnu.org>:

https://gcc.gnu.org/g:1a7f2c0774129750fdf73e9f1b78f0ce983c9ab3

commit r12-5355-g1a7f2c0774129750fdf73e9f1b78f0ce983c9ab3
Author: David Malcolm <dmalcolm@redhat.com>
Date:   Tue Nov 2 09:54:32 2021 -0400

    libcpp: escape non-ASCII source bytes in -Wbidi-chars= [PR103026]

    This flags rich_locations associated with -Wbidi-chars= so that
    non-ASCII bytes will be escaped when printing the source lines
    (using the diagnostics support I added in
    r12-4825-gbd5e882cf6e0def3dd1bc106075d59a303fe0d1e).

    In particular, this ensures that the printed source lines will
    be pure ASCII, and thus the visual ordering of the characters
    will be the same as the logical ordering.

    Before:

      Wbidi-chars-1.c: In function âmainâ:
      Wbidi-chars-1.c:6:43: warning: unpaired UTF-8 bidirectional control
character detected [-Wbidi-chars=]
          6 |     /*â® } â¦if (isAdmin)⩠⦠begin admins only */
            |                                           ^
      Wbidi-chars-1.c:9:28: warning: unpaired UTF-8 bidirectional control
character detected [-Wbidi-chars=]
          9 |     /* end admins only â® { â¦*/
            |                            ^

      Wbidi-chars-11.c:6:15: warning: UTF-8 vs UCN mismatch when closing a
context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=]
          6 | int LRE_âª_PDF_\u202c;
            |               ^
      Wbidi-chars-11.c:8:19: warning: UTF-8 vs UCN mismatch when closing a
context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=]
          8 | int LRE_\u202a_PDF_â¬_;
            |                   ^
      Wbidi-chars-11.c:10:28: warning: UTF-8 vs UCN mismatch when closing a
context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=]
         10 | const char *s1 = "LRE_âª_PDF_\u202c";
            |                            ^
      Wbidi-chars-11.c:12:33: warning: UTF-8 vs UCN mismatch when closing a
context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=]
         12 | const char *s2 = "LRE_\u202a_PDF_â¬";
            |                                 ^

    After:

      Wbidi-chars-1.c: In function âmainâ:
      Wbidi-chars-1.c:6:43: warning: unpaired UTF-8 bidirectional control
character detected [-Wbidi-chars=]
          6 |     /*<U+202E> } <U+2066>if (isAdmin)<U+2069> <U+2066> begin
admins only */
            |                                                                  
        ^
      Wbidi-chars-1.c:9:28: warning: unpaired UTF-8 bidirectional control
character detected [-Wbidi-chars=]
          9 |     /* end admins only <U+202E> { <U+2066>*/
            |                                            ^

      Wbidi-chars-11.c:6:15: warning: UTF-8 vs UCN mismatch when closing a
context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=]
          6 | int LRE_<U+202A>_PDF_\u202c;
            |                       ^
      Wbidi-chars-11.c:8:19: warning: UTF-8 vs UCN mismatch when closing a
context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=]
          8 | int LRE_\u202a_PDF_<U+202C>_;
            |                   ^
      Wbidi-chars-11.c:10:28: warning: UTF-8 vs UCN mismatch when closing a
context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=]
         10 | const char *s1 = "LRE_<U+202A>_PDF_\u202c";
            |                                    ^
      Wbidi-chars-11.c:12:33: warning: UTF-8 vs UCN mismatch when closing a
context by "U+202C (POP DIRECTIONAL FORMATTING)" [-Wbidi-chars=]
         12 | const char *s2 = "LRE_\u202a_PDF_<U+202C>";
            |                                 ^

    libcpp/ChangeLog:
            PR preprocessor/103026
            * lex.c (maybe_warn_bidi_on_close): Use a rich_location
            and call set_escape_on_output (true) on it.
            (maybe_warn_bidi_on_char): Likewise.

    Signed-off-by: David Malcolm <dmalcolm@redhat.com>

  parent reply	other threads:[~2021-11-17 22:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 15:03 [Bug c++/103026] New: " mpolacek at gcc dot gnu.org
2021-11-01 15:03 ` [Bug c++/103026] " mpolacek at gcc dot gnu.org
2021-11-01 16:38 ` [Bug preprocessor/103026] " mpolacek at gcc dot gnu.org
2021-11-01 17:50 ` jakub at gcc dot gnu.org
2021-11-17  3:01 ` cvs-commit at gcc dot gnu.org
2021-11-17  3:05 ` mpolacek at gcc dot gnu.org
2021-11-17 22:33 ` cvs-commit at gcc dot gnu.org [this message]
2021-11-17 22:35 ` cvs-commit at gcc dot gnu.org
2021-11-18 14:35 ` dmalcolm at gcc dot gnu.org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-103026-4-Oha4surEF8@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).