{
va_list vl;
va_start(vl, format);
- vsnprintf(tunemu_error, ERROR_BUFFER_SIZE, format, vl);
+ vsnprintf(tunemu_error, sizeof tunemu_error, format, vl);
va_end(vl);
}
va_copy(aq, ap);
status = vsnprintf(*buf, len, fmt, aq);
+ buf[len - 1] = 0;
va_end(aq);
if(status >= 0)
va_start(ap, format);
int len = vsnprintf(message, sizeof message, format, ap);
+ message[sizeof message - 1] = 0;
va_end(ap);
- if(len > 0 && len < sizeof message && message[len - 1] == '\n')
+ if(len > 0 && len < sizeof message - 1 && message[len - 1] == '\n')
message[len - 1] = 0;
real_logger(level, priority, message);
}
static void sptps_logger(sptps_t *s, int s_errno, const char *format, va_list ap) {
- char message[1024] = "";
+ char message[1024];
size_t msglen = sizeof message;
int len = vsnprintf(message, msglen, format, ap);
- if(len > 0 && len < sizeof message) {
+ message[sizeof message - 1] = 0;
+ if(len > 0 && len < sizeof message - 1) {
if(message[len - 1] == '\n')
message[--len] = 0;
input buffer anyway */
va_start(args, format);
- len = vsnprintf(request, MAXBUFSIZE, format, args);
+ len = vsnprintf(request, sizeof request, format, args);
+ request[sizeof request - 1] = 0;
va_end(args);
- if(len < 0 || len > MAXBUFSIZE - 1) {
+ if(len < 0 || len > sizeof request - 1) {
logger(DEBUG_ALWAYS, LOG_ERR, "Output buffer overflow while sending request to %s (%s)",
c->name, c->hostname);
return false;
va_start(ap, format);
blen = vsnprintf(buffer, sizeof buffer, format, ap);
+ buffer[sizeof buffer - 1] = 0;
va_end(ap);
if(blen < 1 || blen >= sizeof buffer)
if(!pid) {
close(pfd[0]);
- char buf[100] = "";
+ char buf[100];
snprintf(buf, sizeof buf, "%d", pfd[1]);
setenv("TINC_UMBILICAL", buf, true);
exit(execvp(c, nargv));