Whamcloud - gitweb
LU-4629 lov: fix sscanf format specification 91/9391/4
authorDmitry Eremin <dmitry.eremin@intel.com>
Tue, 25 Feb 2014 21:06:20 +0000 (01:06 +0400)
committerOleg Drokin <oleg.drokin@intel.com>
Tue, 6 May 2014 02:31:22 +0000 (02:31 +0000)
sscanf format specification '%d' expects type 'int *' for 'd',
but parameter 3 has a different type '__u32*'

Length of format string "o%.5d" is 11 but array 'oname' of size 10.

Signed-off-by: Dmitry Eremin <dmitry.eremin@intel.com>
Change-Id: I132ba4c4865cc12f831638edddb8d41e5fa2d273
Reviewed-on: http://review.whamcloud.com/9391
Tested-by: Jenkins
Reviewed-by: John L. Hammond <john.hammond@intel.com>
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
lustre/lov/lov_obd.c
lustre/utils/loadgen.c

index 46496c5..1b31a17 100644 (file)
@@ -978,7 +978,7 @@ int lov_process_config_base(struct obd_device *obd, struct lustre_cfg *lcfg,
 
                 obd_str2uuid(&obd_uuid,  lustre_cfg_buf(lcfg, 1));
 
-                if (sscanf(lustre_cfg_buf(lcfg, 2), "%d", indexp) != 1)
+               if (sscanf(lustre_cfg_buf(lcfg, 2), "%u", indexp) != 1)
                         GOTO(out, rc = -EINVAL);
                 if (sscanf(lustre_cfg_buf(lcfg, 3), "%d", genp) != 1)
                         GOTO(out, rc = -EINVAL);
index f467d4d..fbc145e 100644 (file)
@@ -670,21 +670,31 @@ static void report_perf()
 
 static void *run_one_child(void *threadvp)
 {
-        struct kid_t *kid;
-        char oname[10], ename[10];
-        int thread = (long)threadvp, dev = 0;
-        int rc = 0, err;
-
-        if (o_verbose > 2)
-                printf("%s: running thread #%d\n", cmdname, thread);
+       struct kid_t *kid;
+       char oname[16], ename[16];
+       int thread = (long)threadvp;
+       int dev = 0;
+       int err;
+       int rc;
 
-        sprintf(oname, "o%.5d", thread);
-        sprintf(ename, "e%.5d", thread);
+       if (o_verbose > 2)
+               printf("%s: running thread #%d\n", cmdname, thread);
+
+       rc = snprintf(oname, sizeof(oname), "o%.5d", thread);
+       if (rc != 1) {
+               rc = -EFAULT;
+               goto out_exit;
+       }
+       rc = snprintf(ename, sizeof(ename), "e%.5d", thread);
+       if (rc != 1) {
+               rc = -EFAULT;
+               goto out_exit;
+       }
         rc = echocli_setup(oname, ename, &dev);
         if (rc) {
                 fprintf(stderr, "%s: can't setup '%s/%s' (%d)\n",
                         cmdname, oname, ename, rc);
-                pthread_exit((void *)(long)rc);
+               goto out_exit;
         }
 
         kid = push_kid(thread);
@@ -736,7 +746,8 @@ out:
         err = cleanup(oname, 0);
         if (!rc) rc = err;
 
-        pthread_exit((void *)(long)rc);
+out_exit:
+       pthread_exit((void *)(long)rc);
 }
 
 /*