[PATCH 2/2] init: log error on missing --output-format argument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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 majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel]     [Linux SCSI]     [Linux IDE]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux SCSI]

  Powered by Linux