Fix zero size reads

In certain cases we may get zero size reads (e.g. if the server sends an
rfc2217 notification without any other data).
In this situation we must not propagate the zero size read to user space
as it may be interpreted as end of input.

I haven't found a way to tell fuse that it should just ignore this read
but passing EINTR seems to work.
This commit is contained in:
Kim Woelders
2018-07-02 12:31:57 +02:00
parent 5ca23ce107
commit 0f879c8b61
+11 -4
View File
@@ -407,10 +407,17 @@ ttynvt_read(fuse_req_t req, size_t size, off_t off,
}
if (size > tty->rxcnt)
size = tty->rxcnt;
fuse_reply_buf(req, tty->buf, size);
memmove(tty->buf, tty->buf + size, tty->blen - size);
tty->blen -= size;
tty->rxcnt -= size;
if (size > 0)
{
fuse_reply_buf(req, tty->buf, size);
memmove(tty->buf, tty->buf + size, tty->blen - size);
tty->blen -= size;
tty->rxcnt -= size;
}
else
{
fuse_reply_err(req, EINTR);
}
pthread_mutex_unlock(&tty->tty_lock);
}