aboutsummaryrefslogtreecommitdiff
path: root/text.c
diff options
context:
space:
mode:
authorMarc André Tanner <mat@brain-dump.org>2017-07-05 22:10:12 +0200
committerMarc André Tanner <mat@brain-dump.org>2017-07-05 22:10:12 +0200
commit90df6338354b621828f2fae257380d766406b4a4 (patch)
treece9ae27a251b7fa76a61d36f6f0cd4c21e8accc0 /text.c
parentd6c4d8b155de16abcfcffa2a9bbfa886909b3ec3 (diff)
downloadvis-90df6338354b621828f2fae257380d766406b4a4.tar.gz
vis-90df6338354b621828f2fae257380d766406b4a4.tar.xz
text: limit write(2) calls to INT_MAX bytes
Otherwise this fails on macOS. Fix #578
Diffstat (limited to 'text.c')
-rw-r--r--text.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/text.c b/text.c
index 4c7fdc2..caf203b 100644
--- a/text.c
+++ b/text.c
@@ -175,7 +175,7 @@ static size_t lines_count(Text *txt, size_t pos, size_t len);
static ssize_t write_all(int fd, const char *buf, size_t count) {
size_t rem = count;
while (rem > 0) {
- ssize_t written = write(fd, buf, rem);
+ ssize_t written = write(fd, buf, rem > INT_MAX ? INT_MAX : rem);
if (written < 0) {
if (errno == EAGAIN || errno == EINTR)
continue;