From: Michihiro NAKAJIMA Date: Sun, 8 Nov 2009 11:52:49 +0000 (-0500) Subject: Remove duplicate code. X-Git-Tag: v2.8.0~222 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7c9d8e45375c510568ce025d22b0693895ffe068;p=thirdparty%2Flibarchive.git Remove duplicate code. SVN-Revision: 1593 --- diff --git a/libarchive/archive_read_support_format_iso9660.c b/libarchive/archive_read_support_format_iso9660.c index a5cf8ed5b..22a97bb66 100644 --- a/libarchive/archive_read_support_format_iso9660.c +++ b/libarchive/archive_read_support_format_iso9660.c @@ -622,28 +622,12 @@ isJolietSVD(struct iso9660 *iso9660, const unsigned char *h) const unsigned char *p; ssize_t logical_block_size; int32_t volume_block; - int32_t location; - int i; - /* Type 2 means it's a SVD. */ - if (h[SVD_type_offset] != 2) + /* Check if current sector is a kind of Supplementary Volume + * Descriptor. */ + if (!isSVD(iso9660, h)) return (0); - /* ID must be "CD001" */ - if (memcmp(h + SVD_id_offset, "CD001", 5) != 0) - return (0); - - /* Reserved field must be 0. */ - for (i = 0; i < SVD_reserved1_size; ++i) - if (h[SVD_reserved1_offset + i] != 0) - return (0); - for (i = 0; i < SVD_reserved2_size; ++i) - if (h[SVD_reserved2_offset + i] != 0) - return (0); - for (i = 0; i < SVD_reserved3_size; ++i) - if (h[SVD_reserved3_offset + i] != 0) - return (0); - /* FIXME: do more validations according to joliet spec. */ /* check if this SVD contains joliet extension! */ @@ -666,41 +650,15 @@ isJolietSVD(struct iso9660 *iso9660, const unsigned char *h) } else /* not joliet */ return (0); - /* File structure version must be 1 for ISO9660/ECMA119. */ - if (h[SVD_file_structure_version_offset] != 1) - return (0); - logical_block_size = archive_le16dec(h + SVD_logical_block_size_offset); - if (logical_block_size <= 0) - return (0); - volume_block = archive_le32dec(h + SVD_volume_space_size_offset); - if (volume_block <= SYSTEM_AREA_BLOCK+4) - return (0); - - /* Location of Occurrence of Type L Path Table must be - * available location, - * > SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */ - location = archive_le32dec(h+SVD_type_L_path_table_offset); - if (location <= SYSTEM_AREA_BLOCK+2 || location >= volume_block) - return (0); - - /* Location of Occurrence of Type M Path Table must be - * available location, - * > SYSTEM_AREA_BLOCK(16) + 2 and < Volume Space Size. */ - location = archive_be32dec(h+SVD_type_M_path_table_offset); - if (location <= SYSTEM_AREA_BLOCK+2 || location >= volume_block) - return (0); - - /* Read Root Directory Record in Volume Descriptor. */ - p = h + SVD_root_directory_record_offset; - if (p[DR_length_offset] != 34) - return (0); iso9660->logical_block_size = logical_block_size; iso9660->volume_block = volume_block; iso9660->volume_size = logical_block_size * (uint64_t)volume_block; + /* Read Root Directory Record in Volume Descriptor. */ + p = h + SVD_root_directory_record_offset; iso9660->joliet.location = archive_le32dec(p + DR_extent_offset); iso9660->joliet.size = archive_le32dec(p + DR_size_offset); @@ -722,10 +680,6 @@ isSVD(struct iso9660 *iso9660, const unsigned char *h) if (h[SVD_type_offset] != 2) return (0); - /* ID must be "CD001" */ - if (memcmp(h + SVD_id_offset, "CD001", 5) != 0) - return (0); - /* Reserved field must be 0. */ for (i = 0; i < SVD_reserved1_size; ++i) if (h[SVD_reserved1_offset + i] != 0) @@ -787,10 +741,6 @@ isEVD(struct iso9660 *iso9660, const unsigned char *h) if (h[PVD_type_offset] != 2) return (0); - /* ID must be "CD001" */ - if (memcmp(h + PVD_id_offset, "CD001", 5) != 0) - return (0); - /* EVD version must be 2. */ if (h[PVD_version_offset] != 2) return (0); @@ -871,10 +821,6 @@ isPVD(struct iso9660 *iso9660, const unsigned char *h) if (h[PVD_type_offset] != 1) return (0); - /* ID must be "CD001" */ - if (memcmp(h + PVD_id_offset, "CD001", 5) != 0) - return (0); - /* PVD version must be 1. */ if (h[PVD_version_offset] != 1) return (0);