[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
standards
"Unix programs " [actually that's BSD style] " often have static
tables or fixed-size strings, which make for arbitrary limits; use
dynamic allocation instead."
Bruno
- [Bug-gnulib] vasnprintf problem, Simon Josefsson, 2004/09/21
- Re: [Bug-gnulib] vasnprintf problem, Bruno Haible, 2004/09/21
- [Bug-gnulib] snprintf (was: Re: vasnprintf problem), Simon Josefsson, 2004/09/21
- Re: [Bug-gnulib] snprintf (was: Re: vasnprintf problem),
Bruno Haible <=
- [Bug-gnulib] Re: snprintf, Simon Josefsson, 2004/09/21
- [Bug-gnulib] Re: snprintf, Simon Josefsson, 2004/09/30
- Re: [Bug-gnulib] Re: snprintf, Paul Eggert, 2004/09/30
- [Bug-gnulib] Re: snprintf, Simon Josefsson, 2004/09/30
- [Bug-gnulib] Re: snprintf, Simon Josefsson, 2004/09/30