Blame SOURCES/0030-check-for-a-target-being-there-before-processing-TargetAddress.patch

a66d21
check for a target being there before processing TargetAddress
a66d21
a66d21
Message-id: <1383729402-27559-12-git-send-email-pbonzini@redhat.com>
a66d21
Patchwork-id: 55506
a66d21
O-Subject: [PATCH 11/11] check for a target being there before processing TargetAddress
a66d21
Bugzilla: 1026820
a66d21
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
a66d21
RH-Acked-by: Orit Wasserman <owasserm@redhat.com>
a66d21
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
a66d21
a66d21
Otherwise we access a NULL pointer.
a66d21
a66d21
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
a66d21
(cherry picked from commit 87ee6456217debfbb9a0180933ed84281e45a705)
a66d21
---
a66d21
 lib/discovery.c | 8 ++++++++
a66d21
 1 file changed, 8 insertions(+)
a66d21
diff --git a/lib/discovery.c b/lib/discovery.c
a66d21
index 7396e71..178faef 100644
a66d21
--- a/lib/discovery.c
a66d21
+++ b/lib/discovery.c
a66d21
@@ -169,6 +169,14 @@ iscsi_process_text_reply(struct iscsi_context *iscsi, struct iscsi_pdu *pdu,
a66d21
 			target->next = targets;
a66d21
 			targets = target;
a66d21
 		} else if (!strncmp((char *)ptr, "TargetAddress=", 14)) {
a66d21
+			if (targets == NULL || targets->target_address != NULL) {
a66d21
+				iscsi_set_error(iscsi, "Invalid discovery "
a66d21
+						"reply");
a66d21
+				pdu->callback(iscsi, SCSI_STATUS_ERROR, NULL,
a66d21
+					      pdu->private_data);
a66d21
+				iscsi_free_discovery_addresses(iscsi, targets);
a66d21
+				return -1;
a66d21
+			}
a66d21
 			targets->target_address = iscsi_strdup(iscsi, (char *)ptr+14);
a66d21
 			if (targets->target_address == NULL) {
a66d21
 				iscsi_set_error(iscsi, "Failed to allocate "