summaryrefslogtreecommitdiff
path: root/src/or/routerparse.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2013-03-15 13:49:04 -0400
committerNick Mathewson <nickm@torproject.org>2013-04-17 10:45:27 -0400
commit0cf2c01dbd9b86d396a55186e0656db33c7929d8 (patch)
tree8d3f3d54ba3ec81505642d72f7b9badf57eff79e /src/or/routerparse.c
parentacd72d4e3e47c2d81d9f3586d227069b9c87094e (diff)
downloadtor-0cf2c01dbd9b86d396a55186e0656db33c7929d8.tar.gz
tor-0cf2c01dbd9b86d396a55186e0656db33c7929d8.zip
Reject most directory documents with an internal NUL.
(Specifically, we reject all the ones that aren't NUL-terminated, since a NUL-terminated thing can't have a NUL in the middle.) Another fix for #8037.
Diffstat (limited to 'src/or/routerparse.c')
-rw-r--r--src/or/routerparse.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/or/routerparse.c b/src/or/routerparse.c
index 23dae382fc..2c345ae113 100644
--- a/src/or/routerparse.c
+++ b/src/or/routerparse.c
@@ -3902,8 +3902,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;