diff options
author | jmallett <jmallett@FreeBSD.org> | 2002-05-02 02:06:03 +0000 |
---|---|---|
committer | jmallett <jmallett@FreeBSD.org> | 2002-05-02 02:06:03 +0000 |
commit | c136e5d44278a6b1c5a93a71adab858b5e07503b (patch) | |
tree | 5d1a203c4e6148f3db33c84e910b2308b11b1962 /usr.bin/xargs/strnsubst.c | |
parent | b59de1dbbb9fec4564d609d8ae32ab3686fe4c98 (diff) | |
download | FreeBSD-src-c136e5d44278a6b1c5a93a71adab858b5e07503b.zip FreeBSD-src-c136e5d44278a6b1c5a93a71adab858b5e07503b.tar.gz |
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.
Diffstat (limited to 'usr.bin/xargs/strnsubst.c')
-rw-r--r-- | usr.bin/xargs/strnsubst.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/usr.bin/xargs/strnsubst.c b/usr.bin/xargs/strnsubst.c index a06197e..bb8b20e 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; |