Incorrect return types for snprintf() and vsnprintf()

mouring at etoh.eviladmin.org mouring at etoh.eviladmin.org
Sat Oct 20 06:41:47 EST 2001


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
>
>




More information about the openssh-unix-dev mailing list