diff options
author | Nick Mathewson <nickm@torproject.org> | 2012-06-23 15:30:01 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2012-06-23 15:32:04 -0400 |
commit | b1ad1a1d0266a20bb0dac15e65abe7b65a74e8a0 (patch) | |
tree | f8199dbd96fcd0e613abcfc19bb54d46819e4ad9 /src/test | |
parent | d0243e82cfcdf6684283c37f20db2d999740bdf3 (diff) | |
download | tor-b1ad1a1d0266a20bb0dac15e65abe7b65a74e8a0.tar tor-b1ad1a1d0266a20bb0dac15e65abe7b65a74e8a0.tar.gz |
Resolve crash caused by format_helper_exit_status changes in #5557
Because the string output was no longer equal in length to
HEX_ERRNO_SIZE, the write() call would add some extra spaces and
maybe a NUL, and the NUL would trigger an assert in
get_string_from_pipe.
Fixes bug 6225; bug not in any released version of Tor.
Diffstat (limited to 'src/test')
-rw-r--r-- | src/test/test_util.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/test/test_util.c b/src/test/test_util.c index d71d280fa..fab95953b 100644 --- a/src/test/test_util.c +++ b/src/test/test_util.c @@ -2138,28 +2138,34 @@ test_util_exit_status(void *ptr) { /* Leave an extra byte for a \0 so we can do string comparison */ char hex_errno[HEX_ERRNO_SIZE + 1]; + int n; (void)ptr; clear_hex_errno(hex_errno); - format_helper_exit_status(0, 0, hex_errno); + n = format_helper_exit_status(0, 0, hex_errno); test_streq("0/0\n", hex_errno); + test_eq(n, strlen(hex_errno)); clear_hex_errno(hex_errno); - format_helper_exit_status(0, 0x7FFFFFFF, hex_errno); + n = format_helper_exit_status(0, 0x7FFFFFFF, hex_errno); test_streq("0/7FFFFFFF\n", hex_errno); + test_eq(n, strlen(hex_errno)); clear_hex_errno(hex_errno); - format_helper_exit_status(0xFF, -0x80000000, hex_errno); + n = format_helper_exit_status(0xFF, -0x80000000, hex_errno); test_streq("FF/-80000000\n", hex_errno); + test_eq(n, strlen(hex_errno)); clear_hex_errno(hex_errno); - format_helper_exit_status(0x7F, 0, hex_errno); + n = format_helper_exit_status(0x7F, 0, hex_errno); test_streq("7F/0\n", hex_errno); + test_eq(n, strlen(hex_errno)); clear_hex_errno(hex_errno); - format_helper_exit_status(0x08, -0x242, hex_errno); + n = format_helper_exit_status(0x08, -0x242, hex_errno); test_streq("8/-242\n", hex_errno); + test_eq(n, strlen(hex_errno)); done: ; |