From: Nick Mathewson Date: Sat, 21 Mar 2009 16:01:52 +0000 (+0000) Subject: Actually do that memarea_strndup fix right. Not only must you not examine unmapped... X-Git-Tag: tor-0.2.1.14-rc~29 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=be9d72303ecd594574d42faeacb293ba0ce2420b;p=thirdparty%2Ftor.git Actually do that memarea_strndup fix right. Not only must you not examine unmapped ram, but you also must not copy it. From lark. svn:r19095 --- diff --git a/src/common/memarea.c b/src/common/memarea.c index 7eb54821b9..6e0bda0c8a 100644 --- a/src/common/memarea.c +++ b/src/common/memarea.c @@ -241,7 +241,8 @@ memarea_strndup(memarea_t *area, const char *s, size_t n) ; /* cp now points to s+n, or to the 0 in the string. */ ln = cp-s; - result = memarea_memdup(area, s, ln+1); + result = memarea_alloc(area, ln+1); + memcpy(result, s, ln); result[ln]='\0'; return result; }