diff options
author | jmallett <jmallett@FreeBSD.org> | 2002-05-03 19:45:41 +0000 |
---|---|---|
committer | jmallett <jmallett@FreeBSD.org> | 2002-05-03 19:45:41 +0000 |
commit | 98e4fb17a50fab6754397707b279e9747bce4868 (patch) | |
tree | d7fecd4bab2ff2f82aa5b04a1f4604f7f1a3946d /usr.bin | |
parent | e13651801acee7fd9a1da2b4d7a9b3f2154b2891 (diff) | |
download | FreeBSD-src-98e4fb17a50fab6754397707b279e9747bce4868.zip FreeBSD-src-98e4fb17a50fab6754397707b279e9747bce4868.tar.gz |
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.
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/xargs/strnsubst.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/usr.bin/xargs/strnsubst.c b/usr.bin/xargs/strnsubst.c index 6baa3f0..5ca2773 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; } |