staging: lustre: lustre: Off by two in lmv_fid2path()
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 28 Jul 2017 14:42:27 +0000 (17:42 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 20 Aug 2017 18:08:41 +0000 (11:08 -0700)
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 <dan.carpenter@oracle.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: frank zago <fzago@cray.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/staging/lustre/lustre/lmv/lmv_obd.c

index 1c9ff2493423feec1c51b8ccd69546a907ec47e7..84eaab8e867ab79eda1523045816e36da0cb82a3 100644 (file)
@@ -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;
                }