]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
Fix a minor coverity-found bug in tests
authorSebastian Hahn <sebastian@torproject.org>
Wed, 8 Jun 2011 17:58:27 +0000 (19:58 +0200)
committerSebastian Hahn <sebastian@torproject.org>
Wed, 8 Jun 2011 18:00:47 +0000 (20:00 +0200)
changes/coverity_master [new file with mode: 0644]
src/test/test_util.c

diff --git a/changes/coverity_master b/changes/coverity_master
new file mode 100644 (file)
index 0000000..3b61087
--- /dev/null
@@ -0,0 +1,4 @@
+  o Minor bugfixes:
+    - Prevent using negative indices during unit test runs when read_all()
+      fails. Spotted by coverity. Bugfix on 0.2.3.1.
+
index d338bbac9ce562b69d0bc4bb67c5ddc2a045f31c..afc4d5ce92cef8a14d5fff23ab0156579694f588 100644 (file)
@@ -1397,6 +1397,7 @@ run_util_spawn_background(const char *argv[], const char *expected_out,
 
   /* Check stdout */
   pos = read_all(stdout_pipe, stdout_buf, sizeof(stdout_buf) - 1, 0);
+  tor_assert(pos >= 0);
   stdout_buf[pos] = '\0';
   tt_int_op(pos, ==, strlen(expected_out));
   tt_str_op(stdout_buf, ==, expected_out);
@@ -1411,6 +1412,7 @@ run_util_spawn_background(const char *argv[], const char *expected_out,
 
   /* Check stderr */
   pos = read_all(stderr_pipe, stderr_buf, sizeof(stderr_buf) - 1, 0);
+  tor_assert(pos >= 0);
   stderr_buf[pos] = '\0';
   tt_int_op(pos, ==, strlen(expected_err));
   tt_str_op(stderr_buf, ==, expected_err);