Subject: Re: pkg/20155: glib-1.2.x: Documentation violation in g_{v,}snprintf
To: None <gnats-bugs@gnats.netbsd.org, christianbiere@gmx.de>
From: David Laight <david@l8s.co.uk>
List: netbsd-bugs
Date: 02/01/2003 22:09:31
> 
> --- gutils.c	2000/08/09 18:12:31	1.1
> +++ gutils.c	2003/02/01 20:38:25
> @@ -149,6 +149,11 @@
>        str[n-1] = '\0';
>        retval = strlen (str);
>      }
> +  else if (retval >= n) 
> +    {
> +      str[n-1] = '\0';
> +      retval = n - 1;
> +    }
>  
>    return retval;
>  #else	/* !HAVE_VSNPRINTF */
> @@ -191,6 +196,11 @@
>      {
>        str[n-1] = '\0';
>        retval = strlen (str);
> +    }
> +  else if (retval >= n)
> +    {
> +      str[n-1] = '\0';
> +      retval = n - 1;
>      }

the assigments to str[n-1] are not necessary...
(unless that code isn't doing the obvious)

Also, is the definition of g_snprintf() actually correct?
Posix states:

    Upon successful completion, the snprintf() function shall return the
    number of bytes that would be written to s had n been sufficiently large
    excluding the terminating null byte.

One would have thought that it would obey the same rules.

	David

-- 
David Laight: david@l8s.co.uk