diff options
-rw-r--r-- | libopeniscsiusr/session.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/libopeniscsiusr/session.c b/libopeniscsiusr/session.c index 489cea7..4d47592 100644 --- a/libopeniscsiusr/session.c +++ b/libopeniscsiusr/session.c @@ -289,11 +289,15 @@ int iscsi_sessions_get(struct iscsi_context *ctx, rc = LIBISCSI_OK; } } - /* reset session count and sessions array length to what we were able to read from sysfs */ + /* + * reset session count and sessions array length to what we were able to read from sysfs + * + * do not use reallocarray() for the sessions array, since not all platforms + * have that function call + */ *session_count = j; - /* XXX: asserts that there is no integer overflow */ - assert(!(sizeof(struct iscsi_session *) && - *session_count > UINT_MAX / sizeof(struct iscsi_session *))); + /* assert that there is no integer overflow in the realloc call */ + assert(!(*session_count > (UINT_MAX / sizeof(struct iscsi_session *)))); *sessions = realloc(*sessions, *session_count * sizeof(struct iscsi_session *)); |