Browse Source

Prevents negative number of written bytes on error message.

Fixes #17758.
Daniel Pinto 7 years ago
parent
commit
4f19f85eda
1 changed files with 1 additions and 0 deletions
  1. 1 0
      src/or/microdesc.c

+ 1 - 0
src/or/microdesc.c

@@ -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,