summaryrefslogtreecommitdiff
path: root/usr.bin/xargs
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2003-06-12 03:23:23 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2003-06-12 03:23:23 +0000
commit13c26e4c9eb1487e27b7e1c6f2c3710a6e4bb90a (patch)
tree1adfcbe2dd984800b12c88de4d6654be21bfa459 /usr.bin/xargs
parentcbf24587550c533ccb4f756f8b74a3780db3dd0e (diff)
Check snprintf rval for -1
Diffstat (limited to 'usr.bin/xargs')
-rw-r--r--usr.bin/xargs/strnsubst.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/usr.bin/xargs/strnsubst.c b/usr.bin/xargs/strnsubst.c
index 01405717ba4..977c9f051b2 100644
--- a/usr.bin/xargs/strnsubst.c
+++ b/usr.bin/xargs/strnsubst.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: strnsubst.c,v 1.1 2003/06/12 01:09:23 millert Exp $ */
+/* $OpenBSD: strnsubst.c,v 1.2 2003/06/12 03:23:22 millert Exp $ */
/* $FreeBSD: strnsubst.c,v 1.6 2002/06/22 12:58:42 jmallett Exp $ */
/*
@@ -10,7 +10,7 @@
*/
#ifndef lint
-static const char rcsid[] = "$OpenBSD: strnsubst.c,v 1.1 2003/06/12 01:09:23 millert Exp $";
+static const char rcsid[] = "$OpenBSD: strnsubst.c,v 1.2 2003/06/12 03:23:22 millert Exp $";
#endif /* not lint */
#include <err.h>
@@ -59,7 +59,7 @@ strnsubst(char **str, const char *match, const char *replstr, size_t maxsize)
break;
n = snprintf(s2 + s2len, maxsize - s2len, "%.*s%s",
(int)(this - s1), s1, replstr);
- if (n + s2len + strlen(this + matchlen) >= maxsize)
+ if (n == -1 || n + s2len + strlen(this + matchlen) >= maxsize)
break; /* out of room */
s2len += n;
s1 = this + matchlen;