]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Add a sanity check
authorSteven Murdoch <Steven.Murdoch@cl.cam.ac.uk>
Sun, 28 Aug 2011 23:36:41 +0000 (00:36 +0100)
committerSteven Murdoch <Steven.Murdoch@cl.cam.ac.uk>
Sun, 28 Aug 2011 23:36:41 +0000 (00:36 +0100)
src/common/util.c

index 371e09b8db8c3d39f4bb42f93815a88bce59a7f0..dd2d1110e94ea9df1c1645a872063665bdb26183 100644 (file)
@@ -3462,10 +3462,11 @@ tor_read_all_handle(HANDLE h, char *buf, size_t count, HANDLE hProcess)
       continue;
     }
 
+    /* There is data to read; read it */
     retval = ReadFile(h, buf+numread, count-numread, &byte_count, NULL);
+    tor_assert(byte_count + numread <= count);
     if (!retval) {
-      log_warn(LD_GENERAL,
-        "Failed to read from handle: %s",
+      log_warn(LD_GENERAL, "Failed to read from handle: %s",
         format_win32_error(GetLastError()));
       return -1;
     } else if (0 == byte_count) {