From 712f7d5e4093870fff650fb296d2425cb405a4c2 Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Sat, 3 Nov 2018 14:28:56 +0100 Subject: [PATCH] fluke-45: avoid NULL dereference in the probe routine The Fluke 45 probe routine tries to detect whether the serial port is "in echo mode" (which already is questionable before the IDN query). In the absence of a response, the library segfaults. Fix it. --- src/hardware/fluke-45/api.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/hardware/fluke-45/api.c b/src/hardware/fluke-45/api.c index e15adaad..164cd5f9 100644 --- a/src/hardware/fluke-45/api.c +++ b/src/hardware/fluke-45/api.c @@ -68,8 +68,9 @@ static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) sdi->conn = scpi; /* Test for serial port ECHO enabled. */ + response = NULL; sr_scpi_get_string(scpi, "ECHO-TEST", &response); - if (strcmp(response, "ECHO-TEST") == 0) { + if (response && strcmp(response, "ECHO-TEST") == 0) { sr_err("Serial port ECHO is ON. Please turn it OFF!"); return NULL; }