From: Dan Carpenter Date: Fri, 28 Jul 2017 14:42:27 +0000 (+0300) Subject: staging: lustre: lustre: Off by two in lmv_fid2path() X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=0c1b9970ddd4cc41002321c3877e7f91aacb896d;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git staging: lustre: lustre: 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 NUL. Signed-off-by: Dan Carpenter Reviewed-by: John L. Hammond Reviewed-by: frank zago Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/staging/lustre/lustre/lmv/lmv_obd.c b/drivers/staging/lustre/lustre/lmv/lmv_obd.c index 1c9ff2493423..84eaab8e867a 100644 --- a/drivers/staging/lustre/lustre/lmv/lmv_obd.c +++ b/drivers/staging/lustre/lustre/lmv/lmv_obd.c @@ -635,8 +635,8 @@ repeat_fid2path: char *ptr; ori_gf = karg; - if (strlen(ori_gf->gf_path) + - strlen(gf->gf_path) > ori_gf->gf_pathlen) { + if (strlen(ori_gf->gf_path) + 1 + + strlen(gf->gf_path) + 1 > ori_gf->gf_pathlen) { rc = -EOVERFLOW; goto out_fid2path; }