#include <string.h>
#include <stdlib.h>
#include <math.h>
+#include <assert.h>
#ifdef HAVE_CVT
buffy od;
int cc;
+ /*
+ * If someone calls snprintf(buf, 0, ...), then len == -1 here.
+ * Previously this code would assume an "unlimited" buffer size,
+ * thereby emulating sprintf(). Now we silently return and hope
+ * the caller doesn't expect us to terminate the buffer!
+ */
+ if (len < 0)
+ return;
/*
* First initialize the descriptor
* Notice that if no length is given, we initialize buf_end to the
* highest possible address.
*/
+#if OLD_CODE
od.buf_end = len ? &buf[len] : (char *) ~0;
+#else
+ od.buf_end = &buf[len];
+#endif
od.nextb = buf;
/*
{
int cc;
va_list ap;
+ assert(len >= 0);
va_start(ap, format);
strx_printv(&cc, buf, (len - 1), format, ap);
va_end(ap);
va_list ap)
{
int cc;
+ assert(len >= 0);
strx_printv(&cc, buf, (len - 1), format, ap);
return (cc);
}