From 90036a167de18bf34f55043ab7579cc5da6a462e Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Wed, 26 Mar 2025 13:19:47 +0000 Subject: [PATCH 1/2] refactor(TODO): cleanup todos that have been implemented for ages Signed-off-by: Peter Lieven --- TODO | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/TODO b/TODO index dc12eb1..a63990c 100644 --- a/TODO +++ b/TODO @@ -1,23 +1,9 @@ Some features that should be added -* More efficient api for read/write commands where we read/write straight - from the socket into the buffer the application specified instead of as now - we pass the data to a callback and then copy it. - * More scsi marshalling and unmarshalling functions in scsi-lowlevel -* Autoconnect for session faiulures. - When the tcp session fail, try several times to reconnect and relogin. - If successful re-issue any commands that were in flight. - -* Redirects - -* Integrate with other relevant utilities such as +* Integrate with other relevant utilities such as dvdrecord, ... * Data Digest - - - - From eb0853e36e89add782b20f23ab4a1cd0fe83fb89 Mon Sep 17 00:00:00 2001 From: Peter Lieven Date: Wed, 26 Mar 2025 13:28:23 +0000 Subject: [PATCH 2/2] fix: use correct maximum length for TargetName and InitiatorName Signed-off-by: Peter Lieven --- include/iscsi-private.h | 4 ++-- include/iscsi.h | 2 ++ lib/init.c | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/include/iscsi-private.h b/include/iscsi-private.h index 065f243..3c3a219 100644 --- a/include/iscsi-private.h +++ b/include/iscsi-private.h @@ -82,8 +82,8 @@ struct iscsi_context { void *opaque; enum iscsi_transport_type transport; - char initiator_name[MAX_STRING_SIZE+1]; - char target_name[MAX_STRING_SIZE+1]; + char initiator_name[MAX_ISCSI_NAME_SIZE+1]; + char target_name[MAX_ISCSI_NAME_SIZE+1]; char target_address[MAX_STRING_SIZE+1]; /* If a redirect */ char connected_portal[MAX_STRING_SIZE+1]; char portal[MAX_STRING_SIZE+1]; diff --git a/include/iscsi.h b/include/iscsi.h index 375a7d8..ef9636e 100644 --- a/include/iscsi.h +++ b/include/iscsi.h @@ -44,6 +44,8 @@ struct scsi_iovec; #define LIBISCSI_FEATURE_ISER (1) #define MAX_STRING_SIZE (255) +/* RFC 3720 Section 3.2.6.1 */ +#define MAX_ISCSI_NAME_SIZE (223) /* * Syntax for normal and portal/discovery URLs. diff --git a/lib/init.c b/lib/init.c index 7dc5348..cc5bb42 100644 --- a/lib/init.c +++ b/lib/init.c @@ -222,7 +222,7 @@ iscsi_create_context(const char *initiator_name) return NULL; } - strncpy(iscsi->initiator_name,initiator_name,MAX_STRING_SIZE); + strncpy(iscsi->initiator_name,initiator_name,MAX_ISCSI_NAME_SIZE); iscsi->fd = -1; @@ -386,7 +386,7 @@ iscsi_set_targetname(struct iscsi_context *iscsi, const char *target_name) return -1; } - strncpy(iscsi->target_name,target_name,MAX_STRING_SIZE); + strncpy(iscsi->target_name,target_name,MAX_ISCSI_NAME_SIZE); return 0; }