summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Meyering <meyering@redhat.com>2012-05-31 11:29:29 +0200
committerAnand Avati <avati@redhat.com>2012-07-02 15:32:04 -0700
commite6c461abe5fd63baa25007e1880d0f04f3ae01bb (patch)
treee090525c39c4723fb75775bd3b40f47f0a6c0ccc
parent64a2627cc1cfb8cc547c160c2362d05401b8ed87 (diff)
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 <meyering@redhat.com> Reviewed-on: http://review.gluster.com/3590 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-store.c b/xlators/mgmt/glusterd/src/glusterd-store.c
index 173cf244146..b9177b3c089 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;