diff options
author | Michael Brown | 2008-09-26 22:30:53 +0200 |
---|---|---|
committer | Michael Brown | 2008-09-28 00:53:31 +0200 |
commit | 2d41dead0851254bffc703424c474c4466d78bca (patch) | |
tree | 574d28ffac1293e7866903ee48e1a45af2d8231c | |
parent | [release] Update version post release to 0.9.4+ (diff) | |
download | ipxe-2d41dead0851254bffc703424c474c4466d78bca.tar.gz ipxe-2d41dead0851254bffc703424c474c4466d78bca.tar.xz ipxe-2d41dead0851254bffc703424c474c4466d78bca.zip |
[iscsi] Fix LUN parsing in the iSCSI root-path
-rw-r--r-- | src/net/tcp/iscsi.c | 25 |
1 files changed, 14 insertions, 11 deletions
diff --git a/src/net/tcp/iscsi.c b/src/net/tcp/iscsi.c index 01a46584..e9e36449 100644 --- a/src/net/tcp/iscsi.c +++ b/src/net/tcp/iscsi.c @@ -1625,25 +1625,28 @@ enum iscsi_root_path_component { */ static int iscsi_parse_lun ( struct iscsi_session *iscsi, const char *lun_string ) { - char *p = ( char * ) lun_string; union { uint64_t u64; uint16_t u16[4]; } lun; + char *p; int i; - /* Empty LUN; assume LUN 0 */ - if ( ! *lun_string ) - return 0; - - for ( i = 0 ; i < 4 ; i++ ) { - lun.u16[i] = strtoul ( p, &p, 16 ); - if ( *p != '-' ) + memset ( &lun, 0, sizeof ( lun ) ); + if ( lun_string ) { + p = ( char * ) lun_string; + + for ( i = 0 ; i < 4 ; i++ ) { + lun.u16[i] = htons ( strtoul ( p, &p, 16 ) ); + if ( *p == '\0' ) + break; + if ( *p != '-' ) + return -EINVAL; + p++; + } + if ( *p ) return -EINVAL; - p++; } - if ( *p ) - return -EINVAL; iscsi->lun = lun.u64; return 0; |