[google-breakpad] r1187 committed - Fixing several instances of std::vector::operator[] out of range acces...

0 views
Skip to first unread message

google-...@googlecode.com

unread,
May 21, 2013, 1:05:41 PM5/21/13
to google-br...@googlegroups.com
Revision: 1187
Author: ivan....@gmail.com
Date: Tue May 21 10:05:35 2013
Log: Fixing several instances of std::vector::operator[] out of range
access
Review URL: https://breakpad.appspot.com/597002
http://code.google.com/p/google-breakpad/source/detail?r=1187

Modified:
/trunk/src/client/linux/minidump_writer/linux_dumper.cc
/trunk/src/client/linux/minidump_writer/minidump_writer.cc

=======================================
--- /trunk/src/client/linux/minidump_writer/linux_dumper.cc Fri May 17
12:50:00 2013
+++ /trunk/src/client/linux/minidump_writer/linux_dumper.cc Tue May 21
10:05:35 2013
@@ -77,6 +77,9 @@
threads_(&allocator_, 8),
mappings_(&allocator_),
auxv_(&allocator_, AT_MAX + 1) {
+ // The passed-in size to the constructor (above) is only a hint.
+ // Must call .resize() to do actual initialization of the elements.
+ auxv_.resize(AT_MAX + 1);
}

LinuxDumper::~LinuxDumper() {
@@ -90,8 +93,7 @@
LinuxDumper::ElfFileIdentifierForMapping(const MappingInfo& mapping,
bool member,
unsigned int mapping_id,
- uint8_t
identifier[sizeof(MDGUID)])
-{
+ uint8_t
identifier[sizeof(MDGUID)]) {
assert(!member || mapping_id < mappings_.size());
my_memset(identifier, 0, sizeof(MDGUID));
if (IsMappedFileOpenUnsafe(mapping))
@@ -273,7 +275,8 @@
const MappingInfo* mapping = FindMapping(stack_pointer);
if (!mapping)
return false;
- const ptrdiff_t offset = stack_pointer - (uint8_t*) mapping->start_addr;
+ const ptrdiff_t offset = stack_pointer -
+ reinterpret_cast<uint8_t*>(mapping->start_addr);
const ptrdiff_t distance_to_end =
static_cast<ptrdiff_t>(mapping->size) - offset;
*stack_len = distance_to_end > kStackToCapture ?
=======================================
--- /trunk/src/client/linux/minidump_writer/minidump_writer.cc Wed Apr 24
03:06:14 2013
+++ /trunk/src/client/linux/minidump_writer/minidump_writer.cc Tue May 21
10:05:35 2013
@@ -1127,8 +1127,8 @@
return false;
MDRawLinkMap entry;
entry.name = location.rva;
- entry.addr = (void*)map.l_addr;
- entry.ld = (void*)map.l_ld;
+ entry.addr = reinterpret_cast<void*>(map.l_addr);
+ entry.ld = reinterpret_cast<void*>(map.l_ld);
linkmap.CopyIndex(idx++, &entry);
}
}
@@ -1144,11 +1144,14 @@
debug.get()->version = debug_entry.r_version;
debug.get()->map = linkmap_rva;
debug.get()->dso_count = dso_count;
- debug.get()->brk = (void*)debug_entry.r_brk;
- debug.get()->ldbase = (void*)debug_entry.r_ldbase;
+ debug.get()->brk = reinterpret_cast<void*>(debug_entry.r_brk);
+ debug.get()->ldbase = reinterpret_cast<void*>(debug_entry.r_ldbase);
debug.get()->dynamic = dynamic;

wasteful_vector<char> dso_debug_data(dumper_->allocator(),
dynamic_length);
+ // The passed-in size to the constructor (above) is only a hint.
+ // Must call .resize() to do actual initialization of the elements.
+ dso_debug_data.resize(dynamic_length);
dumper_->CopyFromProcess(&dso_debug_data[0], GetCrashThread(), dynamic,
dynamic_length);
debug.CopyIndexAfterObject(0, &dso_debug_data[0], dynamic_length);
@@ -1420,10 +1423,11 @@
const char* p = value;
if (value[0] == '0' && value[1] == 'x') {
p = my_read_hex_ptr(&result, value+2);
- } else if (entry->format == 'x')
+ } else if (entry->format == 'x') {
p = my_read_hex_ptr(&result, value);
- else
+ } else {
p = my_read_decimal_ptr(&result, value);
+ }
if (p == value)
continue;

Reply all
Reply to author
Forward
0 new messages