init: log error on missing --output-format argument
authorStefan Hajnoczi <stefanha@redhat.com>
Tue, 4 Feb 2014 13:27:11 +0000 (14:27 +0100)
committerJens Axboe <axboe@fb.com>
Wed, 5 Feb 2014 17:10:57 +0000 (10:10 -0700)
strcmp(optarg, "foo") will crash if --output-format was given without an
argument.  Log an error and exit properly instead of crashing.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
init.c

diff --git a/init.c b/init.c
index 05c73ef84f827963fca281ce00fbd7623a02c06a..6c48d3ad8a9cd278b9dbf911a2436192f28a61aa 100644 (file)
--- a/init.c
+++ b/init.c
@@ -1652,6 +1652,12 @@ int parse_cmd_line(int argc, char *argv[], int client_type)
                        output_format = FIO_OUTPUT_TERSE;
                        break;
                case 'F':
+                       if (!optarg) {
+                               log_err("fio: missing --output-format argument\n");
+                               exit_val = 1;
+                               do_exit++;
+                               break;
+                       }
                        if (!strcmp(optarg, "minimal") ||
                            !strcmp(optarg, "terse") ||
                            !strcmp(optarg, "csv"))