From f0571a11c9003c2b5ec393499679fe353f49a715 Mon Sep 17 00:00:00 2001 From: oetiker Date: Fri, 6 Mar 2009 05:30:08 +0000 Subject: [PATCH] Make sure we use correct sizes for vsnprintf (sizeof) and strncpy (sizeof-1). -- kevin git-svn-id: svn://svn.oetiker.ch/rrdtool/trunk@1751 a5681a0c-68f1-0310-ab6d-d61299d08faa --- program/src/rrd_daemon.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/program/src/rrd_daemon.c b/program/src/rrd_daemon.c index 6445e55d..7a72b070 100644 --- a/program/src/rrd_daemon.c +++ b/program/src/rrd_daemon.c @@ -466,7 +466,7 @@ static int add_response_info(listen_socket_t *sock, char *fmt, ...) /* {{{ */ va_start(argp, fmt); #ifdef HAVE_VSNPRINTF - len = vsnprintf(buffer, sizeof(buffer)-1, fmt, argp); + len = vsnprintf(buffer, sizeof(buffer), fmt, argp); #else len = vsprintf(buffer, fmt, argp); #endif @@ -524,7 +524,7 @@ static int send_response (listen_socket_t *sock, response_code rc, rclen = sprintf(buffer, "%d ", lines); va_start(argp, fmt); #ifdef HAVE_VSNPRINTF - len = vsnprintf(buffer+rclen, sizeof(buffer)-rclen-1, fmt, argp); + len = vsnprintf(buffer+rclen, sizeof(buffer)-rclen, fmt, argp); #else len = vsprintf(buffer+rclen, fmt, argp); #endif @@ -2159,7 +2159,7 @@ static int open_listen_socket_network(const listen_socket_t *sock) /* {{{ */ char *port; int status; - strncpy (addr_copy, sock->addr, sizeof (addr_copy)); + strncpy (addr_copy, sock->addr, sizeof(addr_copy)-1); addr_copy[sizeof (addr_copy) - 1] = 0; addr = addr_copy; @@ -2451,7 +2451,7 @@ static int daemonize (void) /* {{{ */ { listen_socket_t sock; memset(&sock, 0, sizeof(sock)); - strncpy(sock.addr, RRDCACHED_DEFAULT_ADDRESS, sizeof(sock.addr)); + strncpy(sock.addr, RRDCACHED_DEFAULT_ADDRESS, sizeof(sock.addr)-1); open_listen_socket (&sock); } -- 2.30.2