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.
This commit is contained in:
Peter Lieven
2012-11-06 08:53:38 +01:00
parent 1ba60282bf
commit 0d8819e68f

View File

@@ -293,8 +293,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