All of lore.kernel.org
 help / color / mirror / Atom feed
From: Finn Arne Gangstad <finnag@pvv.org>
To: Michal Rokos <michal.rokos@nextsoft.cz>
Cc: GIT <git@vger.kernel.org>
Subject: Re: [PATCH] Add compat/vsnprintf.c for systems that returns -1 on maxsize reached
Date: Tue, 4 Mar 2008 15:09:31 +0100	[thread overview]
Message-ID: <20080304140930.GA23335@pvv.org> (raw)
In-Reply-To: <200803041459.29000.michal.rokos@nextsoft.cz>

On Tue, Mar 04, 2008 at 02:59:28PM +0100, Michal Rokos wrote:

> +	while ( ret == -1 )
> +	{
> +		maxsize = (maxsize*3)/2;
> +		s = realloc(s, maxsize);
> +		if (! s) return -1;
> +		ret = vsnprintf(s, maxsize, format, ap);  /* <--- UNSAFE! */
> +	}

This is not generally safe, you cannot call vsnprintf multiple times
with the same ap on all architectures. You need va_copy (or __va_copy,
or VA_COPY, differs a bit between different architectures, especially
one the ones with a broken vsnprintf I guess..)

- Finn Arne

  parent reply	other threads:[~2008-03-04 14:47 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-04 13:59 [PATCH] Add compat/vsnprintf.c for systems that returns -1 on maxsize reached Michal Rokos
2008-03-04 14:09 ` Johannes Schindelin
2008-03-04 14:09 ` Finn Arne Gangstad [this message]
2008-03-04 16:19   ` Johannes Sixt
2008-03-04 14:12 ` Morten Welinder
2008-03-04 16:28 ` Johannes Sixt
2008-03-04 23:51   ` Wayne Davison
2008-03-05  8:37   ` Michal Rokos
2008-03-05  8:44     ` Jeff King
2008-03-05  9:18     ` Johannes Sixt
2008-03-05 13:55       ` Michal Rokos
2008-03-05 14:28         ` Johannes Sixt
2008-03-05 15:00           ` Michal Rokos
2008-03-05 15:22             ` Johannes Sixt
2008-03-05 15:48               ` Michal Rokos
2008-03-05 15:54             ` Wayne Davison
2008-03-05 16:04               ` Johannes Sixt
2008-03-05 22:33                 ` Wayne Davison
2008-03-05 21:05               ` Junio C Hamano
2008-03-05  9:22     ` Mike Ralphson
2008-03-05 10:35     ` Robert Haines
2008-03-05 13:58       ` Michal Rokos
2008-03-10  8:59   ` Michal Rokos
2008-03-10  9:28     ` Johannes Sixt
2008-03-10  9:47       ` Michal Rokos
2008-03-10 10:05         ` Johannes Sixt

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=20080304140930.GA23335@pvv.org \
    --to=finnag@pvv.org \
    --cc=git@vger.kernel.org \
    --cc=michal.rokos@nextsoft.cz \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.