diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-02-28 19:23:28 +0800 |
---|---|---|
committer | zeertzjq <zeertzjq@outlook.com> | 2023-02-28 19:52:45 +0800 |
commit | 4bd0611d7b07b56fc5a9e121669a313166ba540f (patch) | |
tree | 9872da5aad04774dca33d95c6d42140a0c978af0 /src/nvim/eval.c | |
parent | bfa0bc7df0ca527fcec49dbd2055f1bac438663e (diff) | |
download | rneovim-4bd0611d7b07b56fc5a9e121669a313166ba540f.tar.gz rneovim-4bd0611d7b07b56fc5a9e121669a313166ba540f.tar.bz2 rneovim-4bd0611d7b07b56fc5a9e121669a313166ba540f.zip |
vim-patch:9.0.0803: readblob() cannot read from character device
Problem: readblob() cannot read from character device.
Solution: Use S_ISCHR() to not check the size. (Ken Takata, closes vim/vim#11407)
https://github.com/vim/vim/commit/43625762a9751cc6e6e4d8f54fbc8b82d98fb20d
S_ISCHR is always defined in Nvim.
Co-authored-by: K.Takata <kentkt@csc.jp>
Diffstat (limited to 'src/nvim/eval.c')
-rw-r--r-- | src/nvim/eval.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index c2f84735b2..92fd8a8de3 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -5893,10 +5893,11 @@ int read_blob(FILE *const fd, typval_T *rettv, off_T offset, off_T size_arg) } // Trying to read bytes that aren't there results in an empty blob, not an // error. - if (size < 0 || size > (off_T)os_fileinfo_size(&file_info)) { + if (size < 0 || (!S_ISCHR(file_info.stat.st_mode) + && size > (off_T)os_fileinfo_size(&file_info))) { return OK; } - if (vim_fseek(fd, offset, whence) != 0) { + if (offset != 0 && vim_fseek(fd, offset, whence) != 0) { return OK; } |