瀏覽代碼

Add a sanity check

Steven Murdoch 14 年之前
父節點
當前提交
93792b5aa6
共有 1 個文件被更改,包括 3 次插入2 次删除
  1. 3 2
      src/common/util.c

+ 3 - 2
src/common/util.c

@@ -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) {