| 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/dmg_analyzer.h" | 5 #include "chrome/utility/safe_browsing/mac/dmg_analyzer.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 sha256->Update(&buffer_[buffer_offset], bytes_read); | 110 sha256->Update(&buffer_[buffer_offset], bytes_read); |
| 111 } while (bytes_read > 0); | 111 } while (bytes_read > 0); |
| 112 | 112 |
| 113 sha256->Finish(digest, crypto::kSHA256Length); | 113 sha256->Finish(digest, crypto::kSHA256Length); |
| 114 | 114 |
| 115 return true; | 115 return true; |
| 116 } | 116 } |
| 117 | 117 |
| 118 } // namespace | 118 } // namespace |
| 119 | 119 |
| 120 void AnalyzeDMGFile(base::File dmg_file, | 120 void AnalyzeDMGFile(base::File dmg_file, ArchiveAnalyzerResults* results) { |
| 121 safe_browsing::zip_analyzer::Results* results) { | |
| 122 MachOFeatureExtractor feature_extractor; | 121 MachOFeatureExtractor feature_extractor; |
| 123 results->success = false; | 122 results->success = false; |
| 124 | 123 |
| 125 FileReadStream read_stream(dmg_file.GetPlatformFile()); | 124 FileReadStream read_stream(dmg_file.GetPlatformFile()); |
| 126 DMGIterator iterator(&read_stream); | 125 DMGIterator iterator(&read_stream); |
| 127 if (!iterator.Open()) | 126 if (!iterator.Open()) |
| 128 return; | 127 return; |
| 129 | 128 |
| 130 while (iterator.Next()) { | 129 while (iterator.Next()) { |
| 131 std::unique_ptr<ReadStream> stream = iterator.GetReadStream(); | 130 std::unique_ptr<ReadStream> stream = iterator.GetReadStream(); |
| (...skipping 11 matching lines...) Expand all Loading... |
| 143 } else { | 142 } else { |
| 144 results->archived_binary.RemoveLast(); | 143 results->archived_binary.RemoveLast(); |
| 145 } | 144 } |
| 146 } | 145 } |
| 147 | 146 |
| 148 results->success = true; | 147 results->success = true; |
| 149 } | 148 } |
| 150 | 149 |
| 151 } // namespace dmg | 150 } // namespace dmg |
| 152 } // namespace safe_browsing | 151 } // namespace safe_browsing |
| OLD | NEW |