[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Bug-gnulib] snprintf (was: Re: vasnprintf problem)

From: Bruno Haible
Subject: Re: [Bug-gnulib] snprintf (was: Re: vasnprintf problem)
Date: Tue, 21 Sep 2004 17:49:46 +0200
User-agent: KMail/1.5

Simon Josefsson wrote:
> I have not really tested it, but that
> will be easier once it is integrated.

Huh? You can run gnulib-tool in your local, modified gnulib checkout.
You don't need to assume something is in CVS before you can test it.

> +    memcpy (str, out, MIN (len, size));

That should be  len + 1  instead of len, no?

Other than that, I'm a little lost why anyone would need snprintf, when
he already has asnprintf in the library. Sure, snprintf is better than
sprintf, to avoid buffer overflows in jpeg displaying libraries :-)
But rather than using a size-limited buffer and then use a temporary
malloc-allocated buffer for filling the size-limited buffer, why would
you not use a malloc-allocated buffer for the result? Avoiding
arbitrary limits is one of the recommendations RMS gives in the GNU
     "Unix programs " [actually that's BSD style] " often have static
      tables or fixed-size strings, which make for arbitrary limits; use
      dynamic allocation instead."


reply via email to

[Prev in Thread] Current Thread [Next in Thread]