Mercurial > vim
diff src/blob.c @ 30938:84f6f91ca02a v9.0.0803
patch 9.0.0803: readblob() cannot read from character device
Commit: https://github.com/vim/vim/commit/43625762a9751cc6e6e4d8f54fbc8b82d98fb20d
Author: K.Takata <kentkt@csc.jp>
Date: Thu Oct 20 13:28:51 2022 +0100
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 https://github.com/vim/vim/issues/11407)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Thu, 20 Oct 2022 14:30:13 +0200 |
parents | ed6acfafa17e |
children | 61558a67630a |
line wrap: on
line diff
--- a/src/blob.c +++ b/src/blob.c @@ -212,9 +212,13 @@ read_blob(FILE *fd, typval_T *rettv, off } // 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)