diff options
author | Nick Mathewson <nickm@torproject.org> | 2013-04-17 10:45:45 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2013-04-17 10:45:45 -0400 |
commit | 42731f69efc1f7b0614a33cd6ea7a70903bfc98b (patch) | |
tree | 3b5d5e5eedb704f116d26367546c002ebf02d0ca /src/or/routerparse.c | |
parent | a6545d6335cd7829cdc9c0d7ce2e61b775bcca1d (diff) | |
parent | 0cf2c01dbd9b86d396a55186e0656db33c7929d8 (diff) | |
download | tor-42731f69efc1f7b0614a33cd6ea7a70903bfc98b.tar.gz tor-42731f69efc1f7b0614a33cd6ea7a70903bfc98b.zip |
Merge branch 'bug8037_squashed' into maint-0.2.4
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r-- | src/or/routerparse.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 0eadcc90f7..370cf2682e 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); @@ -3921,8 +3921,15 @@ tokenize_string(memarea_t *area, tor_assert(area); s = &start; - if (!end) + if (!end) { end = start+strlen(start); + } else { + /* it's only meaningful to check for nuls if we got an end-of-string ptr */ + if (memchr(start, '\0', end-start)) { + log_warn(LD_DIR, "parse error: internal NUL character."); + return -1; + } + } for (i = 0; i < NIL_; ++i) counts[i] = 0; @@ -4256,7 +4263,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; |