mirror of
https://github.com/neovim/neovim.git
synced 2026-08-28 01:51:52 +00:00
fix: avoid unsigned overflow in home_replace()
(cherry picked from commit d3ac297554)
This commit is contained in:
committed by
github-actions[bot]
parent
5eab16fa24
commit
06144afb71
@@ -1119,10 +1119,16 @@ size_t home_replace(const buf_T *const buf, const char *src, char *const dst, si
|
||||
len = envlen;
|
||||
}
|
||||
|
||||
if (dstlen == 0) {
|
||||
break; // Avoid overflowing below.
|
||||
}
|
||||
// if (!one) skip to separator: space or comma.
|
||||
while (*src && (one || (*src != ',' && *src != ' ')) && --dstlen > 0) {
|
||||
*dst_p++ = *src++;
|
||||
}
|
||||
if (dstlen == 0) {
|
||||
break; // Avoid overflowing below.
|
||||
}
|
||||
// Skip separator.
|
||||
while ((*src == ' ' || *src == ',') && --dstlen > 0) {
|
||||
*dst_p++ = *src++;
|
||||
|
||||
Reference in New Issue
Block a user