From 09e688d53b13d2dc520fa196ec2c29d84a866c10 Mon Sep 17 00:00:00 2001 From: Nikita Ivanov Date: Sun, 5 Jun 2022 00:31:16 +0500 Subject: [PATCH] Fix: write/read expect number of bytes, not len --- preview.c | 2 +- server.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/preview.c b/preview.c index b24831f..1d3441a 100644 --- a/preview.c +++ b/preview.c @@ -132,7 +132,7 @@ static int run(Preview *p, int *exitcode) if (*exitcode != FAILED_PREVIEW_EC) { char buf[256]; int len; - while ((len = read(pipe_fds[0], buf, LEN(buf))) > 0) { + while ((len = read(pipe_fds[0], buf, sizeof(buf))) > 0) { write(STDOUT_FILENO, buf, len); } diff --git a/server.c b/server.c index 4e3c96c..4f89935 100644 --- a/server.c +++ b/server.c @@ -90,7 +90,7 @@ static int listen(char *fifo) if (pollfd.revents & POLLIN) { static char buf[1024]; - while ((len = read(pollfd.fd, buf, LEN(buf))) > 0) { + while ((len = read(pollfd.fd, buf, sizeof(buf))) > 0) { /* But first byte equal to 0 means "exit" */ if (buf[0] == 0) goto close;