commit 2b853804113a01672790aed67cb372d35554b61e
parent 14e430ac5b398e0c47f1d80f3c4f4b6386f545c2
Author: Kris Maglione <jg@suckless.org>
Date: Wed, 23 Sep 2009 11:26:48 -0400
Update kris/util.c strlcpy
Diffstat:
4 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/kris/Makefile b/kris/Makefile
@@ -0,0 +1 @@
+../Makefile
+\ No newline at end of file
diff --git a/kris/config.mk b/kris/config.mk
@@ -0,0 +1 @@
+../config.mk
+\ No newline at end of file
diff --git a/kris/sic.c b/kris/sic.c
@@ -28,14 +28,6 @@ static char channel[256];
static time_t trespond;
static FILE *srv;
-#define va_buf(buf, fmt) {\
- va_list ap; \
- \
- va_start(ap, fmt); \
- vsnprintf(buf, sizeof buf, fmt, ap); \
- va_end(ap); \
-}
-
#include "util.c"
static void
@@ -167,7 +159,7 @@ main(int argc, char *argv[]) {
if(++i < argc) password = argv[i];
break;
case 'v':
- eprint("sic-"VERSION", ? 2005-2007 Anselm R. Garbe, Nico Golde\n");
+ eprint("sic-"VERSION", ©2005-2009 Kris Maglione, Anselm R. Garbe, Nico Golde\n");
default:
eprint("usage: sic [-h host] [-p port] [-n nick] [-k keyword] [-v]\n");
}
diff --git a/kris/util.c b/kris/util.c
@@ -2,6 +2,13 @@
#include <netinet/in.h>
#include <sys/socket.h>
+#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';
}