|
From: <sv...@va...> - 2008-05-25 16:25:44
|
Author: bart
Date: 2008-05-25 17:25:51 +0100 (Sun, 25 May 2008)
New Revision: 8126
Log:
Bug fixes (not in bugzilla):
- Make sure that Valgrind does not complain when it tries to read the
debug information of a file of size zero when such a file is mmap()'ed
into memory.
- Make sure the filename is included in the error message that is
printed when reading the debug information fails for a file that is mmap()'ed
into memory.
- Fixed assertion failure that was triggered by supplying an output
buffer to VG_(seginfo_sect_kind)() that is smaller than the filename
to be copied into that buffer.
Modified:
trunk/coregrind/m_debuginfo/debuginfo.c
Modified: trunk/coregrind/m_debuginfo/debuginfo.c
===================================================================
--- trunk/coregrind/m_debuginfo/debuginfo.c 2008-05-25 16:01:52 UTC (rev 8125)
+++ trunk/coregrind/m_debuginfo/debuginfo.c 2008-05-25 16:25:51 UTC (rev 8126)
@@ -538,9 +538,9 @@
VG_(memset)(buf1k, 0, sizeof(buf1k));
fd = VG_(open)( filename, VKI_O_RDONLY, 0 );
if (fd.isError) {
- DebugInfo fake_di;
if (fd.err != VKI_EACCES)
{
+ DebugInfo fake_di;
VG_(memset)(&fake_di, 0, sizeof(fake_di));
fake_di.filename = filename;
ML_(symerr)(&fake_di, True, "can't open file to inspect ELF header");
@@ -550,9 +550,14 @@
nread = VG_(read)( fd.res, buf1k, sizeof(buf1k) );
VG_(close)( fd.res );
- if (nread <= 0) {
- ML_(symerr)(NULL, True, "can't read file to inspect ELF header");
+ if (nread == 0)
return;
+ if (nread < 0) {
+ DebugInfo fake_di;
+ VG_(memset)(&fake_di, 0, sizeof(fake_di));
+ fake_di.filename = filename;
+ ML_(symerr)(&fake_di, True, "can't read file to inspect ELF header");
+ return;
}
vg_assert(nread > 0 && nread <= sizeof(buf1k) );
@@ -2325,13 +2330,13 @@
vg_assert(start_at < fnlen);
i = start_at; j = 0;
while (True) {
- vg_assert(j >= 0 && j+1 < n_name);
+ vg_assert(j >= 0 && j < n_name);
vg_assert(i >= 0 && i <= fnlen);
name[j] = di->filename[i];
- name[j+1] = 0;
if (di->filename[i] == 0) break;
i++; j++;
}
+ vg_assert(i == fnlen);
} else {
VG_(snprintf)(name, n_name, "%s", "???");
}
|