From 3419e7446e55f77932eaab350414963e34d7b64c Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sat, 26 May 2007 00:07:48 +0000 Subject: [PATCH] r12986@catbus: nickm | 2007-05-25 20:07:08 -0400 Try even harder not to dereference the first character after an mmap(). [Bug reported by lodger] svn:r10346 --- ChangeLog | 2 ++ src/or/routerparse.c | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/ChangeLog b/ChangeLog index f6a3db1112..6cea4e7e47 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,8 @@ Changes in version 0.1.2.15 - 2007-0?-?? o Fixes: - Fix compile on FreeBSD/NetBSD/OpenBSD. Oops. + - Try even harder not to dereference the first character after + an mmap(). (Bug reported by lodger) Changes in version 0.1.2.14 - 2007-05-25 diff --git a/src/or/routerparse.c b/src/or/routerparse.c index 6c77eb688e..9fb33a3a56 100644 --- a/src/or/routerparse.c +++ b/src/or/routerparse.c @@ -676,6 +676,11 @@ router_parse_list_from_string(const char **s, const char *eos, cp = end = eos; } + /* Start by backing up a character. If we were at eos, we'll now point + * to a valid character. If we were at a \nrouter or \ndirectory-signature, + * we'll back up to before the \n. */ + --cp; + while (cp > *s && (!*cp || TOR_ISSPACE(*cp))) --cp; /* cp now points to the last non-space character in this descriptor. */