summaryrefslogtreecommitdiffstats
path: root/usr.bin/cvs/xmalloc.c
diff options
context:
space:
mode:
authorxsa <xsa@openbsd.org>2007-01-29 16:22:29 +0000
committerxsa <xsa@openbsd.org>2007-01-29 16:22:29 +0000
commit005d0989509df1c659c8b3acaa15cefeac75e66a (patch)
tree86505d7150b82d2a481ac03cc7aa65841f48822c /usr.bin/cvs/xmalloc.c
parentno longer spit out that you can add new files using 'cvs add', (diff)
downloadwireguard-openbsd-005d0989509df1c659c8b3acaa15cefeac75e66a.tar.xz
wireguard-openbsd-005d0989509df1c659c8b3acaa15cefeac75e66a.zip
introduce xsnprintf(); OK otto@ joris@.
Diffstat (limited to 'usr.bin/cvs/xmalloc.c')
-rw-r--r--usr.bin/cvs/xmalloc.c18
1 files changed, 17 insertions, 1 deletions
diff --git a/usr.bin/cvs/xmalloc.c b/usr.bin/cvs/xmalloc.c
index 1baf4a1ea2d..9883da91ef9 100644
--- a/usr.bin/cvs/xmalloc.c
+++ b/usr.bin/cvs/xmalloc.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: xmalloc.c,v 1.6 2006/03/28 02:13:44 ray Exp $ */
+/* $OpenBSD: xmalloc.c,v 1.7 2007/01/29 16:22:29 xsa Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -102,3 +102,19 @@ xasprintf(char **ret, const char *fmt, ...)
return (i);
}
+
+int
+xsnprintf(char *str, size_t size, const char *fmt, ...)
+{
+ va_list ap;
+ int i;
+
+ va_start(ap, fmt);
+ i = vsnprintf(str, size, fmt, ap);
+ va_end(ap);
+
+ if (i == -1 || i >= (int)size)
+ fatal("xsnprintf: overflow");
+
+ return (i);
+}