mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 00:11:26 +00:00
([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:
parent
7dc236f936
commit
e73a7fe9bc
1 changed files with 9 additions and 2 deletions
|
@ -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];
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue