mirror of
https://github.com/freebsd/freebsd-src
synced 2024-09-20 00:33:57 +00:00
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.
This commit is contained in:
parent
de8541ffe6
commit
38dff9a439
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=95996
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue