Prevents negative number of written bytes on error message.

Fixes #17758.
This commit is contained in:
Daniel Pinto 2016-08-16 17:12:18 +01:00
parent 5e571900b3
commit 4f19f85eda
1 changed files with 1 additions and 0 deletions

View File

@ -108,6 +108,7 @@ dump_microdescriptor(int fd, microdesc_t *md, size_t *annotation_len_out)
md->off = tor_fd_getpos(fd);
written = write_all(fd, md->body, md->bodylen, 0);
if (written != (ssize_t)md->bodylen) {
written = written < 0 ? 0 : written;
log_warn(LD_DIR,
"Couldn't dump microdescriptor (wrote %ld out of %lu): %s",
(long)written, (unsigned long)md->bodylen,