bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Jeremie Courreges-Anglas <jca@wxcvbn.org>
To: Bruno Haible <bruno@clisp.org>
Cc: bug-gnulib@gnu.org
Subject: Re: vasnprintf: avoid using %n in the general case
Date: Sun, 04 Oct 2020 23:27:45 +0200	[thread overview]
Message-ID: <87imbpadgu.fsf@shannon.wxcvbn.org> (raw)
In-Reply-To: 2804955.gIxoHZPy4Z@omega

[-- Attachment #1: Type: text/plain, Size: 1294 bytes --]

On Sun, Oct 04 2020, Bruno Haible <bruno@clisp.org> wrote:
> Hi Jeremie,
>
>> The attached patch changes vasnprintf.c to avoid using %n in the general
>> case, ie when the return value of snprintf is usable.  This should help
>> if more systems decide to make tighten %n usage.  There are plans for
>> that in OpenBSD land.
>
> Thanks for the suggestion. Yes, this is a good idea. (I didn't know about
> the OpenBSD plans.)
>
>> The existing comments in vasnprintf.c mention systems where
>> gl_SNPRINTF_RETVAL_C99 and gl_SNPRINTF_TRUNCATION_C99 pass.  This patch
>> only considers the usability of the return value of snprintf, as lack
>> of truncation seems to be a different problem (apparently handled later
>> in the code).
>
> I prefer to limit the shortcut to those platforms where both
> gl_SNPRINTF_RETVAL_C99 and gl_SNPRINTF_TRUNCATION_C99 pass. These are
> the conditions I found when considering this code in detail a couple of
> years ago. Maybe you are right that only one of the conditions is needed;
> but I don't want to live on the risky edge here.

Your approach certainly makes sense.  I considered something similar
earlier.  Your changes look good to me, thanks!

-- 
jca | PGP : 0x1524E7EE / 5135 92C1 AD36 5293 2BDF  DDCC 0DFA 74AE 1524 E7EE

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 853 bytes --]

      reply	other threads:[~2020-10-04 21:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-03 22:18 vasnprintf: avoid using %n in the general case Jeremie Courreges-Anglas
2020-10-04 15:48 ` Bruno Haible
2020-10-04 21:27   ` Jeremie Courreges-Anglas [this message]

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

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

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

  git send-email \
    --in-reply-to=87imbpadgu.fsf@shannon.wxcvbn.org \
    --to=jca@wxcvbn.org \
    --cc=bruno@clisp.org \
    --cc=bug-gnulib@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).