aboutsummaryrefslogtreecommitdiff
path: root/src/or/routerparse.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-01-26 18:01:06 -0500
committerNick Mathewson <nickm@torproject.org>2013-01-26 18:01:06 -0500
commitacd72d4e3e47c2d81d9f3586d227069b9c87094e (patch)
tree67671109ff5e30cb0f539ab28ae6e9e5e07cc7f4 /src/or/routerparse.c
parentdfbd19df418347d833df650e68367c96a3aa37ad (diff)
downloadtor-acd72d4e3e47c2d81d9f3586d227069b9c87094e.tar.gz
tor-acd72d4e3e47c2d81d9f3586d227069b9c87094e.zip
Correctly copy microdescs/extrinfos with internal NUL bytes
Fixes bug 8037; bugfix on 0.2.0.1-alpha; reported by cypherpunks.
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r--src/or/routerparse.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index b945ea6aa6..23dae382fc 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -1494,7 +1494,7 @@ extrainfo_parse_entry_from_string(const char *s, const char *end,
extrainfo = tor_malloc_zero(sizeof(extrainfo_t));
extrainfo->cache_info.is_extrainfo = 1;
if (cache_copy)
- extrainfo->cache_info.signed_descriptor_body = tor_strndup(s, end-s);
+ extrainfo->cache_info.signed_descriptor_body = tor_memdup_nulterm(s, end-s);
extrainfo->cache_info.signed_descriptor_len = end-s;
memcpy(extrainfo->cache_info.signed_descriptor_digest, digest, DIGEST_LEN);
@@ -4237,7 +4237,7 @@ microdescs_parse_from_string(const char *s, const char *eos,
md->bodylen = start_of_next_microdesc - cp;
if (copy_body)
- md->body = tor_strndup(cp, md->bodylen);
+ md->body = tor_memdup_nulterm(cp, md->bodylen);
else
md->body = (char*)cp;
md->off = cp - start;