From 53d5b14f0dd4fda046bb1d0ce578a1849cec59db Mon Sep 17 00:00:00 2001 From: Dmitry Eremin Date: Wed, 26 Feb 2014 01:06:20 +0400 Subject: [PATCH] LU-4629 lov: fix sscanf format specification 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 Change-Id: I132ba4c4865cc12f831638edddb8d41e5fa2d273 Reviewed-on: http://review.whamcloud.com/9391 Tested-by: Jenkins Reviewed-by: John L. Hammond Tested-by: Maloo Reviewed-by: Andreas Dilger --- lustre/lov/lov_obd.c | 2 +- lustre/utils/loadgen.c | 33 ++++++++++++++++++++++----------- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/lustre/lov/lov_obd.c b/lustre/lov/lov_obd.c index 46496c5..1b31a17 100644 --- a/lustre/lov/lov_obd.c +++ b/lustre/lov/lov_obd.c @@ -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); diff --git a/lustre/utils/loadgen.c b/lustre/utils/loadgen.c index f467d4d..fbc145e 100644 --- a/lustre/utils/loadgen.c +++ b/lustre/utils/loadgen.c @@ -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); } /* -- 1.8.3.1