va_copy(aq, ap);
status = vsnprintf(*buf, len, fmt, aq);
+ buf[len - 1] = 0;
va_end(aq);
if(status >= 0)
char message[4096];
const char *messages[] = {message};
vsnprintf(message, sizeof(message), format, ap);
+ message[sizeof message - 1] = 0;
ReportEvent(loghandle, priority, 0, 0, NULL, 1, 0, messages, NULL);
}
#else
input buffer anyway */
va_start(args, format);
- len = vsnprintf(buffer, MAXBUFSIZE, format, args);
+ len = vsnprintf(buffer, sizeof buffer, format, args);
+ buffer[sizeof buffer - 1] = 0;
va_end(args);
- if(len < 0 || len > MAXBUFSIZE - 1) {
+ if(len < 0 || len > sizeof buffer - 1) {
logger(LOG_ERR, "Output buffer overflow while sending request to %s (%s)",
c->name, c->hostname);
return false;
int result = vsnprintf(buf, sizeof buf, fmt, ap);
if(result < 0)
exit(xalloc_exit_failure);
+ buf[sizeof buf - 1] = 0;
*strp = xstrdup(buf);
#else
int result = vasprintf(strp, fmt, ap);