From 3508a2d237cee98eb5c890011b569a1820b57f5c Mon Sep 17 00:00:00 2001 From: Raghavendra G Date: Tue, 15 Sep 2009 08:07:30 +0000 Subject: libglusterfsclient: NULL terminate the vmp entry during vmp_entry_init. Signed-off-by: Anand V. Avati BUG: 263 (files are not resolved to glusterfs when vmp is not terminated with a '/'.) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=263 --- libglusterfsclient/src/libglusterfsclient.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'libglusterfsclient') diff --git a/libglusterfsclient/src/libglusterfsclient.c b/libglusterfsclient/src/libglusterfsclient.c index bba5877897e..8fb1441722a 100755 --- a/libglusterfsclient/src/libglusterfsclient.c +++ b/libglusterfsclient/src/libglusterfsclient.c @@ -1382,7 +1382,7 @@ libgf_init_vmpentry (char *vmp, glusterfs_handle_t *vmphandle) appendslash = 1; } - entry->vmp = CALLOC (vmplen, sizeof (char)); + entry->vmp = CALLOC (vmplen + 1, sizeof (char)); if (!entry->vmp) { gf_log (LIBGF_XL_NAME, GF_LOG_ERROR, "Memory allocation " "failed"); @@ -1390,8 +1390,11 @@ libgf_init_vmpentry (char *vmp, glusterfs_handle_t *vmphandle) } strcpy (entry->vmp, vmp); - if (appendslash) + if (appendslash) { entry->vmp[vmplen-1] = '/'; + entry->vmp[vmplen] = '\0'; + } + entry->vmplen = vmplen; entry->handle = vmphandle; INIT_LIST_HEAD (&entry->list); -- cgit