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

Unified Diff: chrome/utility/safe_browsing/mac/udif.cc

Issue 2934373002: Record Code Signature of Downloaded DMG files (Closed)
Patch Set: correcting rebase mixup Created 3 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/utility/safe_browsing/mac/udif.h ('k') | components/safe_browsing/csd.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/utility/safe_browsing/mac/udif.cc
diff --git a/chrome/utility/safe_browsing/mac/udif.cc b/chrome/utility/safe_browsing/mac/udif.cc
index 0c4be3fa310747ef84226969a5ea536f630e8b6c..dea3cf91ff766ea2cd5ef10a307b796bf151f9ac 100644
--- a/chrome/utility/safe_browsing/mac/udif.cc
+++ b/chrome/utility/safe_browsing/mac/udif.cc
@@ -348,8 +348,7 @@ UDIFParser::UDIFParser(ReadStream* stream)
: stream_(stream),
partition_names_(),
blocks_(),
- block_size_(kSectorSize) {
-}
+ block_size_(kSectorSize) {}
UDIFParser::~UDIFParser() {}
@@ -360,6 +359,10 @@ bool UDIFParser::Parse() {
return true;
}
+const std::vector<uint8_t>& UDIFParser::GetCodeSignature() {
+ return signature_blob_;
+}
+
size_t UDIFParser::GetNumberOfPartitions() {
return blocks_.size();
}
@@ -557,6 +560,37 @@ bool UDIFParser::ParseBlkx() {
partition_names_.push_back(partition_name);
}
+ // The offsets in the trailer could be garbage in DMGs that aren't signed.
+ // Need a sanity check that the DMG has legit values for these fields.
+ if (trailer.code_signature_length != 0 && trailer_start > 0) {
+ auto code_signature_end =
+ base::CheckedNumeric<size_t>(trailer.code_signature_offset) +
+ trailer.code_signature_length;
+ if (code_signature_end.IsValid() &&
+ code_signature_end.ValueOrDie() <=
+ base::checked_cast<size_t>(trailer_start)) {
+ signature_blob_.resize(trailer.code_signature_length);
+
+ off_t code_signature_start =
+ stream_->Seek(trailer.code_signature_offset, SEEK_SET);
+ if (code_signature_start == -1)
+ return false;
+
+ size_t bytes_read = 0;
+
+ if (!stream_->Read(signature_blob_.data(), trailer.code_signature_length,
+ &bytes_read)) {
+ DLOG(ERROR) << "Failed to read raw signature bytes";
+ return false;
+ }
+
+ if (bytes_read != trailer.code_signature_length) {
+ DLOG(ERROR) << "Read unexpected number of raw signature bytes";
+ return false;
+ }
+ }
+ }
+
return true;
}
« no previous file with comments | « chrome/utility/safe_browsing/mac/udif.h ('k') | components/safe_browsing/csd.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698