]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Use read_all() to read messages from spawn_background
authorNick Mathewson <nickm@torproject.org>
Thu, 5 May 2011 03:32:18 +0000 (23:32 -0400)
committerNick Mathewson <nickm@torproject.org>
Thu, 5 May 2011 03:32:18 +0000 (23:32 -0400)
Using read() is an invitation to get some of the data you want, not all.

Possible fix for bug 2462

src/test/test_util.c

index 25fd51c1246053e793760ab558fd036672f17c3d..efbc47b4606b8e2420566cdf5641046bdf80540c 100644 (file)
@@ -1367,7 +1367,7 @@ run_util_spawn_background(const char *argv[], const char *expected_out,
   pid = retval;
 
   /* Check stdout */
-  pos = read(stdout_pipe, stdout_buf, sizeof(stdout_buf) - 1);
+  pos = read_all(stdout_pipe, stdout_buf, sizeof(stdout_buf) - 1, 0);
   stdout_buf[pos] = '\0';
   tt_int_op(pos, ==, strlen(expected_out));
   tt_str_op(stdout_buf, ==, expected_out);
@@ -1381,7 +1381,7 @@ run_util_spawn_background(const char *argv[], const char *expected_out,
   tt_assert(!WIFSTOPPED(stat_loc));
 
   /* Check stderr */
-  pos = read(stderr_pipe, stderr_buf, sizeof(stderr_buf) - 1);
+  pos = read_all(stderr_pipe, stderr_buf, sizeof(stderr_buf) - 1, 0);
   stderr_buf[pos] = '\0';
   tt_int_op(pos, ==, strlen(expected_err));
   tt_str_op(stderr_buf, ==, expected_err);