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/hfs.h" | 5 #include "chrome/utility/safe_browsing/mac/hfs.h" |
6 | 6 |
7 #include <libkern/OSByteOrder.h> | 7 #include <libkern/OSByteOrder.h> |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <sys/stat.h> | 9 #include <sys/stat.h> |
10 | 10 |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 current_extent_data_.resize(extent_size.ValueOrDie()); | 376 current_extent_data_.resize(extent_size.ValueOrDie()); |
377 if (!hfs_->stream()->ReadExact(¤t_extent_data_[0], | 377 if (!hfs_->stream()->ReadExact(¤t_extent_data_[0], |
378 extent_size.ValueOrDie())) { | 378 extent_size.ValueOrDie())) { |
379 DLOG(ERROR) << "Failed to read extent " << current_extent_; | 379 DLOG(ERROR) << "Failed to read extent " << current_extent_; |
380 return false; | 380 return false; |
381 } | 381 } |
382 | 382 |
383 read_current_extent_ = true; | 383 read_current_extent_ = true; |
384 } | 384 } |
385 | 385 |
386 size_t extent_offset = fork_logical_offset_ % extent_size.ValueOrDie(); | 386 size_t extent_offset = (fork_logical_offset_ % extent_size).ValueOrDie(); |
387 size_t bytes_to_copy = | 387 size_t bytes_to_copy = std::min( |
388 std::min(std::min(static_cast<size_t>(fork_.logicalSize) - | 388 std::min( |
389 fork_logical_offset_, | 389 static_cast<size_t>(fork_.logicalSize) - fork_logical_offset_, |
390 extent_size.ValueOrDie() - extent_offset), | 390 static_cast<size_t>((extent_size - extent_offset).ValueOrDie())), |
391 buffer_space_remaining); | 391 buffer_space_remaining); |
392 | 392 |
393 memcpy(&buffer[buffer_size - buffer_space_remaining], | 393 memcpy(&buffer[buffer_size - buffer_space_remaining], |
394 ¤t_extent_data_[extent_offset], | 394 ¤t_extent_data_[extent_offset], |
395 bytes_to_copy); | 395 bytes_to_copy); |
396 | 396 |
397 buffer_space_remaining -= bytes_to_copy; | 397 buffer_space_remaining -= bytes_to_copy; |
398 *bytes_read += bytes_to_copy; | 398 *bytes_read += bytes_to_copy; |
399 fork_logical_offset_ += bytes_to_copy; | 399 fork_logical_offset_ += bytes_to_copy; |
400 | 400 |
401 // If the fork's data have been read, then end the loop. | 401 // If the fork's data have been read, then end the loop. |
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
645 return object; | 645 return object; |
646 } | 646 } |
647 | 647 |
648 bool HFSBTreeIterator::IsKeyUnexported(const base::string16& key) { | 648 bool HFSBTreeIterator::IsKeyUnexported(const base::string16& key) { |
649 return key == kHFSDirMetadataFolder || | 649 return key == kHFSDirMetadataFolder || |
650 key == kHFSMetadataFolder; | 650 key == kHFSMetadataFolder; |
651 } | 651 } |
652 | 652 |
653 } // namespace dmg | 653 } // namespace dmg |
654 } // namespace safe_browsing | 654 } // namespace safe_browsing |
OLD | NEW |