diff options
author | mmentovai <mmentovai@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2007-05-31 19:44:52 +0000 |
---|---|---|
committer | mmentovai <mmentovai@4c0a9323-5329-0410-9bdc-e9ce6186880e> | 2007-05-31 19:44:52 +0000 |
commit | 2e0e2234b9e9d7d82c4c3c20396bdf8f18007e6c (patch) | |
tree | c6c1c415720fcaffed1f224b4e1fda7c86267565 /src/processor | |
parent | Check allocation and array sizes in minidump.cc (#12). r=bryner (diff) | |
download | breakpad-2e0e2234b9e9d7d82c4c3c20396bdf8f18007e6c.tar.xz |
Allow building with -pedantic (#186). r=ted.mielczarek
http://groups.google.com/group/google-breakpad-dev/browse_thread/thread/6aa39d7f0ffa3c42
git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@183 4c0a9323-5329-0410-9bdc-e9ce6186880e
Diffstat (limited to 'src/processor')
-rw-r--r-- | src/processor/logging.h | 2 | ||||
-rw-r--r-- | src/processor/minidump.cc | 38 | ||||
-rw-r--r-- | src/processor/minidump_stackwalk.cc | 10 |
3 files changed, 25 insertions, 25 deletions
diff --git a/src/processor/logging.h b/src/processor/logging.h index 40738836..b638ff58 100644 --- a/src/processor/logging.h +++ b/src/processor/logging.h @@ -72,7 +72,7 @@ class LogStream { public: enum Severity { SEVERITY_INFO, - SEVERITY_ERROR, + SEVERITY_ERROR }; // Begin logging a message to the stream identified by |stream|, at the diff --git a/src/processor/minidump.cc b/src/processor/minidump.cc index ed0ba365..3548fb95 100644 --- a/src/processor/minidump.cc +++ b/src/processor/minidump.cc @@ -106,15 +106,13 @@ static inline void Swap(u_int32_t* value) { } -static inline void Swap(u_int64_t* value) { - *value = (*value >> 56) | - ((*value >> 40) & 0x000000000000ff00LL) | - ((*value >> 24) & 0x0000000000ff0000LL) | - ((*value >> 8) & 0x00000000ff000000LL) | - ((*value << 8) & 0x000000ff00000000LL) | - ((*value << 24) & 0x0000ff0000000000LL) | - ((*value << 40) & 0x00ff000000000000LL) | - (*value << 56); +static void Swap(u_int64_t* value) { + u_int32_t* value32 = reinterpret_cast<u_int32_t*>(value); + Swap(&value32[0]); + Swap(&value32[1]); + u_int32_t temp = value32[0]; + value32[0] = value32[1]; + value32[1] = temp; } @@ -1392,7 +1390,7 @@ string MinidumpModule::debug_file() const { // if misc_record->data is 0-terminated, so use an explicit size. file = string( reinterpret_cast<const char*>(misc_record->data), - module_.misc_record.data_size - sizeof(MDImageDebugMisc)); + module_.misc_record.data_size - MDImageDebugMisc_minsize); } else { // There's a misc_record but it encodes the debug filename in UTF-16. // (Actually, because miscellaneous records are so old, it's probably @@ -1401,7 +1399,7 @@ string MinidumpModule::debug_file() const { // return. unsigned int bytes = - module_.misc_record.data_size - sizeof(MDImageDebugMisc); + module_.misc_record.data_size - MDImageDebugMisc_minsize; if (bytes % 2 == 0) { unsigned int utf16_words = bytes / 2; @@ -1559,7 +1557,7 @@ const u_int8_t* MinidumpModule::GetCVRecord(u_int32_t* size) { // problems. x86 and ppc are able to cope, though. This allocation // style is needed because the MDCVInfoPDB70 or MDCVInfoPDB20 are // variable-sized due to their pdb_file_name fields; these structures - // are not sizeof(MDCVInfoPDB70) or sizeof(MDCVInfoPDB20) and treating + // are not MDCVInfoPDB70_minsize or MDCVInfoPDB20_minsize and treating // them as such would result in incomplete structures or overruns. scoped_ptr< vector<u_int8_t> > cv_record( new vector<u_int8_t>(module_.cv_record.data_size)); @@ -1580,9 +1578,9 @@ const u_int8_t* MinidumpModule::GetCVRecord(u_int32_t* size) { if (signature == MD_CVINFOPDB70_SIGNATURE) { // Now that the structure type is known, recheck the size. - if (sizeof(MDCVInfoPDB70) > module_.cv_record.data_size) { + if (MDCVInfoPDB70_minsize > module_.cv_record.data_size) { BPLOG(ERROR) << "MinidumpModule CodeView7 record size mismatch, " << - sizeof(MDCVInfoPDB70) << " > " << + MDCVInfoPDB70_minsize << " > " << module_.cv_record.data_size; return NULL; } @@ -1606,9 +1604,9 @@ const u_int8_t* MinidumpModule::GetCVRecord(u_int32_t* size) { } } else if (signature == MD_CVINFOPDB20_SIGNATURE) { // Now that the structure type is known, recheck the size. - if (sizeof(MDCVInfoPDB20) > module_.cv_record.data_size) { + if (MDCVInfoPDB20_minsize > module_.cv_record.data_size) { BPLOG(ERROR) << "MinidumpModule CodeView2 record size mismatch, " << - sizeof(MDCVInfoPDB20) << " > " << + MDCVInfoPDB20_minsize << " > " << module_.cv_record.data_size; return NULL; } @@ -1662,9 +1660,9 @@ const MDImageDebugMisc* MinidumpModule::GetMiscRecord(u_int32_t* size) { return NULL; } - if (sizeof(MDImageDebugMisc) > module_.misc_record.data_size) { + if (MDImageDebugMisc_minsize > module_.misc_record.data_size) { BPLOG(ERROR) << "MinidumpModule miscellaneous debugging record " - "size mismatch, " << sizeof(MDImageDebugMisc) << " > " << + "size mismatch, " << MDImageDebugMisc_minsize << " > " << module_.misc_record.data_size; return NULL; } @@ -1686,7 +1684,7 @@ const MDImageDebugMisc* MinidumpModule::GetMiscRecord(u_int32_t* size) { // is allocated as u_int8_t[] can cause alignment problems. x86 and // ppc are able to cope, though. This allocation style is needed // because the MDImageDebugMisc is variable-sized due to its data field; - // this structure is not sizeof(MDImageDebugMisc) and treating it as such + // this structure is not MDImageDebugMisc_minsize and treating it as such // would result in an incomplete structure or an overrun. scoped_ptr< vector<u_int8_t> > misc_record_mem( new vector<u_int8_t>(module_.misc_record.data_size)); @@ -1710,7 +1708,7 @@ const MDImageDebugMisc* MinidumpModule::GetMiscRecord(u_int32_t* size) { // in practice due to the layout of MDImageDebugMisc. u_int16_t* data16 = reinterpret_cast<u_int16_t*>(&(misc_record->data)); unsigned int dataBytes = module_.misc_record.data_size - - sizeof(MDImageDebugMisc); + MDImageDebugMisc_minsize; unsigned int dataLength = dataBytes / 2; for (unsigned int characterIndex = 0; characterIndex < dataLength; diff --git a/src/processor/minidump_stackwalk.cc b/src/processor/minidump_stackwalk.cc index 01b601c7..35f0aa27 100644 --- a/src/processor/minidump_stackwalk.cc +++ b/src/processor/minidump_stackwalk.cc @@ -233,7 +233,7 @@ static void PrintModules(const CodeModules *modules) { printf("\n"); printf("Loaded modules:\n"); - u_int64_t main_address = 0xffffffffffffffffLL; + u_int64_t main_address = 0; const CodeModule *main_module = modules->GetMainModule(); if (main_module) { main_address = main_module->base_address(); @@ -249,7 +249,8 @@ static void PrintModules(const CodeModules *modules) { base_address, base_address + module->size() - 1, PathnameStripper::File(module->code_file()).c_str(), module->version().empty() ? "???" : module->version().c_str(), - base_address == main_address ? " (main)" : ""); + main_module != NULL && base_address == main_address ? + " (main)" : ""); } } @@ -262,7 +263,7 @@ static void PrintModulesMachineReadable(const CodeModules *modules) { if (!modules) return; - u_int64_t main_address = 0xffffffffffffffffLL; + u_int64_t main_address = 0; const CodeModule *main_module = modules->GetMainModule(); if (main_module) { main_address = main_module->base_address(); @@ -284,7 +285,8 @@ static void PrintModulesMachineReadable(const CodeModules *modules) { StripSeparator(module->debug_identifier()).c_str(), kOutputSeparator, base_address, kOutputSeparator, base_address + module->size() - 1, - kOutputSeparator, base_address == main_address ? 1 : 0); + kOutputSeparator, + main_module != NULL && base_address == main_address ? 1 : 0); } } |