[ipxe-devel] [PATCH 1/2] iscsi: Parse IPv6 address for rootpath

Hannes Reinecke hare at suse.de
Mon Feb 5 08:38:20 UTC 2018


The 'rootpath' variable might contain an IPv6 address in brackets
[XX:XX::XX]. So update the parser to handle this address correctly.

Signed-off-by: Hannes Reinecke <hare at suse.de>
---
 src/net/tcp/iscsi.c | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/src/net/tcp/iscsi.c b/src/net/tcp/iscsi.c
index 789ac86e6..376e77ea5 100644
--- a/src/net/tcp/iscsi.c
+++ b/src/net/tcp/iscsi.c
@@ -1927,15 +1927,25 @@ static int iscsi_parse_root_path ( struct iscsi_session *iscsi,
 	/* Split root path into component parts */
 	strcpy ( rp_copy, root_path );
 	while ( 1 ) {
+		int skip = 0;
+
+		if (*rp == '[') {
+			rp++;
+			skip = 1;
+		}
 		rp_comp[i++] = rp;
 		if ( i == NUM_RP_COMPONENTS )
 			break;
-		for ( ; *rp != ':' ; rp++ ) {
+		for ( ; *rp != ':' || skip; rp++ ) {
 			if ( ! *rp ) {
 				DBGC ( iscsi, "iSCSI %p root path \"%s\" "
 				       "too short\n", iscsi, root_path );
 				return -EINVAL_ROOT_PATH_TOO_SHORT;
 			}
+			if (*rp == ']') {
+				skip = 0;
+				*rp = '\0';
+			}
 		}
 		*(rp++) = '\0';
 	}
-- 
2.13.6




More information about the ipxe-devel mailing list