summaryrefslogtreecommitdiff
path: root/src/common/compat.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2016-02-16 11:34:06 -0500
committerNick Mathewson <nickm@torproject.org>2016-02-16 11:34:06 -0500
commit5cd6c577df3b3f59a8380b03e45d437aa593d326 (patch)
tree1940f5c05a6abec7f024c15c6f7ceb51e9c85986 /src/common/compat.c
parent1f679d4ae11cd976f5539bc4ddf36873132aeb00 (diff)
parent75daeb5c6d9dd549b92f20edbd795c85e451cbcd (diff)
downloadtor-5cd6c577df3b3f59a8380b03e45d437aa593d326.tar.gz
tor-5cd6c577df3b3f59a8380b03e45d437aa593d326.zip
Merge branch 'bug17852_revised'
Diffstat (limited to 'src/common/compat.c')
-rw-r--r--src/common/compat.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/common/compat.c b/src/common/compat.c
index fb22e922ba..87f56644cb 100644
--- a/src/common/compat.c
+++ b/src/common/compat.c
@@ -576,14 +576,17 @@ tor_vasprintf(char **strp, const char *fmt, va_list args)
int len, r;
va_list tmp_args;
va_copy(tmp_args, args);
- len = vsnprintf(buf, sizeof(buf), fmt, tmp_args);
+ /* vsnprintf() was properly checked but tor_vsnprintf() available so
+ * why not use it? */
+ len = tor_vsnprintf(buf, sizeof(buf), fmt, tmp_args);
va_end(tmp_args);
if (len < (int)sizeof(buf)) {
*strp = tor_strdup(buf);
return len;
}
strp_tmp = tor_malloc(len+1);
- r = vsnprintf(strp_tmp, len+1, fmt, args);
+ /* use of tor_vsnprintf() will ensure string is null terminated */
+ r = tor_vsnprintf(strp_tmp, len+1, fmt, args);
if (r != len) {
tor_free(strp_tmp);
*strp = NULL;