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 <[email protected]>
---
 init.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/init.c b/init.c
index 05c73ef..6c48d3a 100644
--- 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"))
-- 
1.8.5.3

--
To unsubscribe from this list: send the line "unsubscribe fio" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to