summaryrefslogtreecommitdiff
path: root/src/or/control.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/or/control.c')
-rw-r--r--src/or/control.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/or/control.c b/src/or/control.c
index 36f0cffee2..9767d0e2e8 100644
--- a/src/or/control.c
+++ b/src/or/control.c
@@ -290,7 +290,7 @@ write_escaped_data(const char *data, size_t len, int translate_newlines,
int start_of_line;
for (i=0; i<(int)len; ++i) {
if (data[i]== '\n')
- ++sz_out;
+ sz_out += 2; /* Maybe add a CR; maybe add a dot. */
}
*out = outp = tor_malloc(sz_out+1);
end = data+len;
@@ -317,6 +317,8 @@ write_escaped_data(const char *data, size_t len, int translate_newlines,
*outp++ = '.';
*outp++ = '\r';
*outp++ = '\n';
+ *outp = '\0'; /* NUL-terminate just in case. */
+ tor_assert((outp - *out) <= (sz_out));
return outp - *out;
}