summaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorJens Axboe <axboe@fb.com>2014-04-03 08:18:07 -0600
committerJens Axboe <axboe@fb.com>2014-04-03 08:18:07 -0600
commitf75c69a1e26166b5c205c6d4c0a6a9412ee6cd86 (patch)
treef506f076c5a283863ef638e582d8e23282551d5a /parse.c
parent2e80228232afc9cf90ad06b360a33a05637978f3 (diff)
downloadfio-f75c69a1e26166b5c205c6d4c0a6a9412ee6cd86.tar.gz
fio-f75c69a1e26166b5c205c6d4c0a6a9412ee6cd86.tar.bz2
parse: fix crash with empty FIO_OPT_STR_STORE variables
Sébastien reports: A crash on solaris & windows (at least) when using fio-2.1.6.1 : A simple profile that use a env variable : directory=${DIRECTORY} I'm starting fio without defining DIRECTORY and I'm getting a crash: The stack on solaris is : core 'core' of 4574: ./fio ../fio_env.win 0000000100035348 set_name_idx (ffffffff7fffe970, 100231950, 0, 16c4e8, 0, 1002319b0) + cc 0000000100021a70 add_file (ffffffff7b400000, ffffffff7fffee60, 0, 0, 100071c30, ffffffff7fffe970) + 38 000000010000daf4 add_job.part.4 (7, 100236050, 0, ffffffff7ffff268, 1, 0) + 11f0 000000010000f444 parse_jobs_ini (0, 0, 0, 1, 100236050, 1002276c0) + 77c 0000000100010db0 parse_options (5118, ffffffff7ffff968, 1, 0, 0, 10021eef0) + 304 000000010006ff68 main (2, ffffffff7ffff968, ffffffff7ffff980, 100228338, 100000000, 2800) + 20 000000010000952c _start (0, 0, 0, 0, 0, 0) + 7c Same thing happens with filename and other store options. Fix this by checking in the parser whether the string is empty or not. Reported-by: Sébastien Bouchex Bellomié <sbouchex@infovista.com> Signed-off-by: Jens Axboe <axboe@fb.com>
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/parse.c b/parse.c
index 079f19e3..83c59f70 100644
--- a/parse.c
+++ b/parse.c
@@ -608,6 +608,9 @@ static int __handle_option(struct fio_option *o, const char *ptr, void *data,
case FIO_OPT_STR_STORE: {
fio_opt_str_fn *fn = o->cb;
+ if (!strlen(ptr))
+ return 1;
+
if (o->off1) {
cp = td_var(data, o, o->off1);
*cp = strdup(ptr);