From be55cc8cf05aace5e8769230e02b5948a0079496 Mon Sep 17 00:00:00 2001 From: mmentovai Date: Fri, 1 Jul 2011 01:20:27 +0000 Subject: [PATCH] Fix an assertion encountered in UntypedMDRVA::Copy(). 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 git-svn-id: http://google-breakpad.googlecode.com/svn/trunk@792 4c0a9323-5329-0410-9bdc-e9ce6186880e --- src/client/linux/minidump_writer/minidump_writer.cc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/client/linux/minidump_writer/minidump_writer.cc b/src/client/linux/minidump_writer/minidump_writer.cc index ee9adac0..77ff7ea2 100644 --- a/src/client/linux/minidump_writer/minidump_writer.cc +++ b/src/client/linux/minidump_writer/minidump_writer.cc @@ -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; }