diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Read and write slot keys and pages in full
xread and xwrite may move fewer bytes than asked. A short write of the key left a slot that could never match, a short read of it reported a collision, and a page write that moved nothing looped for ever.
Diffstat (limited to 'source/html.c')
-rw-r--r--source/html.c6
1 file changed, 5 insertions, 1 deletion
diff --git a/source/html.c b/source/html.c
index ef74bb3..367cea7 100644
--- a/source/html.c
+++ b/source/html.c
@@ -65,7 +65,11 @@ static void write_out(const char *data, size_t size)
while (size) {
ssize_t written = xwrite(STDOUT_FILENO, data, size);
- if (written < 0)
+ // A write that moves nothing would repeat for ever, so it
+ // counts as a full device, the way write_in_full treats it.
+ if (!written)
+ errno = ENOSPC;
+ if (written <= 0)
break;
data += written;
size -= written;