aboutsummaryrefslogtreecommitdiff
path: root/usr.bin/xargs/strnsubst.c
diff options
context:
space:
mode:
authorJuli Mallett <jmallett@FreeBSD.org>2002-05-03 19:45:41 +0000
committerJuli Mallett <jmallett@FreeBSD.org>2002-05-03 19:45:41 +0000
commit38dff9a4391c3c3537814acecc88b433fcd40156 (patch)
treed7fecd4bab2ff2f82aa5b04a1f4604f7f1a3946d /usr.bin/xargs/strnsubst.c
parentde8541ffe6ad4931309eeb7101ed8217ec640809 (diff)
downloadsrc-38dff9a4391c3c3537814acecc88b433fcd40156.tar.gz
src-38dff9a4391c3c3537814acecc88b433fcd40156.zip
Fix a bug whereby we were getting ~0 and comparing it to maxsize, i.e. if
s1 was 0 length, and replstr was 0 length, etc., we would end up subtracting one from zero and seeing if it was greater than the size_t (unsigned) var maxsize... This would cause us to return a string consisting of essentially only match, which is not the right behaviour if we have 0 length inpline.
Notes
Notes: svn path=/head/; revision=95996
Diffstat (limited to 'usr.bin/xargs/strnsubst.c')
-rw-r--r--usr.bin/xargs/strnsubst.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/usr.bin/xargs/strnsubst.c b/usr.bin/xargs/strnsubst.c
index 6baa3f0df704..5ca2773fded7 100644
--- a/usr.bin/xargs/strnsubst.c
+++ b/usr.bin/xargs/strnsubst.c
@@ -48,7 +48,7 @@ strnsubst(char **str, const char *match, const char *replstr, size_t maxsize)
if (this == NULL)
break;
if ((strlen(s2) + ((uintptr_t)this - (uintptr_t)s1) +
- (strlen(replstr) - 1)) > maxsize) {
+ (strlen(replstr) - 1)) > maxsize && *replstr != '\0') {
strlcat(s2, s1, maxsize);
goto done;
}