From bde85a4b5796d3827292a641575f7bf2266c52a5 Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Tue, 6 Nov 2012 08:53:38 +0100 Subject: [PATCH] INIT allow iscsi_context = NULL in iscsi_set_error() qemu-kvm calls iscsi_parse_url_full() with iscsi = NULL. In case there is an invalid URL specified qemu-kvm segfaults when it tries to set iscsi->error_string. I tried to patch this in qemu-kvm, but the initiator_name is dirived from the target name so this seemed to be the easier approach. --- lib/init.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/init.c b/lib/init.c index d7d32d2..8c489a7 100644 --- a/lib/init.c +++ b/lib/init.c @@ -251,8 +251,13 @@ iscsi_set_error(struct iscsi_context *iscsi, const char *error_string, ...) } va_end(ap); - strncpy(iscsi->error_string,errstr,MAX_STRING_SIZE); - DPRINTF(iscsi,1,"%s",iscsi->error_string); + if (iscsi != NULL) { + strncpy(iscsi->error_string,errstr,MAX_STRING_SIZE); + DPRINTF(iscsi,1,"%s",iscsi->error_string); + } + else { + fprintf(stderr,"libiscsi: %s\n", errstr); + } } void