From: Dan Carpenter Date: Fri, 11 Aug 2017 00:26:39 +0000 (-0400) Subject: LU-9863 lmv: Off by two in lmv_fid2path() X-Git-Tag: 2.10.53~63 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=3f86915bdfe506ac9070f091b5a1c52ed134f5d2;p=fs%2Flustre-release.git 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 --- 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;