[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Prevents negative number of written bytes on error message.



commit 4f19f85eda9fa096fcca2b8ce34b1db0b757d4a7
Author: Daniel Pinto <danielpinto52@xxxxxxxxx>
Date:   Tue Aug 16 17:12:18 2016 +0100

    Prevents negative number of written bytes on error message.
    
    Fixes #17758.
---
 src/or/microdesc.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/src/or/microdesc.c b/src/or/microdesc.c
index 130259a..a81dc54 100644
--- a/src/or/microdesc.c
+++ b/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,



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits