[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/release-0.2.4] Fix unit test for format_helper_exit_status



commit 004a9c6dd11ba71f310b750f00d5ed403faceb5a
Author: Nick Mathewson <nickm@xxxxxxxxxxxxxx>
Date:   Thu Oct 10 11:15:35 2013 -0400

    Fix unit test for format_helper_exit_status
    
    Fix format_helper_exit_status to allow full HEX_ERRNO_SIZE answers,
    *and* increase the buffer length again.
---
 src/common/util.c    |    4 ++--
 src/test/test_util.c |    1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/src/common/util.c b/src/common/util.c
index 5b0dbcd..b16afa1 100644
--- a/src/common/util.c
+++ b/src/common/util.c
@@ -3294,7 +3294,7 @@ format_helper_exit_status(unsigned char child_state, int saved_errno,
    * Count how many chars of space we have left, and keep a pointer into the
    * current point in the buffer.
    */
-  left = HEX_ERRNO_SIZE;
+  left = HEX_ERRNO_SIZE+1;
   cur = hex_errno;
 
   /* Emit child_state */
@@ -3594,7 +3594,7 @@ tor_spawn_background(const char *const filename, const char **argv,
      this is used for printing out the error message */
   unsigned char child_state = CHILD_STATE_INIT;
 
-  char hex_errno[HEX_ERRNO_SIZE + 1];
+  char hex_errno[HEX_ERRNO_SIZE + 2]; /* + 1 should be sufficient actually */
 
   static int max_fd = -1;
 
diff --git a/src/test/test_util.c b/src/test/test_util.c
index 4f9eb73..6c72247 100644
--- a/src/test/test_util.c
+++ b/src/test/test_util.c
@@ -2169,6 +2169,7 @@ test_util_exit_status(void *ptr)
   n = format_helper_exit_status(0xFF, -0x80000000, hex_errno);
   test_streq("FF/-80000000\n", hex_errno);
   test_eq(n, strlen(hex_errno));
+  test_eq(n, HEX_ERRNO_SIZE);
 
   clear_hex_errno(hex_errno);
   n = format_helper_exit_status(0x7F, 0, hex_errno);



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits