david/ipxe
david
/
ipxe
Archived
1
0
Fork 0

[iscsi] Fix LUN parsing in the iSCSI root-path

This commit is contained in:
Michael Brown 2008-09-26 21:30:53 +01:00
parent 6eaefa16a8
commit 2d41dead08
1 changed files with 14 additions and 11 deletions

View File

@ -1625,25 +1625,28 @@ enum iscsi_root_path_component {
*/ */
static int iscsi_parse_lun ( struct iscsi_session *iscsi, static int iscsi_parse_lun ( struct iscsi_session *iscsi,
const char *lun_string ) { const char *lun_string ) {
char *p = ( char * ) lun_string;
union { union {
uint64_t u64; uint64_t u64;
uint16_t u16[4]; uint16_t u16[4];
} lun; } lun;
char *p;
int i; int i;
/* Empty LUN; assume LUN 0 */ memset ( &lun, 0, sizeof ( lun ) );
if ( ! *lun_string ) if ( lun_string ) {
return 0; p = ( char * ) lun_string;
for ( i = 0 ; i < 4 ; i++ ) { for ( i = 0 ; i < 4 ; i++ ) {
lun.u16[i] = strtoul ( p, &p, 16 ); lun.u16[i] = htons ( strtoul ( p, &p, 16 ) );
if ( *p != '-' ) if ( *p == '\0' )
break;
if ( *p != '-' )
return -EINVAL;
p++;
}
if ( *p )
return -EINVAL; return -EINVAL;
p++;
} }
if ( *p )
return -EINVAL;
iscsi->lun = lun.u64; iscsi->lun = lun.u64;
return 0; return 0;