From f00cd048105f64102e28653f01c08aa0148e653f Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Tue, 6 Nov 2012 15:01:34 +0100 Subject: [PATCH] INIT call srand() once at iscsi_create_context() currently the rng is not seeded at all which makes the isid not really random at all. --- lib/init.c | 2 ++ lib/socket.c | 1 + 2 files changed, 3 insertions(+) diff --git a/lib/init.c b/lib/init.c index 2540779..143cf9b 100644 --- a/lib/init.c +++ b/lib/init.c @@ -88,6 +88,8 @@ iscsi_create_context(const char *initiator_name) iscsi->fd = -1; + srand(time(NULL) ^ getpid() ^ (u_int32_t) iscsi); + /* initialize to a "random" isid */ iscsi_set_isid_random(iscsi, rand(), 0); diff --git a/lib/socket.c b/lib/socket.c index 84b427e..7d1f014 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -228,6 +228,7 @@ iscsi_connect_async(struct iscsi_context *iscsi, const char *portal, break; } if (pchr2) {pchr=pchr2+1;} + iface_c++; } while (pchr2); int res = setsockopt(iscsi->fd, SOL_SOCKET, SO_BINDTODEVICE, pchr, strlen(pchr));