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

Side by Side Diff: components/metrics/public/cpp/call_stack_profile_struct_traits.h

Issue 2532243002: Stack sampling profiler: fix module read validation failures (Closed)
Patch Set: Created 4 years 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 | components/metrics/public/cpp/call_stack_profile_struct_traits_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 // Defines StructTraits specializations for translating between mojo types and 5 // Defines StructTraits specializations for translating between mojo types and
6 // base::StackSamplingProfiler types, with data validity checks. 6 // base::StackSamplingProfiler types, with data validity checks.
7 7
8 #ifndef COMPONENTS_METRICS_CALL_STACK_PROFILE_STRUCT_TRAITS_H_ 8 #ifndef COMPONENTS_METRICS_CALL_STACK_PROFILE_STRUCT_TRAITS_H_
9 #define COMPONENTS_METRICS_CALL_STACK_PROFILE_STRUCT_TRAITS_H_ 9 #define COMPONENTS_METRICS_CALL_STACK_PROFILE_STRUCT_TRAITS_H_
10 10
(...skipping 16 matching lines...) Expand all
27 const base::StackSamplingProfiler::Module& module) { 27 const base::StackSamplingProfiler::Module& module) {
28 return module.id; 28 return module.id;
29 } 29 }
30 static const base::FilePath& filename( 30 static const base::FilePath& filename(
31 const base::StackSamplingProfiler::Module& module) { 31 const base::StackSamplingProfiler::Module& module) {
32 return module.filename; 32 return module.filename;
33 } 33 }
34 34
35 static bool Read(metrics::mojom::CallStackModuleDataView data, 35 static bool Read(metrics::mojom::CallStackModuleDataView data,
36 base::StackSamplingProfiler::Module* out) { 36 base::StackSamplingProfiler::Module* out) {
37 // Linux has the longest build id at 40 bytes.
38 static const size_t kMaxIDSize = 40;
39
40 std::string id; 37 std::string id;
41 base::FilePath filename; 38 base::FilePath filename;
42 if (!data.ReadId(&id) || id.size() > kMaxIDSize || 39 if (!data.ReadId(&id) || !data.ReadFilename(&filename))
43 !data.ReadFilename(&filename))
44 return false; 40 return false;
45 41
46 *out = 42 *out =
47 base::StackSamplingProfiler::Module(data.base_address(), id, filename); 43 base::StackSamplingProfiler::Module(data.base_address(), id, filename);
48 return true; 44 return true;
49 } 45 }
50 }; 46 };
51 47
52 template <> 48 template <>
53 struct StructTraits<metrics::mojom::CallStackFrameDataView, 49 struct StructTraits<metrics::mojom::CallStackFrameDataView,
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 metrics::CallStackProfileParams::SampleOrderingSpec::PRESERVE_ORDER; 360 metrics::CallStackProfileParams::SampleOrderingSpec::PRESERVE_ORDER;
365 return true; 361 return true;
366 } 362 }
367 return false; 363 return false;
368 } 364 }
369 }; 365 };
370 366
371 } // mojo 367 } // mojo
372 368
373 #endif // COMPONENTS_METRICS_CALL_STACK_PROFILE_STRUCT_TRAITS_H_ 369 #endif // COMPONENTS_METRICS_CALL_STACK_PROFILE_STRUCT_TRAITS_H_
OLDNEW
« no previous file with comments | « no previous file | components/metrics/public/cpp/call_stack_profile_struct_traits_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698