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

[tor-commits] [tor/release-0.2.3] Don't assert in get_string_from_pipe() on len==0



commit ffd7189b3fc015ce47e6ab27ac85d4eab2183a2b
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Sat Jun 23 15:35:43 2012 -0400

    Don't assert in get_string_from_pipe() on len==0
    
    We can treat this case as an EAGAIN (probably because of an
    unexpected internal NUL) rather than a crash-worthy problem.
    
    Fixes bug 6225, again.  Bug not in any released version of Tor.
---
 src/common/util.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/src/common/util.c b/src/common/util.c
index 8cb013e..e5b51b9 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -4386,7 +4386,10 @@ get_string_from_pipe(FILE *stream, char *buf_out, size_t count)
     }
   } else {
     len = strlen(buf_out);
-    tor_assert(len>0);
+    if (len == 0) {
+      /* this probably means we got a NUL at the start of the string. */
+      return IO_STREAM_EAGAIN;
+    }
 
     if (buf_out[len - 1] == '\n') {
       /* Remove the trailing newline */



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