Skip to content

Commit

Permalink
Fix an assertion encountered in UntypedMDRVA::Copy().
Browse files Browse the repository at this point in the history
Fix an assertion where a zero-length buffer was being passed to
UntypedMDRVA::Copy().  This occurred when WriteFile() was given a file whose
size was a multiple of the temporary buffer size.  In this issue's case, the
procfs file "environ" happened to be 2032 bytes, while the temporary buffer
was 1016 bytes.

Patch by Michael Krebs <mkrebs@chromium.org>


git-svn-id: http://google-breakpad.googlecode.com/svn@792 4c0a9323-5329-0410-9bdc-e9ce6186880e
  • Loading branch information
mmentovai committed Jul 1, 2011
1 parent 23dd927 commit e462a1e
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions trunk/src/client/linux/minidump_writer/minidump_writer.cc
Expand Up @@ -1212,6 +1212,15 @@ class MinidumpWriter {
if (!memory.Allocate(total))
return false;
for (MDRVA pos = memory.position(); buffers; buffers = buffers->next) {
// Check for special case of a zero-length buffer. This should only
// occur if a file's size happens to be a multiple of the buffer's
// size, in which case the final sys_read() will have resulted in
// zero bytes being read after the final buffer was just allocated.
if (buffers->len == 0) {
// This can only occur with final buffer.
assert(buffers->next == NULL);
continue;
}
memory.Copy(pos, &buffers->data, buffers->len);
pos += buffers->len;
}
Expand Down

0 comments on commit e462a1e

Please sign in to comment.