Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(178)

Side by Side Diff: chrome/utility/safe_browsing/mac/udif.cc

Issue 2225123002: [Mac] Convert a DCHECK to a condition in safe_browsing::dmg::UDIFBlockChunkReadStream::Seek. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2785
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 if (!decompress_read_offset.IsValid()) { 602 if (!decompress_read_offset.IsValid()) {
603 DLOG(ERROR) << "Partition decompress read offset overflows"; 603 DLOG(ERROR) << "Partition decompress read offset overflows";
604 return -1; 604 return -1;
605 } 605 }
606 606
607 if (!chunk_stream_ || chunk != chunk_stream_->chunk()) { 607 if (!chunk_stream_ || chunk != chunk_stream_->chunk()) {
608 chunk_stream_.reset( 608 chunk_stream_.reset(
609 new UDIFBlockChunkReadStream(stream_, block_size_, chunk)); 609 new UDIFBlockChunkReadStream(stream_, block_size_, chunk));
610 } 610 }
611 current_chunk_ = chunk_number; 611 current_chunk_ = chunk_number;
612 chunk_stream_->Seek(decompress_read_offset.ValueOrDie(), SEEK_SET); 612 if (chunk_stream_->Seek(decompress_read_offset.ValueOrDie(), SEEK_SET) == -1)
613 return -1;
613 614
614 return offset; 615 return offset;
615 } 616 }
616 617
617 UDIFBlockChunkReadStream::UDIFBlockChunkReadStream(ReadStream* stream, 618 UDIFBlockChunkReadStream::UDIFBlockChunkReadStream(ReadStream* stream,
618 uint16_t block_size, 619 uint16_t block_size,
619 const UDIFBlockChunk* chunk) 620 const UDIFBlockChunk* chunk)
620 : stream_(stream), 621 : stream_(stream),
621 chunk_(chunk), 622 chunk_(chunk),
622 length_in_bytes_(chunk->sector_count * block_size), 623 length_in_bytes_(chunk->sector_count * block_size),
(...skipping 27 matching lines...) Expand all
650 break; 651 break;
651 case UDIFBlockChunk::Type::LAST_BLOCK: 652 case UDIFBlockChunk::Type::LAST_BLOCK:
652 *bytes_read = 0; 653 *bytes_read = 0;
653 return true; 654 return true;
654 } 655 }
655 return false; 656 return false;
656 } 657 }
657 658
658 off_t UDIFBlockChunkReadStream::Seek(off_t offset, int whence) { 659 off_t UDIFBlockChunkReadStream::Seek(off_t offset, int whence) {
659 DCHECK_EQ(SEEK_SET, whence); 660 DCHECK_EQ(SEEK_SET, whence);
660 DCHECK_LT(static_cast<uint64_t>(offset), length_in_bytes_); 661 if (static_cast<uint64_t>(offset) >= length_in_bytes_)
662 return -1;
661 offset_ = offset; 663 offset_ = offset;
662 return offset_; 664 return offset_;
663 } 665 }
664 666
665 bool UDIFBlockChunkReadStream::CopyOutZeros(uint8_t* buffer, 667 bool UDIFBlockChunkReadStream::CopyOutZeros(uint8_t* buffer,
666 size_t buffer_size, 668 size_t buffer_size,
667 size_t* bytes_read) { 669 size_t* bytes_read) {
668 *bytes_read = std::min(buffer_size, length_in_bytes_ - offset_); 670 *bytes_read = std::min(buffer_size, length_in_bytes_ - offset_);
669 bzero(buffer, *bytes_read); 671 bzero(buffer, *bytes_read);
670 offset_ += *bytes_read; 672 offset_ += *bytes_read;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 << chunk_->compressed_offset; 791 << chunk_->compressed_offset;
790 return false; 792 return false;
791 } 793 }
792 return true; 794 return true;
793 } 795 }
794 796
795 } // namespace 797 } // namespace
796 798
797 } // namespace dmg 799 } // namespace dmg
798 } // namespace safe_browsing 800 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698