summaryrefslogtreecommitdiffstats
path: root/src/blob.c
diff options
context:
space:
mode:
authorK.Takata <kentkt@csc.jp>2022-10-20 13:28:51 +0100
committerBram Moolenaar <Bram@vim.org>2022-10-20 13:28:51 +0100
commit43625762a9751cc6e6e4d8f54fbc8b82d98fb20d (patch)
tree0261835c4d3eb079e9013ae8277531b12c1d5db2 /src/blob.c
parent4c36678ffd1f933a6d4a12415994dea15e4ccec6 (diff)
patch 9.0.0803: readblob() cannot read from character devicev9.0.0803
Problem: readblob() cannot read from character device. Solution: Use S_ISCHR() to not check the size. (Ken Takata, closes #11407)
Diffstat (limited to 'src/blob.c')
-rw-r--r--src/blob.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/blob.c b/src/blob.c
index 92efb67ab5..a94316c13f 100644
--- a/src/blob.c
+++ b/src/blob.c
@@ -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)