From 73f36e452580ef9be36d3d89985c25e0d33e4a2d Mon Sep 17 00:00:00 2001 From: Brian Aker Date: Fri, 21 Dec 2007 17:26:25 -0800 Subject: [PATCH 1/1] Fixed a bug Cal found on null termination of a result for memcached_fetch() --- ChangeLog | 2 ++ configure.ac | 2 +- lib/memcached_string.c | 3 ++- 3 files changed, 5 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 68671ae4..a8e87a7d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -8,6 +8,8 @@ * If memcached_server_list_append is passed NULLs instead of pointers it returns NULL. * Added memcached_fetch_execute() method + * Found a bug where memcached_fetch() was not null terminating the result + value. 0.12 Tue Dec 11 15:20:55 PST 2007 * Updates for consistent hashing diff --git a/configure.ac b/configure.ac index f052f5f0..0cf13db9 100644 --- a/configure.ac +++ b/configure.ac @@ -7,7 +7,7 @@ MEMCACHED_LIBRARY_NAME=libmemcached #release versioning MEMCACHED_MAJOR_VERSION=0 -MEMCACHED_MINOR_VERSION=12 +MEMCACHED_MINOR_VERSION=13 MEMCACHED_MICRO_VERSION=0 #API version diff --git a/lib/memcached_string.c b/lib/memcached_string.c index 300f10f2..247fbe47 100644 --- a/lib/memcached_string.c +++ b/lib/memcached_string.c @@ -129,11 +129,12 @@ char *memcached_string_c_copy(memcached_string_st *string) WATCHPOINT_ASSERT(string->is_allocated != MEMCACHED_USED); - c_ptr= (char *)malloc(memcached_string_length(string) * sizeof(char)); + c_ptr= (char *)malloc((memcached_string_length(string)+1) * sizeof(char)); if (!c_ptr) return NULL; memcpy(c_ptr, memcached_string_value(string), memcached_string_length(string)); + c_ptr[memcached_string_length(string)]= 0; return c_ptr; } -- 2.30.2