diff mbox series

[ibsim,12/23] sim_cmd.c: sim_cmd_file should check the char pointer before dereferening

Message ID 20190102131318.5765-12-honli@redhat.com (mailing list archive)
State Not Applicable
Headers show
Series [ibsim,01/23] move sim_cmd_file into ibsim/sim_cmd.c | expand

Commit Message

Honggang LI Jan. 2, 2019, 1:13 p.m. UTC
Signed-off-by: Honggang Li <honli@redhat.com>
---
 ibsim/sim_cmd.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Comments

Hal Rosenstock Jan. 4, 2019, 12:24 p.m. UTC | #1
On 1/2/2019 8:13 AM, Honggang Li wrote:
> Signed-off-by: Honggang Li <honli@redhat.com>

Thanks. Applied.

-- Hal
diff mbox series

Patch

diff --git a/ibsim/sim_cmd.c b/ibsim/sim_cmd.c
index 1d36c600814f..0a94c68bdf21 100644
--- a/ibsim/sim_cmd.c
+++ b/ibsim/sim_cmd.c
@@ -1149,11 +1149,16 @@  int sim_cmd_file(FILE * f, char *s)
 	FILE *cmd_file;
 	char *p;
 
+	if (!s) {
+		fprintf(f, "do_cmd_from_file: no file name - skip\n");
+		return -1;
+	}
+
 	s++;
 	while (isspace(*s))
 		s++;
 
-	if (!s || !*s) {
+	if (!*s) {
 		fprintf(f, "do_cmd_from_file: no file name - skip\n");
 		return -1;
 	}