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

Side by Side Diff: minidump/test/minidump_writable_test_util.cc

Issue 708803002: minidump: stronger checking for MinidumpWritableAtRVA<>() (Closed) Base URL: https://chromium.googlesource.com/crashpad/crashpad@master
Patch Set: Created 6 years, 1 month 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 | « minidump/test/minidump_writable_test_util.h ('k') | 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 2014 The Crashpad Authors. All rights reserved. 1 // Copyright 2014 The Crashpad Authors. All rights reserved.
2 // 2 //
3 // Licensed under the Apache License, Version 2.0 (the "License"); 3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License. 4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at 5 // You may obtain a copy of the License at
6 // 6 //
7 // http://www.apache.org/licenses/LICENSE-2.0 7 // http://www.apache.org/licenses/LICENSE-2.0
8 // 8 //
9 // Unless required by applicable law or agreed to in writing, software 9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS, 10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and 12 // See the License for the specific language governing permissions and
13 // limitations under the License. 13 // limitations under the License.
14 14
15 #include "minidump/test/minidump_writable_test_util.h" 15 #include "minidump/test/minidump_writable_test_util.h"
16 16
17 #include <string> 17 #include <string>
18 18
19 #include "base/strings/string16.h" 19 #include "base/strings/string16.h"
20 #include "gtest/gtest.h" 20 #include "gtest/gtest.h"
21 21
22 namespace crashpad { 22 namespace crashpad {
23 namespace test { 23 namespace test {
24 24
25 namespace {
26
27 //! \brief Returns an untyped minidump object located within a minidump file’s
28 //! contents, where the offset of the object is known.
29 //!
30 //! \param[in] file_contents The contents of the minidump file.
31 //! \param[in] rva The offset within the minidump file of the desired object.
32 //!
33 //! \return If \a rva is within the range of \a file_contents, returns a pointer
34 //! into \a file_contents at offset \a rva. Otherwise, raises a gtest
35 //! assertion failure and returns `nullptr`.
36 //!
37 //! Do not call this function. Use the typed version, MinidumpWritableAtRVA<>(),
38 //! or another type-specific function.
25 const void* MinidumpWritableAtRVAInternal(const std::string& file_contents, 39 const void* MinidumpWritableAtRVAInternal(const std::string& file_contents,
26 RVA rva) { 40 RVA rva) {
27 if (rva >= file_contents.size()) { 41 if (rva >= file_contents.size()) {
28 EXPECT_LT(rva, file_contents.size()); 42 EXPECT_LT(rva, file_contents.size());
29 return nullptr; 43 return nullptr;
30 } 44 }
31 45
32 return &file_contents[rva]; 46 return &file_contents[rva];
33 } 47 }
34 48
49 } // namespace
50
35 const void* MinidumpWritableAtLocationDescriptorInternal( 51 const void* MinidumpWritableAtLocationDescriptorInternal(
36 const std::string& file_contents, 52 const std::string& file_contents,
37 const MINIDUMP_LOCATION_DESCRIPTOR& location, 53 const MINIDUMP_LOCATION_DESCRIPTOR& location,
38 size_t expected_size, 54 size_t expected_size,
39 bool allow_oversized_data) { 55 bool allow_oversized_data) {
40 if (location.DataSize == 0) { 56 if (location.DataSize == 0) {
41 EXPECT_EQ(0u, location.Rva); 57 EXPECT_EQ(0u, location.Rva);
42 return nullptr; 58 return nullptr;
43 } 59 }
44 60
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 const MinidumpModuleCodeViewRecordPDB70* 299 const MinidumpModuleCodeViewRecordPDB70*
284 MinidumpWritableAtLocationDescriptor<MinidumpModuleCodeViewRecordPDB70>( 300 MinidumpWritableAtLocationDescriptor<MinidumpModuleCodeViewRecordPDB70>(
285 const std::string& file_contents, 301 const std::string& file_contents,
286 const MINIDUMP_LOCATION_DESCRIPTOR& location) { 302 const MINIDUMP_LOCATION_DESCRIPTOR& location) {
287 return MinidumpCVPDBAtLocationDescriptor<MinidumpModuleCodeViewRecordPDB70>( 303 return MinidumpCVPDBAtLocationDescriptor<MinidumpModuleCodeViewRecordPDB70>(
288 file_contents, location); 304 file_contents, location);
289 } 305 }
290 306
291 } // namespace test 307 } // namespace test
292 } // namespace crashpad 308 } // namespace crashpad
OLDNEW
« no previous file with comments | « minidump/test/minidump_writable_test_util.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698