This is the mail archive of the
newlib@sources.redhat.com
mailing list for the newlib project.
Re: Problem with snprintf()
- To: dwyatt at sunflower dot com
- Subject: Re: Problem with snprintf()
- From: Corinna Vinschen <vinschen at cygnus dot com>
- Date: Mon, 07 Aug 2000 17:43:28 +0200
- CC: newlib at sourceware dot cygnus dot com
- References: <200008071512.KAA00988@mail1.sunflower.com>
- Reply-To: newlib <newlib at sources dot redhat dot com>
Doug Wyatt wrote:
> Is the newlib version wrong? It appears to be in light of this
> excerpt from the RH6.2 snprintf man entry, also:
>
> Return value
> "
> "
> snprintf and vsnprintf do not write more than size bytes
> (including the trailing '\0'), and return -1 if the output was
> truncated due to this limit. (Thus until glibc 2.0.6. Since
> glibc 2.1 these functions follow the C99 standard and return the
> number of characters (excluding the trailing '\0') which would
> have been written to the final string if enough space had been
> available.)
>
> The problem arises in a configure file which wants (size - 1)
> bytes in 'target'.
>
> Is the newlib behavior a variant or a bug?
I have found another problem with snprintf. While porting OpenSSH
to Cygwin I found that configure reports the following:
configure:2567: checking whether snprintf correctly terminates long
strings
configure: warning: ****** Your snprintf() function is broken,
complain to your vendor
The configure file contains the following test:
#include <stdio.h>
int main(void){char b[5];snprintf(b,5,"123456789");return(b[4]!='\0');}
As you can see, it expects snprintf terminating strings with \0 always
which seems not to be the case for the newlib version.
Shouldn't this be fixed as well?
Corinna
--
Corinna Vinschen Please, send mails regarding Cygwin to
Cygwin Developer mailto:cygwin@sources.redhat.com
Red Hat, Inc.
mailto:vinschen@cygnus.com