From 2b853804113a01672790aed67cb372d35554b61e Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Wed, 23 Sep 2009 11:26:48 -0400 Subject: Update kris/util.c strlcpy --- kris/util.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'kris/util.c') diff --git a/kris/util.c b/kris/util.c index 19c2f2b..53b2fe8 100644 --- a/kris/util.c +++ b/kris/util.c @@ -2,6 +2,13 @@ #include #include +#define va_buf(buf, fmt) {\ + va_list ap; \ + va_start(ap, fmt); \ + vsnprintf(buf, sizeof buf, fmt, ap); \ + va_end(ap); \ +} + static void eprint(const char *fmt, ...) { @@ -34,7 +41,7 @@ dial(char *host, int port) { #define strlcpy _strlcpy static void strlcpy(char *to, const char *from, int l) { - strncpy(to, from, l-1); + memccpy(to, from, '\0', l); to[l-1] = '\0'; } -- cgit v1.2.3