[ipxe-devel] [PATCH 09/11] iscsi: Parse IPv6 address for rootpath
Hannes Reinecke
hare at suse.de
Thu May 7 09:25:04 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 0099bf5..a61c0c4 100644
--- a/src/net/tcp/iscsi.c
+++ b/src/net/tcp/iscsi.c
@@ -1901,15 +1901,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