aboutsummaryrefslogtreecommitdiff
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/log.c10
-rw-r--r--src/common/tortls.c2
2 files changed, 7 insertions, 5 deletions
diff --git a/src/common/log.c b/src/common/log.c
index 0f75237c6..0b8a0bb38 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -54,17 +54,19 @@ static INLINE void format_msg(char *buf, size_t buf_len,
".%.3ld [%s] ",
(long)now.tv_usec / 1000, sev_to_string(severity));
if(n > buf_len)
- n = buf_len; /* the *nprintf funcs return how many bytes they
- * _would_ print, if the output is truncated */
+ n = buf_len-1; /* the *nprintf funcs return how many bytes they
+ * _would_ print, if the output is truncated.
+ * Subtract one because the count doesn't include the \0 */
+
if (funcname) {
n += snprintf(buf+n, buf_len-n, "%s(): ", funcname);
if(n > buf_len)
- n = buf_len;
+ n = buf_len-1;
}
n += vsnprintf(buf+n,buf_len-n,format,ap);
if(n > buf_len)
- n = buf_len;
+ n = buf_len-1;
buf[n]='\n';
buf[n+1]='\0';
}
diff --git a/src/common/tortls.c b/src/common/tortls.c
index a1d5b2c5e..1046b4981 100644
--- a/src/common/tortls.c
+++ b/src/common/tortls.c
@@ -215,7 +215,7 @@ tor_tls_context_new(crypto_pk_env_t *rsa,
cert = tor_tls_create_certificate(rsa, nickname);
if (!cert) {
log(LOG_ERR, "Error creating certificate");
- return NULL;
+ return -1;
}
}