mirror of
https://github.com/neovim/neovim.git
synced 2026-04-02 05:39:26 +00:00
vim-patch:9.2.0271: buffer underflow in vim_fgets() (#38575)
Problem: buffer underflow in vim_fgets()
Solution: Ensure size is always greater than 1
(Koda Reef)
3c0f8000e1
This currently never happens in Nvim.
Co-authored-by: Koda Reef <kodareef5@gmail.com>
This commit is contained in:
@@ -2498,7 +2498,14 @@ bool vim_fgets(char *buf, int size, FILE *fp)
|
||||
{
|
||||
char *retval;
|
||||
|
||||
assert(size > 0);
|
||||
// safety check
|
||||
if (size < 2) {
|
||||
if (size == 1) {
|
||||
buf[0] = NUL;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
buf[size - 2] = NUL;
|
||||
|
||||
do {
|
||||
|
||||
Reference in New Issue
Block a user