diff options
author | Alexander Færøy <ahf@torproject.org> | 2017-02-27 15:57:08 +0100 |
---|---|---|
committer | Alexander Færøy <ahf@torproject.org> | 2017-03-01 21:26:27 +0100 |
commit | ae91e64fa846d2861a6627fbd018665840fd7dd7 (patch) | |
tree | 97d416690eb86777c73dfca922be57e5be05fdb8 /src | |
parent | 3dca5a6e71929f88c9c76f6ebbaac58789884b6e (diff) | |
download | tor-ae91e64fa846d2861a6627fbd018665840fd7dd7.tar.gz tor-ae91e64fa846d2861a6627fbd018665840fd7dd7.zip |
Reset `buf` after each succesful test to avoid artifacts.
This patch resets `buf` in test_util_fgets_eagain() after each succesful
ivocation to avoid stray artifacts left in the buffer by erroneous
tor_fgets() calls.
Diffstat (limited to 'src')
-rw-r--r-- | src/test/test_util.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index 7a6991650d..3e4d45d35b 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -3986,6 +3986,7 @@ test_util_fgets_eagain(void *ptr) tt_ptr_op(retptr, OP_EQ, buf); tt_str_op(buf, OP_EQ, "B\n"); errno = 0; + memset(buf, '\0', sizeof(buf)); /* Send in a full line */ retlen = write(test_pipe[1], "CD\n", 3); @@ -3995,6 +3996,7 @@ test_util_fgets_eagain(void *ptr) tt_ptr_op(retptr, OP_EQ, buf); tt_str_op(buf, OP_EQ, "CD\n"); errno = 0; + memset(buf, '\0', sizeof(buf)); /* Send in a partial line */ retlen = write(test_pipe[1], "E", 1); @@ -4013,6 +4015,7 @@ test_util_fgets_eagain(void *ptr) tt_ptr_op(retptr, OP_EQ, buf); tt_str_op(buf, OP_EQ, "F\n"); errno = 0; + memset(buf, '\0', sizeof(buf)); /* Send in a full line and close */ retlen = write(test_pipe[1], "GH", 2); @@ -4036,6 +4039,7 @@ test_util_fgets_eagain(void *ptr) /* Check that buf is unchanged according to C99 and C11 */ tt_str_op(buf, OP_EQ, "GH"); + memset(buf, '\0', sizeof(buf)); done: if (test_stream != NULL) |