mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
fix: avoid unsigned overflow in home_replace() (#20854)
This commit is contained in:
parent
49fbcb5b82
commit
a7d100f052
@ -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++;
|
||||
|
@ -144,4 +144,10 @@ describe('tabpage', function()
|
||||
command(' silent :keepalt :: ::: silent! -2 tabmove')
|
||||
eq(1, funcs.nvim_tabpage_get_number(0))
|
||||
end)
|
||||
|
||||
it(':tabs does not overflow IObuff with long path with comma #20850', function()
|
||||
meths.buf_set_name(0, ('x'):rep(1024) .. ',' .. ('x'):rep(1024))
|
||||
command('tabs')
|
||||
assert_alive()
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user