summaryrefslogtreecommitdiff
path: root/usr.sbin/iscsid
diff options
context:
space:
mode:
authorClaudio Jeker <claudio@cvs.openbsd.org>2014-04-20 16:49:57 +0000
committerClaudio Jeker <claudio@cvs.openbsd.org>2014-04-20 16:49:57 +0000
commitd6649b60ee363e8ca05fe19f581df746b73ca0bd (patch)
tree5f60621aac1276748b4ef48ca5b82387dbf57d78 /usr.sbin/iscsid
parent75897dba8ca692e11c70bae46eada44b8eb578ed (diff)
Fix conn_gen_kvp and its caller to fill the kvp array properly (including
the NULL terminator at the end). Now iscsid does proper LoginOperational negotiation (which will bump the MaxRecvDataSegmentLength to 64k)
Diffstat (limited to 'usr.sbin/iscsid')
-rw-r--r--usr.sbin/iscsid/connection.c12
-rw-r--r--usr.sbin/iscsid/initiator.c3
2 files changed, 8 insertions, 7 deletions
diff --git a/usr.sbin/iscsid/connection.c b/usr.sbin/iscsid/connection.c
index dc63a3ee187..d9c0ad6ae1d 100644
--- a/usr.sbin/iscsid/connection.c
+++ b/usr.sbin/iscsid/connection.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: connection.c,v 1.13 2011/05/04 21:00:04 claudio Exp $ */
+/* $OpenBSD: connection.c,v 1.14 2014/04/20 16:49:56 claudio Exp $ */
/*
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
@@ -313,31 +313,31 @@ conn_gen_kvp(struct connection *c, struct kvp *kvp, size_t *nkvp)
size_t i = 0;
if (s->mine.MaxConnections != iscsi_sess_defaults.MaxConnections) {
- i++;
if (kvp && i < *nkvp) {
kvp[i].key = strdup("MaxConnections");
if (kvp[i].key == NULL)
return (-1);
- if (asprintf(&kvp[i].value, "%u",
- (unsigned int)s->mine.MaxConnections) == -1) {
+ if (asprintf(&kvp[i].value, "%hu",
+ s->mine.MaxConnections) == -1) {
kvp[i].value = NULL;
return (-1);
}
}
+ i++;
}
if (c->mine.MaxRecvDataSegmentLength !=
iscsi_conn_defaults.MaxRecvDataSegmentLength) {
- i++;
if (kvp && i < *nkvp) {
kvp[i].key = strdup("MaxRecvDataSegmentLength");
if (kvp[i].key == NULL)
return (-1);
if (asprintf(&kvp[i].value, "%u",
- (unsigned int)c->mine.MaxRecvDataSegmentLength) == -1) {
+ c->mine.MaxRecvDataSegmentLength) == -1) {
kvp[i].value = NULL;
return (-1);
}
}
+ i++;
}
*nkvp = i;
diff --git a/usr.sbin/iscsid/initiator.c b/usr.sbin/iscsid/initiator.c
index 99e914ab43a..a8b794d73d0 100644
--- a/usr.sbin/iscsid/initiator.c
+++ b/usr.sbin/iscsid/initiator.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: initiator.c,v 1.11 2014/04/19 18:31:33 claudio Exp $ */
+/* $OpenBSD: initiator.c,v 1.12 2014/04/20 16:49:56 claudio Exp $ */
/*
* Copyright (c) 2009 Claudio Jeker <claudio@openbsd.org>
@@ -276,6 +276,7 @@ initiator_login_kvp(struct connection *c, u_int8_t stage)
case ISCSI_LOGIN_STG_OPNEG:
if (conn_gen_kvp(c, NULL, &nkvp) == -1)
return NULL;
+ nkvp += 1; /* add slot for terminator */
if (!(kvp = calloc(nkvp, sizeof(*kvp))))
return NULL;
if (conn_gen_kvp(c, kvp, &nkvp) == -1) {