linux-man.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Stéphane Aulery" <saulery@legtux.org>
To: 794947@bugs.debian.org, control@bugs.debian.org,
	linux-man@vger.kernel.org, wharms@bfs.de
Subject: Bug#794947: manpages-dev: printf(3) example: possible integer overflow
Date: Wed, 17 Feb 2016 13:40:07 +0100	[thread overview]
Message-ID: <e62670273dd84e658fe32cda6e16e94b@legtux.org> (raw)

retitle 794947 printf(3): possible integer overflow in make_message 
example
severity 794947 wishlist
tags 794947 + confirmed
tags 794947 + upstream
forwarded 794947 linux-man@vger.kernel.org
stop

-----

Hello Walter,

Jakub Wilk reported a possible integer overflow in make_message example 
:

> The example in the printf(3) manpages looks like this (with boring 
> parts
> omitted):
> 
> int n;
> /* ... */
>   n = vsnprintf(p, size, fmt, ap);
>    /* ... */
>    if (n < 0) {
>        /* ... */
>        return NULL;
>    }
>    /* ... */
>    size = n + 1;
> 
> 
> But vsnprintf could return INT_MAX, which would then cause "n + 1" to
> overflow.
> 
> (AFAICS, the glibc vsnprintf implementation never returns INT_MAX, but
> it could in principle.)
> 
> I'd suggest changing "n < 0" to "n < 0 || n == INT_MAX".


Since this example has been modified by you (Walter Harms), after the 
bug #794947 [1] has been reported, I wanted to ask your opinion on the 
best option.

Should we add this test to good practice, or rather a comment to mention 
that the case is not taken into account because the example uses glibc?

Regards,

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=794947

-- 
Stéphane Aulery

             reply	other threads:[~2016-02-17 12:40 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-17 12:40 Stéphane Aulery [this message]
     [not found] ` <e62670273dd84e658fe32cda6e16e94b-lkSrsyIBln0dnm+yROfE0A@public.gmane.org>
2016-02-17 21:13   ` manpages-dev: printf(3) example: possible integer overflow walter harms
     [not found]     ` <56C4E269.5020108-fPG8STNUNVg@public.gmane.org>
2016-02-18 19:18       ` Bug#794947: " Stéphane Aulery

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=e62670273dd84e658fe32cda6e16e94b@legtux.org \
    --to=saulery@legtux.org \
    --cc=794947@bugs.debian.org \
    --cc=control@bugs.debian.org \
    --cc=linux-man@vger.kernel.org \
    --cc=wharms@bfs.de \
    /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 NNTP newsgroup(s).