reconnect: do not initialize iscsi to old_iscsi, use old_iscsi if appropriate

Makes it clearer that logging has to be done on the existing context,
since the "iscsi" pointer will not survive iscsi_reconnect.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
log failures (typically malloc) of iscsi_create_context during reconnect

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
exit after malloc failure when allocating sense data blob

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
do not test arrays against NULL

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
handle bad iscsi->fd in iscsi_service

Just do nothing if the file descriptor is invalid.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
rework login and discovery code to avoid strlen beyond end of data

Checking for the presence of the NUL character should be done
without accessing beyond the PDU datain.  Use memchr instead
of strlen, and compute the length only if a NUL character is
actually there.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
check for a target being there before processing TargetAddress

Otherwise we access a NULL pointer.  RFC3270 appendix D confirms
that TargetName must always come before TargetAddress.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Merge pull request #83 from bonzini/coverity

Fix issues reported by Coverity
Merged, thanks!