[stgt] [PATCH 01/11] check return of getnameinfo and getsockname
Boaz Harrosh
bharrosh at panasas.com
Thu Mar 12 11:58:13 CET 2009
Both getsockname and getnameinfo might fail check for
errors. And don't return to initiator a bogus address.
Also added a couple of eprints in error cases.
Signed-off-by: Boaz Harrosh <bharrosh at panasas.com>
---
usr/iscsi/iscsid.c | 17 +++++++++++++----
1 files changed, 13 insertions(+), 4 deletions(-)
diff --git a/usr/iscsi/iscsid.c b/usr/iscsi/iscsid.c
index 8a2ee9b..df51048 100644
--- a/usr/iscsi/iscsid.c
+++ b/usr/iscsi/iscsid.c
@@ -743,6 +743,7 @@ static void text_scan_text(struct iscsi_connection *conn)
{
char *key, *value, *data;
int datasize;
+ int ret;
data = conn->req.data;
datasize = conn->req.datasize;
@@ -760,15 +761,23 @@ static void text_scan_text(struct iscsi_connection *conn)
blen = sizeof(buf);
slen = sizeof(ss);
- conn->tp->ep_getsockname(conn, (struct sockaddr *) &ss,
- &slen);
+ ret = conn->tp->ep_getsockname(conn,
+ (struct sockaddr *) &ss, &slen);
+ if (ret)
+ eprintf("getsockname Faild=>%d\n", ret);
+
if (ss.ss_family == AF_INET6) {
*p++ = '[';
blen--;
}
- getnameinfo((struct sockaddr *) &ss, slen, p, blen,
- NULL, 0, NI_NUMERICHOST);
+ ret = getnameinfo((struct sockaddr *) &ss, slen, p,
+ blen, NULL, 0, NI_NUMERICHOST);
+ if (ret) {
+ eprintf("getnameinfo Faild=>%d: %s\n",
+ ret, gai_strerror(ret));
+ continue;
+ }
p = buf + strlen(buf);
--
1.6.0.6
--
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