From bd71bdd74252585a1d567a480fa97e19884fa3fb Mon Sep 17 00:00:00 2001 From: "ivan.penkov@gmail.com" Date: Wed, 25 Sep 2013 18:25:13 +0000 Subject: Adding stricter validation checks to various symbol parser functions. More specifically, the validation of the following record types is improved: - FILE records - FUNC records - Line record - PUBLIC records Adding unittests. Review URL: https://breakpad.appspot.com/632003 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@1217 4c0a9323-5329-0410-9bdc-e9ce6186880e --- .../processor/basic_source_line_resolver.h | 58 ++++++++++++++++++++++ 1 file changed, 58 insertions(+) (limited to 'src/google_breakpad/processor') diff --git a/src/google_breakpad/processor/basic_source_line_resolver.h b/src/google_breakpad/processor/basic_source_line_resolver.h index c1946ca4..6bb6d863 100644 --- a/src/google_breakpad/processor/basic_source_line_resolver.h +++ b/src/google_breakpad/processor/basic_source_line_resolver.h @@ -81,6 +81,64 @@ class BasicSourceLineResolver : public SourceLineResolverBase { void operator=(const BasicSourceLineResolver&); }; +// Helper class, containing useful methods for parsing of Breakpad symbol files. +class SymbolParseHelper { + public: + // Parses a |file_line| declaration. Returns true on success. + // Format: FILE . + // Notice, that this method modifies the input |file_line| which is why it + // can't be const. On success, , and are stored in |*index|, + // and |*filename|. No allocation is done, |*filename| simply points inside + // |file_line|. + static bool ParseFile(char *file_line, // in + long *index, // out + char **filename); // out + + // Parses a |function_line| declaration. Returns true on success. + // Format: FUNC
. + // Notice, that this method modifies the input |function_line| which is why it + // can't be const. On success,
, , , and + // are stored in |*address|, |*size|, |*stack_param_size|, and |*name|. + // No allocation is done, |*name| simply points inside |function_line|. + static bool ParseFunction(char *function_line, // in + uint64_t *address, // out + uint64_t *size, // out + long *stack_param_size, // out + char **name); // out + + // Parses a |line| declaration. Returns true on success. + // Format:
+ // Notice, that this method modifies the input |function_line| which is why + // it can't be const. On success,
, , , and + // are stored in |*address|, |*size|, |*line_number|, and + // |*source_file|. + static bool ParseLine(char *line_line, // in + uint64_t *address, // out + uint64_t *size, // out + long *line_number, // out + long *source_file); // out + + // Parses a |public_line| declaration. Returns true on success. + // Format: PUBLIC
+ // Notice, that this method modifies the input |function_line| which is why + // it can't be const. On success,
, , + // are stored in |*address|, |*stack_param_size|, and |*name|. + // No allocation is done, |*name| simply points inside |public_line|. + static bool ParsePublicSymbol(char *public_line, // in + uint64_t *address, // out + long *stack_param_size, // out + char **name); // out + + private: + // Used for success checks after strtoull and strtol. + static bool IsValidAfterNumber(char *after_number); + + // Only allow static methods. + SymbolParseHelper(); + SymbolParseHelper(const SymbolParseHelper&); + void operator=(const SymbolParseHelper&); +}; + } // namespace google_breakpad #endif // GOOGLE_BREAKPAD_PROCESSOR_BASIC_SOURCE_LINE_RESOLVER_H__ -- cgit v1.2.1