[stgt] [PATCH 2/2] iscsi: enlarge response buffer if necessary

FUJITA Tomonori fujita.tomonori at lab.ntt.co.jp
Fri Apr 24 07:23:40 CEST 2009


Signed-off-by: FUJITA Tomonori <fujita.tomonori at lab.ntt.co.jp>
---
 usr/iscsi/iscsid.c |   20 ++++++++++++++++----
 1 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index a34111e..9252f4a 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -166,13 +166,19 @@ void text_key_add(struct iscsi_connection *conn, char *key, char *value)
 	if (!conn->rsp.datasize)
 		conn->rsp.data = conn->rsp_buffer;
 
+	buffer = conn->rsp_buffer;
+
 	if (conn->rsp.datasize + len > max_len)
 		goto drop;
 
-	if (conn->rsp.datasize + len > INCOMING_BUFSIZE)
-		goto drop;
+	if (conn->rsp.datasize + len > INCOMING_BUFSIZE) {
+		buffer = realloc(buffer, conn->rsp.datasize + len);
+		if (buffer)
+			conn->rsp_buffer = buffer;
+		else
+			goto drop;
+	}
 
-	buffer = conn->rsp_buffer;
 	buffer += conn->rsp.datasize;
 	conn->rsp.datasize += len;
 
@@ -327,7 +333,13 @@ static void text_scan_login(struct iscsi_connection *conn)
 			}
 
 			err = param_check_val(session_keys, idx, &val);
-			err = param_set_val(session_keys, conn->session_param, idx, &val);
+			if (idx == ISCSI_PARAM_MAX_XMIT_DLENGTH &&
+			    conn->session_type == SESSION_DISCOVERY)
+				conn->session_param[idx].val = val;
+			else
+				err = param_set_val(session_keys,
+						    conn->session_param,
+						    idx, &val);
 
 			switch (conn->session_param[idx].state) {
 			case KEY_STATE_START:
-- 
1.5.6.5

--
To unsubscribe from this list: send the line "unsubscribe stgt" in
the body of a message to majordomo at vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html



More information about the stgt mailing list