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 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 auto size = | 396 auto size = |
397 base::CheckedNumeric<size_t>(blocks_[part_number]->sector_count()) * | 397 base::CheckedNumeric<size_t>(blocks_[part_number]->sector_count()) * |
398 block_size_; | 398 block_size_; |
399 return size.ValueOrDie(); | 399 return size.ValueOrDie(); |
400 } | 400 } |
401 | 401 |
402 std::unique_ptr<ReadStream> UDIFParser::GetPartitionReadStream( | 402 std::unique_ptr<ReadStream> UDIFParser::GetPartitionReadStream( |
403 size_t part_number) { | 403 size_t part_number) { |
404 DCHECK_LT(part_number, blocks_.size()); | 404 DCHECK_LT(part_number, blocks_.size()); |
405 return base::MakeUnique<UDIFPartitionReadStream>(stream_, block_size_, | 405 return base::MakeUnique<UDIFPartitionReadStream>(stream_, block_size_, |
406 blocks_[part_number]); | 406 blocks_[part_number].get()); |
407 } | 407 } |
408 | 408 |
409 bool UDIFParser::ParseBlkx() { | 409 bool UDIFParser::ParseBlkx() { |
410 UDIFResourceFile trailer; | 410 UDIFResourceFile trailer; |
411 off_t trailer_start = stream_->Seek(-sizeof(trailer), SEEK_END); | 411 off_t trailer_start = stream_->Seek(-sizeof(trailer), SEEK_END); |
412 if (trailer_start == -1) | 412 if (trailer_start == -1) |
413 return false; | 413 return false; |
414 | 414 |
415 if (!stream_->ReadType(&trailer)) { | 415 if (!stream_->ReadType(&trailer)) { |
416 DLOG(ERROR) << "Failed to read UDIFResourceFile"; | 416 DLOG(ERROR) << "Failed to read UDIFResourceFile"; |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 | 502 |
503 auto* data = base::mac::GetValueFromDictionary<CFDataRef>(block_dictionary, | 503 auto* data = base::mac::GetValueFromDictionary<CFDataRef>(block_dictionary, |
504 CFSTR("Data")); | 504 CFSTR("Data")); |
505 if (!data) { | 505 if (!data) { |
506 DLOG(ERROR) << "Skipping block " << i | 506 DLOG(ERROR) << "Skipping block " << i |
507 << " because it has no Data section"; | 507 << " because it has no Data section"; |
508 continue; | 508 continue; |
509 } | 509 } |
510 | 510 |
511 // Copy the block table out of the plist. | 511 // Copy the block table out of the plist. |
512 std::unique_ptr<UDIFBlock> block(new UDIFBlock()); | 512 auto block = base::MakeUnique<UDIFBlock>(); |
513 if (!block->ParseBlockData( | 513 if (!block->ParseBlockData( |
514 reinterpret_cast<const UDIFBlockData*>(CFDataGetBytePtr(data)), | 514 reinterpret_cast<const UDIFBlockData*>(CFDataGetBytePtr(data)), |
515 base::checked_cast<size_t>(CFDataGetLength(data)), | 515 base::checked_cast<size_t>(CFDataGetLength(data)), |
516 block_size_)) { | 516 block_size_)) { |
517 DLOG(ERROR) << "Failed to parse UDIF block data"; | 517 DLOG(ERROR) << "Failed to parse UDIF block data"; |
518 return false; | 518 return false; |
519 } | 519 } |
520 | 520 |
521 if (block->signature() != UDIFBlockData::kSignature) { | 521 if (block->signature() != UDIFBlockData::kSignature) { |
522 DLOG(ERROR) << "Skipping block " << i << " because its signature does not" | 522 DLOG(ERROR) << "Skipping block " << i << " because its signature does not" |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 << chunk_->compressed_offset; | 865 << chunk_->compressed_offset; |
866 return false; | 866 return false; |
867 } | 867 } |
868 return true; | 868 return true; |
869 } | 869 } |
870 | 870 |
871 } // namespace | 871 } // namespace |
872 | 872 |
873 } // namespace dmg | 873 } // namespace dmg |
874 } // namespace safe_browsing | 874 } // namespace safe_browsing |
OLD | NEW |