Both of these functions are using strlen() to create return value.
Cheers,
Scott Rankin
*** /openbsd-compat/bsd-snprintf.c.orig Thu Oct 18 13:57:51 2001
--- /openbsd-compat/bsd-snprintf.c Thu Oct 18 13:58:26 2001
***************
*** 632,638 ****
#endif /* !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) */
#ifndef HAVE_VSNPRINTF
! int
vsnprintf(char *str, size_t count, const char *fmt, va_list args)
{
str[0] = 0;
--- 632,638 ----
#endif /* !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) */
#ifndef HAVE_VSNPRINTF
! size_t
vsnprintf(char *str, size_t count, const char *fmt, va_list args)
{
str[0] = 0;
***************
*** 643,649 ****
#endif /* !HAVE_VSNPRINTF */
#ifndef HAVE_SNPRINTF
! int
snprintf(char *str,size_t count,const char *fmt,...)
{
va_list ap;
--- 643,649 ----
#endif /* !HAVE_VSNPRINTF */
#ifndef HAVE_SNPRINTF
! size_t
snprintf(char *str,size_t count,const char *fmt,...)
{
va_list ap;
*** /openbsd-compat/bsd-snprintf.h.orig Thu Oct 18 14:00:08 2001
--- /openbsd-compat/bsd-snprintf.h Thu Oct 18 14:00:35 2001
***************
*** 8,18 ****
#include <sys/types.h> /* For size_t */
#ifndef HAVE_SNPRINTF
! int snprintf(char *str, size_t count, const char *fmt, ...);
#endif /* !HAVE_SNPRINTF */
#ifndef HAVE_VSNPRINTF
! int vsnprintf(char *str, size_t count, const char *fmt, va_list args);
#endif /* !HAVE_SNPRINTF */
--- 8,18 ----
#include <sys/types.h> /* For size_t */
#ifndef HAVE_SNPRINTF
! size_t snprintf(char *str, size_t count, const char *fmt, ...);
#endif /* !HAVE_SNPRINTF */
#ifndef HAVE_VSNPRINTF
! size_t vsnprintf(char *str, size_t count, const char *fmt, va_list args);
#endif /* !HAVE_SNPRINTF */
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
Richard Kettlewell
2001-Oct-19 14:44 UTC
Incorrect return types for snprintf() and vsnprintf()
"s c o t t" <spaceacademy at hotmail.com> writes:> Both of these functions are using strlen() to create return value.This patch would make the -compat versions incompatible with the standard versions of [v]snprintf, which return int (and in particular, return -1 to signal certain errors). ttfn/rjk -- http://www.greenend.org.uk/rjk/
mouring at etoh.eviladmin.org
2001-Oct-19 20:41 UTC
Incorrect return types for snprintf() and vsnprintf()
What platform? Solaris and Linux return int even if they use size_t in their arguments. - Ben On Thu, 18 Oct 2001, s c o t t wrote:> Both of these functions are using strlen() to create return value. > > Cheers, > Scott Rankin > > *** /openbsd-compat/bsd-snprintf.c.orig Thu Oct 18 13:57:51 2001 > --- /openbsd-compat/bsd-snprintf.c Thu Oct 18 13:58:26 2001 > *************** > *** 632,638 **** > #endif /* !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) */ > > #ifndef HAVE_VSNPRINTF > ! int > vsnprintf(char *str, size_t count, const char *fmt, va_list args) > { > str[0] = 0; > --- 632,638 ---- > #endif /* !defined(HAVE_SNPRINTF) || !defined(HAVE_VSNPRINTF) */ > > #ifndef HAVE_VSNPRINTF > ! size_t > vsnprintf(char *str, size_t count, const char *fmt, va_list args) > { > str[0] = 0; > *************** > *** 643,649 **** > #endif /* !HAVE_VSNPRINTF */ > > #ifndef HAVE_SNPRINTF > ! int > snprintf(char *str,size_t count,const char *fmt,...) > { > va_list ap; > --- 643,649 ---- > #endif /* !HAVE_VSNPRINTF */ > > #ifndef HAVE_SNPRINTF > ! size_t > snprintf(char *str,size_t count,const char *fmt,...) > { > va_list ap; > > *** /openbsd-compat/bsd-snprintf.h.orig Thu Oct 18 14:00:08 2001 > --- /openbsd-compat/bsd-snprintf.h Thu Oct 18 14:00:35 2001 > *************** > *** 8,18 **** > #include <sys/types.h> /* For size_t */ > > #ifndef HAVE_SNPRINTF > ! int snprintf(char *str, size_t count, const char *fmt, ...); > #endif /* !HAVE_SNPRINTF */ > > #ifndef HAVE_VSNPRINTF > ! int vsnprintf(char *str, size_t count, const char *fmt, va_list args); > #endif /* !HAVE_SNPRINTF */ > > > --- 8,18 ---- > #include <sys/types.h> /* For size_t */ > > #ifndef HAVE_SNPRINTF > ! size_t snprintf(char *str, size_t count, const char *fmt, ...); > #endif /* !HAVE_SNPRINTF */ > > #ifndef HAVE_VSNPRINTF > ! size_t vsnprintf(char *str, size_t count, const char *fmt, va_list args); > #endif /* !HAVE_SNPRINTF */ > > > _________________________________________________________________ > Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp > >