chiark / gitweb /
cleanup: buffer size for snprintf should come from sizeof
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 19 Jun 2011 12:52:13 +0000 (13:52 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 26 Jun 2011 11:07:27 +0000 (12:07 +0100)
Previously, hardcoded copies of the buffer size literals were used.

Signed-off-by: Richard Kettlewell <richard@greenend.org.uk>
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
site.c
tun.c

diff --git a/site.c b/site.c
index 567b85f..17c3af2 100644 (file)
--- a/site.c
+++ b/site.c
@@ -217,7 +217,7 @@ static void slog(struct site *st, uint32_t event, cstring_t msg, ...)
        default: class=M_ERR; break;
        }
 
-       vsnprintf(buf,240,msg,ap);
+       vsnprintf(buf,sizeof(buf),msg,ap);
        st->log->log(st->log->st,class,"%s: %s",st->tunname,buf);
     }
     va_end(ap);
diff --git a/tun.c b/tun.c
index d899f0c..5f9aa98 100644 (file)
--- a/tun.c
+++ b/tun.c
@@ -332,7 +332,7 @@ static void tun_phase_hook(void *sst, uint32_t newphase)
 
     hostaddr=ipaddr_to_string(st->local_address);
     secnetaddr=ipaddr_to_string(st->nl.secnet_address);
-    snprintf(mtu,6,"%d",st->nl.mtu);
+    snprintf(mtu,sizeof(mtu),"%d",st->nl.mtu);
     mtu[5]=0;
 
     switch (st->ifconfig_type) {