vasprintf: Pass a 1-character buffer to initial vsnprintf call.

GNO vsnprintf will give an error if size is 0, leading vasprintf to fail. This prevented sending data in telnetd.
This commit is contained in:
Stephen Heumann 2015-06-03 20:38:31 -05:00
parent 7968e76e4a
commit 98b485d83b

View File

@ -44,9 +44,10 @@ vasprintf(char **strp, const char *fmt, va_list ap)
{
va_list aq;
int ret;
char c;
va_copy(aq, ap);
ret = vsnprintf(NULL, 0, fmt, ap);
ret = vsnprintf(&c, 1, fmt, ap);
/* va_end(ap); -- Don't do this on ORCA/C; it messes up the stack */
if ((*strp = malloc(ret + 1)) == NULL)
return (-1);