Whamcloud - gitweb
LU-9863 lmv: Off by two in lmv_fid2path() 77/28477/2
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 11 Aug 2017 00:26:39 +0000 (20:26 -0400)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 28 Aug 2017 06:25:44 +0000 (06:25 +0000)
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 <dan.carpenter@oracle.com>
Signed-off-by: James Simmons <uja.ornl@yahoo.com>
Reviewed-on: https://review.whamcloud.com/28477
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Frank Zago <fzago@cray.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lmv/lmv_obd.c

index 68ed668..904a7e0 100644 (file)
@@ -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;