Whamcloud - gitweb
LU-6406 tests: fix undersized fsname and FID strings 13/14213/5
authorFrank Zago <fzago@cray.com>
Thu, 26 Mar 2015 23:42:25 +0000 (18:42 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Mon, 11 May 2015 11:30:27 +0000 (11:30 +0000)
A Lustre filesystem name is up to 8 characters, plus 1 for the NUL
terminator. If a filesystem name is 8 characters, then the
llapi_layout_test, llapi_hsm_test, group_lock_test and llapi_fid_test
may have their stack scribbled or overran when they call
llapi_search_mounts(). Add one extra byte for the NUL character.

Same issue with a FID string, which also needs an extra character for
NUL termination.

Signed-off-by: frank zago <fzago@cray.com>
Change-Id: Ic7757ebce051e12f4723e27b5b00d4db1637b384
Reviewed-on: http://review.whamcloud.com/14213
Tested-by: Jenkins
Reviewed-by: Dmitry Eremin <dmitry.eremin@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Reviewed-by: Oleg Drokin <oleg.drokin@intel.com>
lustre/lod/lod_object.c
lustre/tests/llapi_fid_test.c
lustre/tests/llapi_hsm_test.c
lustre/tests/llapi_layout_test.c

index 2ba89c2..a87c4e8 100644 (file)
@@ -853,7 +853,8 @@ int lod_load_lmv_shards(const struct lu_env *env, struct lod_object *lo,
                                goto next;
                }
 
                                goto next;
                }
 
-               len = snprintf(name, FID_LEN + 1, DFID":", PFID(&ent->lde_fid));
+               len = snprintf(name, sizeof(name),
+                              DFID":", PFID(&ent->lde_fid));
                /* The ent->lde_name is composed of ${FID}:${index} */
                if (ent->lde_namelen < len + 1 ||
                    memcmp(ent->lde_name, name, len) != 0) {
                /* The ent->lde_name is composed of ${FID}:${index} */
                if (ent->lde_namelen < len + 1 ||
                    memcmp(ent->lde_name, name, len) != 0) {
index e7d18f9..e8433a1 100644 (file)
@@ -105,7 +105,7 @@ static void helper_fid2path(const char *filename, int fd)
        lustre_fid fid;
        lustre_fid fid2;
        lustre_fid fid3;
        lustre_fid fid;
        lustre_fid fid2;
        lustre_fid fid3;
-       char fidstr[FID_LEN];
+       char fidstr[FID_LEN + 1];
        char path1[PATH_MAX];
        char path2[PATH_MAX];
        char path3[PATH_MAX];
        char path1[PATH_MAX];
        char path2[PATH_MAX];
        char path3[PATH_MAX];
@@ -241,7 +241,7 @@ static void test11(void)
        int rc;
        int fd;
        lustre_fid fid;
        int rc;
        int fd;
        lustre_fid fid;
-       char fidstr[FID_LEN];
+       char fidstr[FID_LEN + 1];
        char path[PATH_MAX];
        long long recno;
        int linkno;
        char path[PATH_MAX];
        long long recno;
        int linkno;
@@ -371,7 +371,7 @@ static void test30(void)
        char buf[PATH_MAX];
        char buf2[PATH_MAX];
        lustre_fid fid;
        char buf[PATH_MAX];
        char buf2[PATH_MAX];
        lustre_fid fid;
-       char fidstr[FID_LEN];
+       char fidstr[FID_LEN + 1];
        int rc;
        int i;
        int j;
        int rc;
        int i;
        int j;
@@ -698,7 +698,7 @@ static void process_args(int argc, char *argv[])
 
 int main(int argc, char *argv[])
 {
 
 int main(int argc, char *argv[])
 {
-       char fsname[8];
+       char fsname[8 + 1];
        int rc;
 
        process_args(argc, argv);
        int rc;
 
        process_args(argc, argv);
index 54c3495..7c47654 100644 (file)
@@ -1024,7 +1024,7 @@ static void process_args(int argc, char *argv[])
 
 int main(int argc, char *argv[])
 {
 
 int main(int argc, char *argv[])
 {
-       char fsname[8];
+       char fsname[8 + 1];
        int rc;
 
        process_args(argc, argv);
        int rc;
 
        process_args(argc, argv);
index 12109f1..53b20b7 100644 (file)
@@ -1313,7 +1313,7 @@ int main(int argc, char *argv[])
        int rc = 0;
        int i;
        struct stat s;
        int rc = 0;
        int i;
        struct stat s;
-       char fsname[8];
+       char fsname[8 + 1];
 
        llapi_msg_set_level(LLAPI_MSG_OFF);
 
 
        llapi_msg_set_level(LLAPI_MSG_OFF);