Fix snprintf(...%n...)
to pass not more than buffer size to %n agrument, old variant always assume infinite buffer. %n is for actually transmitted characters, not for planned ones.
This commit is contained in:
parent
4838495a16
commit
e73e3ecc2a
@ -39,7 +39,7 @@
|
||||
static char sccsid[] = "@(#)vfprintf.c 8.1 (Berkeley) 6/4/93";
|
||||
#endif
|
||||
static const char rcsid[] =
|
||||
"$Id: vfprintf.c,v 1.12 1997/02/22 15:02:40 peter Exp $";
|
||||
"$Id: vfprintf.c,v 1.13 1997/12/19 21:59:22 bde Exp $";
|
||||
#endif /* LIBC_SCCS and not lint */
|
||||
|
||||
/*
|
||||
@ -643,14 +643,18 @@ fp_begin: if (prec == -1)
|
||||
break;
|
||||
#endif /* FLOATING_POINT */
|
||||
case 'n':
|
||||
n = ret;
|
||||
if ((fp->_flags & __SSTR) &&
|
||||
fp->_bf._size < n)
|
||||
n = fp->_bf._size;
|
||||
if (flags & QUADINT)
|
||||
*GETARG(quad_t *) = ret;
|
||||
*GETARG(quad_t *) = n;
|
||||
else if (flags & LONGINT)
|
||||
*GETARG(long *) = ret;
|
||||
*GETARG(long *) = n;
|
||||
else if (flags & SHORTINT)
|
||||
*GETARG(short *) = ret;
|
||||
*GETARG(short *) = n;
|
||||
else
|
||||
*GETARG(int *) = ret;
|
||||
*GETARG(int *) = n;
|
||||
continue; /* no output */
|
||||
case 'O':
|
||||
flags |= LONGINT;
|
||||
|
Loading…
Reference in New Issue
Block a user