From e6c461abe5fd63baa25007e1880d0f04f3ae01bb Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Thu, 31 May 2012 11:29:29 +0200 Subject: glusterd: avoid buffer overrun due to lack of NUL terminator Assume that this use of strncpy is not spurious (i.e., that it does sometimes truncate), and ensure that the result is NUL-terminated. Otherwise, callers that treat ->filepath as a NUL-terminated string could operate on a bogus file name and/or segfault. Change-Id: I276bf8a4da330284cc0300e8da7113a48b9b9b37 BUG: 789278 Signed-off-by: Jim Meyering Reviewed-on: http://review.gluster.com/3590 Tested-by: Gluster Build System Reviewed-by: Anand Avati --- xlators/mgmt/glusterd/src/glusterd-store.c | 1 + 1 file changed, 1 insertion(+) (limited to 'xlators') diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c index 173cf2441..b9177b3c0 100644 --- a/xlators/mgmt/glusterd/src/glusterd-store.c +++ b/xlators/mgmt/glusterd/src/glusterd-store.c @@ -1492,6 +1492,7 @@ glusterd_store_iter_new (glusterd_store_handle_t *shandle, } strncpy (tmp_iter->filepath, shandle->path, sizeof (tmp_iter->filepath)); + tmp_iter->filepath[sizeof (tmp_iter->filepath) - 1] = 0; *iter = tmp_iter; ret = 0; -- cgit