public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Joseph Myers <joseph@codesourcery.com>
To: Marek Polacek <polacek@redhat.com>
Cc: GCC Patches <gcc-patches@gcc.gnu.org>, Jakub Jelinek <jakub@redhat.com>
Subject: Re: [PATCH] libcpp: Implement -Wbidirectional for CVE-2021-42574 [PR103026]
Date: Mon, 1 Nov 2021 22:10:40 +0000	[thread overview]
Message-ID: <alpine.DEB.2.22.394.2111012158330.1978253@digraph.polyomino.org.uk> (raw)
In-Reply-To: <20211101163652.36794-1-polacek@redhat.com>

On Mon, 1 Nov 2021, Marek Polacek via Gcc-patches wrote:

> +  /* We've read a bidi char, update the current vector as necessary.  */
> +  void on_char (kind k, bool ucn_p)
> +  {
> +    switch (k)
> +      {
> +      case kind::LRE:
> +      case kind::RLE:
> +      case kind::LRO:
> +      case kind::RLO:
> +	vec.push (ucn_p ? 3u : 1u);
> +	break;
> +      case kind::LRI:
> +      case kind::RLI:
> +      case kind::FSI:
> +	vec.push (ucn_p ? 2u : 0u);
> +	break;
> +      case kind::PDF:
> +	if (current_ctx () == kind::PDF)
> +	  pop ();
> +	break;
> +      case kind::PDI:
> +	if (current_ctx () == kind::PDI)
> +	  pop ();

My understanding is that PDI should pop all intermediate PDF contexts 
outward to a PDI context, which it also pops.  (But if it's embedded only 
in PDF contexts, with no PDI context containing it, it doesn't pop 
anything.)

I think failing to handle that only means libcpp sometimes models there 
as being more bidirectional contexts open than there should be, so it 
might give spurious warnings when in fact all such contexts had been 
closed by end of string or comment.

-- 
Joseph S. Myers
joseph@codesourcery.com

  reply	other threads:[~2021-11-01 22:10 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-01 16:36 Marek Polacek
2021-11-01 22:10 ` Joseph Myers [this message]
2021-11-02 17:18   ` [PATCH v2] " Marek Polacek
2021-11-02 19:20     ` Martin Sebor
2021-11-02 19:52       ` Marek Polacek
2021-11-08 21:33         ` Marek Polacek
2021-11-15 17:28           ` [PATCH] libcpp: Implement -Wbidi-chars " Marek Polacek
2021-11-15 23:15             ` David Malcolm
2021-11-16 19:50               ` [PATCH v2] " Marek Polacek
2021-11-16 23:00                 ` David Malcolm
2021-11-17  0:37                   ` [PATCH v3] " Marek Polacek
2021-11-17  2:28                     ` David Malcolm
2021-11-17  3:05                       ` Marek Polacek
2021-11-17 22:45                         ` [committed] libcpp: escape non-ASCII source bytes in -Wbidi-chars= [PR103026] David Malcolm
2021-11-17 22:45                           ` [PATCH 2/2] libcpp: capture and underline ranges " David Malcolm
2021-11-17 23:01                             ` Marek Polacek
2021-11-30  8:38             ` [PATCH] libcpp: Implement -Wbidi-chars for CVE-2021-42574 [PR103026] Stephan Bergmann
2021-11-30 13:26               ` Marek Polacek
2021-11-30 15:00                 ` Stephan Bergmann
2021-11-30 15:27                   ` Marek Polacek
2022-01-14  9:23                     ` Stephan Bergmann
2022-01-14 13:28                       ` Marek Polacek
2022-01-14 14:52                         ` Stephan Bergmann
2021-11-02 20:57 ` [PATCH 0/2] Re: [PATCH] libcpp: Implement -Wbidirectional " David Malcolm
2021-11-02 20:58   ` [PATCH 1/2] Flag CPP_W_BIDIRECTIONAL so that source lines are escaped David Malcolm
2021-11-02 21:07     ` David Malcolm
2021-11-02 20:58   ` [PATCH 2/2] Capture locations of bidi chars and underline ranges David Malcolm

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=alpine.DEB.2.22.394.2111012158330.1978253@digraph.polyomino.org.uk \
    --to=joseph@codesourcery.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@redhat.com \
    --cc=polacek@redhat.com \
    /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).