]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Don't assert in get_string_from_pipe() on len==0
authorNick Mathewson <nickm@torproject.org>
Sat, 23 Jun 2012 19:35:43 +0000 (15:35 -0400)
committerNick Mathewson <nickm@torproject.org>
Sat, 23 Jun 2012 19:35:43 +0000 (15:35 -0400)
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

index 8cb013e18a54874ccbcd24eb6f306ec9b67b49f3..e5b51b9a94718e55ede7464bd20b8aace11a9660 100644 (file)
@@ -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 */