summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-03-21 11:52:53 +0000
committerNick Mathewson <nickm@torproject.org>2009-03-21 11:52:53 +0000
commit0fa01654b9553598fd3263cdec9849bd8ea2a4a8 (patch)
treede6914da06ca16151e208394e737ad75f4008f49
parent4962e466b2e72cdf78411e5ff426c5b5478d59f6 (diff)
downloadtor-0fa01654b9553598fd3263cdec9849bd8ea2a4a8.tar.gz
tor-0fa01654b9553598fd3263cdec9849bd8ea2a4a8.zip
fix from lark: make memarea_strndup() work even at the end of a mmap chunk. Bug was harmless for now, I think.
svn:r19094
-rw-r--r--ChangeLog4
-rw-r--r--src/common/memarea.c2
2 files changed, 5 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index d003e273d1..8fe9cb7589 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,10 @@ Changes in version 0.2.1.14-??? - 2009-03-??
0.2.0.33.
- Avoid double-free on list of successfully uploaded hidden
service discriptors. Fix for bug 948. Bugfix on 0.2.1.6-alpha.
+ - Change memarea_strndup() implementation to work even when
+ duplicating a string at the end of a page. This bug was
+ harmless for now, but could have meant crashes later. Fix by
+ lark. Bugfix on 0.2.1.1-alpha.
o Minor features (controller):
- Try harder to look up nicknames for routers on a circuit when
diff --git a/src/common/memarea.c b/src/common/memarea.c
index 65e36e3dd9..7eb54821b9 100644
--- a/src/common/memarea.c
+++ b/src/common/memarea.c
@@ -237,7 +237,7 @@ memarea_strndup(memarea_t *area, const char *s, size_t n)
size_t ln;
char *result;
const char *cp, *end = s+n;
- for (cp = s; *cp && cp < end; ++cp)
+ for (cp = s; cp < end && *cp; ++cp)
;
/* cp now points to s+n, or to the 0 in the string. */
ln = cp-s;