summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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;