diff --git a/src/file_iso.c b/src/file_iso.c index a45b1849..49c5dbeb 100644 --- a/src/file_iso.c +++ b/src/file_iso.c @@ -29,6 +29,7 @@ #endif #include #include "types.h" +#include "common.h" #include "filegen.h" #include "iso9660.h" @@ -50,13 +51,13 @@ static int header_check_db(const unsigned char *buffer, const unsigned int buffe return 0; { const struct iso_primary_descriptor *iso1=(const struct iso_primary_descriptor*)&buffer[0x8000]; - const unsigned int volume_space_size=iso1->volume_space_size[0] | (iso1->volume_space_size[1]<<8) | (iso1->volume_space_size[2]<<16) | (iso1->volume_space_size[3]<<24); - const unsigned int volume_space_size2=iso1->volume_space_size[7] | (iso1->volume_space_size[6]<<8) | (iso1->volume_space_size[5]<<16) | (iso1->volume_space_size[4]<<24); - const unsigned int logical_block_size=iso1->logical_block_size[0] | (iso1->logical_block_size[1]<<8); - const unsigned int logical_block_size2=iso1->logical_block_size[3] | (iso1->logical_block_size[2]<<8); - if(volume_space_size==volume_space_size2 && logical_block_size==logical_block_size2) + const unsigned int volume_space_size_le=le32(iso1->volume_space_size_le); + const unsigned int volume_space_size_be=be32(iso1->volume_space_size_be); + const unsigned int logical_block_size_le=le16(iso1->logical_block_size_le); + const unsigned int logical_block_size_be=be16(iso1->logical_block_size_be); + if(volume_space_size_le==volume_space_size_be && logical_block_size_le==logical_block_size_be) { /* ISO 9660 */ - const uint64_t size=(uint64_t)volume_space_size * logical_block_size; + const uint64_t size=(uint64_t)volume_space_size_le * logical_block_size_le; if(size < 0x8000+512) return 0; reset_file_recovery(file_recovery_new); @@ -79,5 +80,4 @@ static void register_header_check_iso(file_stat_t *file_stat) static const unsigned char iso_header[6]= { 0x01, 'C', 'D', '0', '0', '1'}; register_header_check(0x8000, iso_header,sizeof(iso_header), &header_check_db, file_stat); } - #endif diff --git a/src/iso.c b/src/iso.c index b025ca82..05b636c4 100644 --- a/src/iso.c +++ b/src/iso.c @@ -67,15 +67,15 @@ int check_ISO(disk_t *disk_car, partition_t *partition) static void set_ISO_info(const struct iso_primary_descriptor *iso, partition_t *partition) { - const unsigned int volume_space_size=iso->volume_space_size[0] | (iso->volume_space_size[1]<<8) | (iso->volume_space_size[2]<<16) | (iso->volume_space_size[3]<<24); - const unsigned int volume_space_size2=iso->volume_space_size[7] | (iso->volume_space_size[6]<<8) | (iso->volume_space_size[5]<<16) | (iso->volume_space_size[4]<<24); - const unsigned int logical_block_size=iso->logical_block_size[0] | (iso->logical_block_size[1]<<8); - const unsigned int logical_block_size2=iso->logical_block_size[3] | (iso->logical_block_size[2]<<8); + const unsigned int volume_space_size_le=le32(iso->volume_space_size_le); + const unsigned int volume_space_size_be=be32(iso->volume_space_size_be); + const unsigned int logical_block_size_le=le16(iso->logical_block_size_le); + const unsigned int logical_block_size_be=be16(iso->logical_block_size_be); partition->upart_type=UP_ISO; set_part_name_chomp(partition, (const unsigned char*)iso->volume_id, 32); - if(volume_space_size==volume_space_size2 && logical_block_size==logical_block_size2) + if(volume_space_size_le==volume_space_size_be && logical_block_size_le==logical_block_size_be) { - partition->blocksize=logical_block_size; + partition->blocksize=logical_block_size_le; snprintf(partition->info, sizeof(partition->info), "ISO9660 blocksize=%u", partition->blocksize); } @@ -89,13 +89,13 @@ int recover_ISO(const struct iso_primary_descriptor *iso, partition_t *partition return 1; set_ISO_info(iso, partition); { - const unsigned int volume_space_size=iso->volume_space_size[0] | (iso->volume_space_size[1]<<8) | (iso->volume_space_size[2]<<16) | (iso->volume_space_size[3]<<24); - const unsigned int volume_space_size2=iso->volume_space_size[7] | (iso->volume_space_size[6]<<8) | (iso->volume_space_size[5]<<16) | (iso->volume_space_size[4]<<24); - const unsigned int logical_block_size=iso->logical_block_size[0] | (iso->logical_block_size[1]<<8); - const unsigned int logical_block_size2=iso->logical_block_size[3] | (iso->logical_block_size[2]<<8); - if(volume_space_size==volume_space_size2 && logical_block_size==logical_block_size2) + const unsigned int volume_space_size_le=le32(iso->volume_space_size_le); + const unsigned int volume_space_size_be=be32(iso->volume_space_size_be); + const unsigned int logical_block_size_le=le16(iso->logical_block_size_le); + const unsigned int logical_block_size_be=be16(iso->logical_block_size_be); + if(volume_space_size_le==volume_space_size_be && logical_block_size_le==logical_block_size_be) { /* ISO 9660 */ - partition->part_size=(uint64_t)volume_space_size * logical_block_size; + partition->part_size=(uint64_t)volume_space_size_le * logical_block_size_le; } } return 0; diff --git a/src/iso9660.h b/src/iso9660.h index 5a4f5864..df826558 100644 --- a/src/iso9660.h +++ b/src/iso9660.h @@ -33,11 +33,13 @@ struct iso_primary_descriptor char system_id[32]; char volume_id[32]; char unused2[8]; - char volume_space_size[8]; + uint32_t volume_space_size_le; + uint32_t volume_space_size_be; char unused3[32]; char volume_set_size[4]; char volume_sequence_number[4]; - char logical_block_size[4]; + uint16_t logical_block_size_le; + uint16_t logical_block_size_be; char path_table_size[8]; char type_l_path_tabl[4]; char opt_type_l_path_table[4];