| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/utility/safe_browsing/mac/udif.h" | 5 #include "chrome/utility/safe_browsing/mac/udif.h" |
| 6 | 6 |
| 7 #include <CoreFoundation/CoreFoundation.h> | 7 #include <CoreFoundation/CoreFoundation.h> |
| 8 #include <bzlib.h> | 8 #include <bzlib.h> |
| 9 #include <libkern/OSByteOrder.h> | 9 #include <libkern/OSByteOrder.h> |
| 10 #include <uuid/uuid.h> | 10 #include <uuid/uuid.h> |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 63 uint64_t rsrc_fork_length; | 63 uint64_t rsrc_fork_length; |
| 64 uint32_t segment_number; | 64 uint32_t segment_number; |
| 65 uint32_t segment_count; | 65 uint32_t segment_count; |
| 66 uuid_t segment_id; | 66 uuid_t segment_id; |
| 67 | 67 |
| 68 UDIFChecksum data_checksum; | 68 UDIFChecksum data_checksum; |
| 69 | 69 |
| 70 uint64_t plist_offset; // Offset and length of the blkx plist. | 70 uint64_t plist_offset; // Offset and length of the blkx plist. |
| 71 uint64_t plist_length; | 71 uint64_t plist_length; |
| 72 | 72 |
| 73 uint8_t reserved1[120]; | 73 uint8_t reserved1[64]; |
| 74 |
| 75 uint64_t code_signature_offset; |
| 76 uint64_t code_signature_length; |
| 77 |
| 78 uint8_t reserved2[40]; |
| 74 | 79 |
| 75 UDIFChecksum master_checksum; | 80 UDIFChecksum master_checksum; |
| 76 | 81 |
| 77 uint32_t image_variant; | 82 uint32_t image_variant; |
| 78 uint64_t sector_count; | 83 uint64_t sector_count; |
| 79 | 84 |
| 80 uint32_t reserved2; | |
| 81 uint32_t reserved3; | 85 uint32_t reserved3; |
| 82 uint32_t reserved4; | 86 uint32_t reserved4; |
| 87 uint32_t reserved5; |
| 83 }; | 88 }; |
| 84 | 89 |
| 85 static void ConvertBigEndian(uuid_t* uuid) { | 90 static void ConvertBigEndian(uuid_t* uuid) { |
| 86 // UUID is never consulted, so do not swap. | 91 // UUID is never consulted, so do not swap. |
| 87 } | 92 } |
| 88 | 93 |
| 89 static void ConvertBigEndian(UDIFResourceFile* file) { | 94 static void ConvertBigEndian(UDIFResourceFile* file) { |
| 90 ConvertBigEndian(&file->signature); | 95 ConvertBigEndian(&file->signature); |
| 91 ConvertBigEndian(&file->version); | 96 ConvertBigEndian(&file->version); |
| 92 ConvertBigEndian(&file->flags); | 97 ConvertBigEndian(&file->flags); |
| 93 ConvertBigEndian(&file->header_size); | 98 ConvertBigEndian(&file->header_size); |
| 94 ConvertBigEndian(&file->running_data_fork_offset); | 99 ConvertBigEndian(&file->running_data_fork_offset); |
| 95 ConvertBigEndian(&file->data_fork_offset); | 100 ConvertBigEndian(&file->data_fork_offset); |
| 96 ConvertBigEndian(&file->data_fork_length); | 101 ConvertBigEndian(&file->data_fork_length); |
| 97 ConvertBigEndian(&file->rsrc_fork_offset); | 102 ConvertBigEndian(&file->rsrc_fork_offset); |
| 98 ConvertBigEndian(&file->rsrc_fork_length); | 103 ConvertBigEndian(&file->rsrc_fork_length); |
| 99 ConvertBigEndian(&file->segment_number); | 104 ConvertBigEndian(&file->segment_number); |
| 100 ConvertBigEndian(&file->segment_count); | 105 ConvertBigEndian(&file->segment_count); |
| 101 ConvertBigEndian(&file->segment_id); | 106 ConvertBigEndian(&file->segment_id); |
| 102 ConvertBigEndian(&file->data_checksum); | 107 ConvertBigEndian(&file->data_checksum); |
| 103 ConvertBigEndian(&file->plist_offset); | 108 ConvertBigEndian(&file->plist_offset); |
| 104 ConvertBigEndian(&file->plist_length); | 109 ConvertBigEndian(&file->plist_length); |
| 110 ConvertBigEndian(&file->code_signature_offset); |
| 111 ConvertBigEndian(&file->code_signature_length); |
| 105 ConvertBigEndian(&file->master_checksum); | 112 ConvertBigEndian(&file->master_checksum); |
| 106 ConvertBigEndian(&file->image_variant); | 113 ConvertBigEndian(&file->image_variant); |
| 107 ConvertBigEndian(&file->sector_count); | 114 ConvertBigEndian(&file->sector_count); |
| 108 // Reserved fields are skipped. | 115 // Reserved fields are skipped. |
| 109 } | 116 } |
| 110 | 117 |
| 111 struct UDIFBlockChunk { | 118 struct UDIFBlockChunk { |
| 112 enum class Type : uint32_t { | 119 enum class Type : uint32_t { |
| 113 ZERO_FILL = 0x00000000, | 120 ZERO_FILL = 0x00000000, |
| 114 UNCOMPRESSED = 0x00000001, | 121 UNCOMPRESSED = 0x00000001, |
| (...skipping 674 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 789 << chunk_->compressed_offset; | 796 << chunk_->compressed_offset; |
| 790 return false; | 797 return false; |
| 791 } | 798 } |
| 792 return true; | 799 return true; |
| 793 } | 800 } |
| 794 | 801 |
| 795 } // namespace | 802 } // namespace |
| 796 | 803 |
| 797 } // namespace dmg | 804 } // namespace dmg |
| 798 } // namespace safe_browsing | 805 } // namespace safe_browsing |
| OLD | NEW |