diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-10-10 10:55:58 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-10-10 10:55:58 -0400 |
commit | 97285bc46550ba135a2567d89351159da8db99f8 (patch) | |
tree | 9f219295d726b104ff32f50088260c677a72e08e /src | |
parent | 3b6c48328b03d7f0e639785fbdf268c0d973f16f (diff) | |
parent | 1137817319c7a9e4293e9901405d01e7b85da6ea (diff) | |
download | tor-97285bc46550ba135a2567d89351159da8db99f8.tar tor-97285bc46550ba135a2567d89351159da8db99f8.tar.gz |
Merge remote-tracking branch 'origin/maint-0.2.4'
Diffstat (limited to 'src')
-rw-r--r-- | src/common/util.c | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/common/util.c b/src/common/util.c index a45011fc4..51d135281 100644 --- a/src/common/util.c +++ b/src/common/util.c @@ -3448,10 +3448,10 @@ format_hex_number_sigsafe(unsigned int x, char *buf, int buf_len) * <b>hex_errno</b>. Called between fork and _exit, so must be signal-handler * safe. * - * <b>hex_errno</b> must have at least HEX_ERRNO_SIZE bytes available. + * <b>hex_errno</b> must have at least HEX_ERRNO_SIZE+1 bytes available. * * The format of <b>hex_errno</b> is: "CHILD_STATE/ERRNO\n", left-padded - * with spaces. Note that there is no trailing \0. CHILD_STATE indicates where + * with spaces. CHILD_STATE indicates where * in the processs of starting the child process did the failure occur (see * CHILD_STATE_* macros for definition), and SAVED_ERRNO is the value of * errno when the failure occurred. @@ -3529,8 +3529,8 @@ format_helper_exit_status(unsigned char child_state, int saved_errno, left -= written; cur += written; - /* Check that we have enough space left for a newline */ - if (left <= 0) + /* Check that we have enough space left for a newline and a NUL */ + if (left <= 1) goto err; /* Emit the newline and NUL */ @@ -3786,7 +3786,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]; + char hex_errno[HEX_ERRNO_SIZE + 1]; static int max_fd = -1; |