1
0
forked from aniani/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 #11407)
This commit is contained in:
K.Takata
2022-10-20 13:28:51 +01:00
committed by Bram Moolenaar
parent 4c36678ffd
commit 43625762a9
5 changed files with 20 additions and 4 deletions

View File

@@ -212,9 +212,13 @@ read_blob(FILE *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 > st.st_size)
if (size <= 0 || (
#ifdef S_ISCHR
!S_ISCHR(st.st_mode) &&
#endif
size > st.st_size))
return OK;
if (vim_fseek(fd, offset, whence) != 0)
if (offset != 0 && vim_fseek(fd, offset, whence) != 0)
return OK;
if (ga_grow(&blob->bv_ga, (int)size) == FAIL)