public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Eric Gallager <egall@gwmail.gwu.edu>
To: Martin Sebor <msebor@gmail.com>
Cc: Jeff Law <law@redhat.com>, Gcc Patch List <gcc-patches@gcc.gnu.org>
Subject: Re: [PATCH] assume sprintf formatting of wide characters may fail (PR 86853)
Date: Sun, 05 Aug 2018 16:03:00 -0000	[thread overview]
Message-ID: <CAMfHzOs9UZ-oO0t=dLNeBCpN__w3C==suQnpZUUr3+N_ZqwehA@mail.gmail.com> (raw)
In-Reply-To: <0e8d373d-16e1-0620-e8e5-590db87033e6@gmail.com>

On 8/4/18, Martin Sebor <msebor@gmail.com> wrote:
> The sprintf handling of wide characters neglects to consider
> that calling the function may fail due to a conversion error
> (when the wide character is invalid or not representable in
> the current locale).  The handling also misinterprets
> the POSIX %S wide string directive as a plain narrow %s and
> doesn't include %C (the POSIX equivalent of %lc).

I was worried about portability to non-POSIX platforms, but after
checking the documentation for the gnulib sprintf-posix module,
apparently there are no portability issues with platforms that don't
support the %C directive, so I guess it should be fine:
https://www.gnu.org/software/gnulib/manual/html_node/sprintf.html

> The attached patch corrects these oversights by extending the data
> structures to indicate when a directive may fail, and extending the
> UNDER4K member of the format_result structure to also encode
> calls with such directives.
>
> Tested on x86_64-linux.
>
> Besides the trunk, since this bug can affect code correctness
> I'd like to backport this patch to both release branches (7
> and 8).
>
> Martin
>

  reply	other threads:[~2018-08-05 16:03 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-04 18:46 Martin Sebor
2018-08-05 16:03 ` Eric Gallager [this message]
2018-08-09  4:14 ` Jeff Law
2018-08-09 20:54   ` Martin Sebor
2018-08-17  4:02 ` Jeff Law
2018-08-09 19:29 Bernd Edlinger
2018-08-16 22:47 ` Jeff Law
2018-08-20 19:05 David Edelsohn
2018-08-20 19:07 ` Jeff Law
2018-10-03 23:11 ` Jeff Law

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='CAMfHzOs9UZ-oO0t=dLNeBCpN__w3C==suQnpZUUr3+N_ZqwehA@mail.gmail.com' \
    --to=egall@gwmail.gwu.edu \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=law@redhat.com \
    --cc=msebor@gmail.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).