aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/xargs/strnsubst.c
diff options
context:
space:
mode:
authorJuli Mallett <jmallett@FreeBSD.org>2002-05-02 02:06:03 +0000
committerJuli Mallett <jmallett@FreeBSD.org>2002-05-02 02:06:03 +0000
commit0fa5e8dc420b528e314e3ea440a9bf3546955a84 (patch)
tree5d1a203c4e6148f3db33c84e910b2308b11b1962 /usr.bin/xargs/strnsubst.c
parent088f357d12f4881de81886cab7ff90b6d58c2468 (diff)
downloadsrc-0fa5e8dc420b528e314e3ea440a9bf3546955a84.tar.gz
src-0fa5e8dc420b528e314e3ea440a9bf3546955a84.zip
Rework some of the -I support so I can't find a way to make xargs(1) core or
corrupt memory. Simplifies the code in one or two places, also removes some code that looks like it was bogus or incomplete. Update strnsubst to have one or two extra conditions which maybe would make it more efficient, or at least more versatile. This is likely a no-op.
Notes
Notes: svn path=/head/; revision=95898
Diffstat (limited to 'usr.bin/xargs/strnsubst.c')
-rw-r--r--usr.bin/xargs/strnsubst.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/usr.bin/xargs/strnsubst.c b/usr.bin/xargs/strnsubst.c
index a06197ea72cc..bb8b20e193a5 100644
--- a/usr.bin/xargs/strnsubst.c
+++ b/usr.bin/xargs/strnsubst.c
@@ -38,6 +38,11 @@ strnsubst(char **str, const char *match, const char *replstr, size_t maxsize)
if (s2 == NULL)
err(1, "calloc");
+ if (match == NULL || replstr == NULL || maxsize == strlen(*str)) {
+ strlcpy(s2, s1, maxsize);
+ goto done;
+ }
+
for (;;) {
char *this;