mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-28 14:23:30 +01:00
Fix a minor coverity-found bug in tests
This commit is contained in:
parent
da3256b5ae
commit
3bf808c341
4
changes/coverity_master
Normal file
4
changes/coverity_master
Normal file
@ -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.
|
||||||
|
|
@ -1397,6 +1397,7 @@ run_util_spawn_background(const char *argv[], const char *expected_out,
|
|||||||
|
|
||||||
/* Check stdout */
|
/* Check stdout */
|
||||||
pos = read_all(stdout_pipe, stdout_buf, sizeof(stdout_buf) - 1, 0);
|
pos = read_all(stdout_pipe, stdout_buf, sizeof(stdout_buf) - 1, 0);
|
||||||
|
tor_assert(pos >= 0);
|
||||||
stdout_buf[pos] = '\0';
|
stdout_buf[pos] = '\0';
|
||||||
tt_int_op(pos, ==, strlen(expected_out));
|
tt_int_op(pos, ==, strlen(expected_out));
|
||||||
tt_str_op(stdout_buf, ==, 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 */
|
/* Check stderr */
|
||||||
pos = read_all(stderr_pipe, stderr_buf, sizeof(stderr_buf) - 1, 0);
|
pos = read_all(stderr_pipe, stderr_buf, sizeof(stderr_buf) - 1, 0);
|
||||||
|
tor_assert(pos >= 0);
|
||||||
stderr_buf[pos] = '\0';
|
stderr_buf[pos] = '\0';
|
||||||
tt_int_op(pos, ==, strlen(expected_err));
|
tt_int_op(pos, ==, strlen(expected_err));
|
||||||
tt_str_op(stderr_buf, ==, expected_err);
|
tt_str_op(stderr_buf, ==, expected_err);
|
||||||
|
Loading…
Reference in New Issue
Block a user