From 3f86915bdfe506ac9070f091b5a1c52ed134f5d2 Mon Sep 17 00:00:00 2001 From: Dan Carpenter Date: Thu, 10 Aug 2017 20:26:39 -0400 Subject: [PATCH] LU-9863 lmv: Off by two in lmv_fid2path() We want to concatonate join string one, a '/' character, string two and then a NUL terminator. The destination buffer holds ori_gf->gf_pathlen characters. The strlen() function returns the number of characters not counting the NUL terminator. So we should be adding two extra spaces, one for the foward slash and one for the NULL. Change-Id: Ia96461a2d1b3331f44d3791ca0148f6e836caf0d Signed-off-by: Dan Carpenter Signed-off-by: James Simmons Reviewed-on: https://review.whamcloud.com/28477 Tested-by: Jenkins Tested-by: Maloo Reviewed-by: John L. Hammond Reviewed-by: Frank Zago Reviewed-by: Oleg Drokin --- lustre/lmv/lmv_obd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lustre/lmv/lmv_obd.c b/lustre/lmv/lmv_obd.c index 68ed668..904a7e0 100644 --- a/lustre/lmv/lmv_obd.c +++ b/lustre/lmv/lmv_obd.c @@ -683,8 +683,8 @@ repeat_fid2path: char *ptr; ori_gf = (struct getinfo_fid2path *)karg; - if (strlen(ori_gf->gf_u.gf_path) + - strlen(gf->gf_u.gf_path) > ori_gf->gf_pathlen) + if (strlen(ori_gf->gf_u.gf_path) + 1 + + strlen(gf->gf_u.gf_path) + 1 > ori_gf->gf_pathlen) GOTO(out_fid2path, rc = -EOVERFLOW); ptr = ori_gf->gf_u.gf_path; -- 1.8.3.1