([NSString -initWithFormat:arguments:]): Increase bsprintf buffer

size, and assert that we haven't overrun the buffer.


git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@1606 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
mccallum 1996-05-31 15:10:53 +00:00
parent ac13a2bde7
commit ce049ea252

View file

@ -300,8 +300,15 @@ handle_printf_atsign (FILE *stream,
arguments: (va_list)argList
{
#if HAVE_VSPRINTF
char buf[128]; /* xxx horrible, disgusting, fix this! */
vsprintf(buf, [format _cStringContents], argList);
#define BUFFER_EXTRA 1024
const char *format_cp = [format cStringNoCopy]);
int format_len = strlen (format_cp);
char buf[format_len + BUFFER_EXTRA]; /* xxx horrible disgusting, fix this! */
int printed_len;
printed_len = vsprintf (buf, format_cp, argList);
/* Signal error if we overran our buffer. */
NSParameterAssert (printed_len < format_len + BUFFER_EXTRA - 1);
return [self initWithCString:buf];
#else
[self notImplemented:_cmd];