CONNECT: connect data is not always malloc()ed so we can demand it is free()able
After a sync connection, make sure to clear connect_data since it will otherwise point to a structure on the stack.
This commit is contained in:
@@ -244,7 +244,6 @@ iscsi_destroy_context(struct iscsi_context *iscsi)
|
||||
free(discard_const(iscsi->chap_c));
|
||||
iscsi->chap_c = NULL;
|
||||
|
||||
free(iscsi->connect_data);
|
||||
iscsi->connect_data = NULL;
|
||||
|
||||
free(iscsi);
|
||||
|
||||
@@ -68,11 +68,6 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal,
|
||||
struct addrinfo *ai = NULL;
|
||||
int socksize;
|
||||
|
||||
if (iscsi->connect_data != NULL) {
|
||||
free(iscsi->connect_data);
|
||||
}
|
||||
iscsi->connect_data = private_data;
|
||||
|
||||
if (iscsi->fd != -1) {
|
||||
iscsi_set_error(iscsi,
|
||||
"Trying to connect but already connected.");
|
||||
@@ -159,6 +154,7 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal,
|
||||
}
|
||||
|
||||
iscsi->socket_status_cb = cb;
|
||||
iscsi->connect_data = private_data;
|
||||
|
||||
set_nonblocking(iscsi->fd);
|
||||
|
||||
|
||||
@@ -97,6 +97,9 @@ iscsi_connect_sync(struct iscsi_context *iscsi, const char *portal)
|
||||
|
||||
event_loop(iscsi, &state);
|
||||
|
||||
/* clear connect_data so it doesnt point to our stack */
|
||||
iscsi->connect_data = NULL;
|
||||
|
||||
return state.status;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user