Whamcloud - gitweb
LU-9289 nodemap: fix fileset string length issue 35/26335/7
authorSebastien Buisson <sbuisson@ddn.com>
Tue, 4 Apr 2017 09:51:00 +0000 (18:51 +0900)
committerOleg Drokin <oleg.drokin@intel.com>
Sat, 3 Jun 2017 03:57:08 +0000 (03:57 +0000)
In nodemap_fileset_seq_write(), it is necessary to allocate count+1
for nm_fileset in order to have a '0' at the end of the string got
with copy_from_user().

Signed-off-by: Sebastien Buisson <sbuisson@ddn.com>
Change-Id: Id170e51648a8483c8d343d9f99f115bc04f798b3
Reviewed-on: https://review.whamcloud.com/26335
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Emoly Liu <emoly.liu@intel.com>
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/ptlrpc/nodemap_lproc.c

index c384785..6da0fd3 100644 (file)
@@ -220,7 +220,8 @@ nodemap_fileset_seq_write(struct file *file,
        if (count > PATH_MAX)
                RETURN(-EINVAL);
 
        if (count > PATH_MAX)
                RETURN(-EINVAL);
 
-       OBD_ALLOC(nm_fileset, count);
+       OBD_ALLOC(nm_fileset, count + 1);
+       /* OBD_ALLOC zero-fills the buffer */
        if (nm_fileset == NULL)
                RETURN(-ENOMEM);
 
        if (nm_fileset == NULL)
                RETURN(-ENOMEM);
 
@@ -233,7 +234,7 @@ nodemap_fileset_seq_write(struct file *file,
 
        rc = count;
 out:
 
        rc = count;
 out:
-       OBD_FREE(nm_fileset, count);
+       OBD_FREE(nm_fileset, count + 1);
 
        return rc;
 }
 
        return rc;
 }