[ipxe-devel] [PATCH 5/7] iscsi: Parse IPv6 address for rootpath
Hannes Reinecke
hare at suse.de
Wed Apr 1 07:26:19 UTC 2015
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 2e420d9..6a1b164 100644
--- a/src/net/tcp/iscsi.c
+++ b/src/net/tcp/iscsi.c
@@ -1899,15 +1899,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';
}
--
1.8.4.5
More information about the ipxe-devel
mailing list