|
From: <sv...@va...> - 2014-07-30 11:42:46
|
Author: florian
Date: Wed Jul 30 11:42:38 2014
New Revision: 14208
Log:
In read_dot_valgrindrc use a large enough buffer allocated on the
stack.
Also assert that the passed in directory is not NULL. This is
true at all call sites. The old code would have attempted to read
/.valgrindrc for dir == NULL and I don't think we want that.
Modified:
branches/BUF_REMOVAL/coregrind/m_commandline.c
Modified: branches/BUF_REMOVAL/coregrind/m_commandline.c
==============================================================================
--- branches/BUF_REMOVAL/coregrind/m_commandline.c (original)
+++ branches/BUF_REMOVAL/coregrind/m_commandline.c Wed Jul 30 11:42:38 2014
@@ -59,10 +59,13 @@
SysRes fd;
struct vg_stat stat_buf;
HChar* f_clo = NULL;
- HChar filename[VKI_PATH_MAX];
+ const HChar dot_valgrindrc[] = ".valgrindrc";
+
+ vg_assert(dir != NULL);
+
+ HChar filename[VG_(strlen)(dir) + 1 + VG_(strlen)(dot_valgrindrc) + 1];
+ VG_(sprintf)(filename, "%s/%s", dir, dot_valgrindrc);
- VG_(snprintf)(filename, VKI_PATH_MAX, "%s/.valgrindrc",
- ( NULL == dir ? "" : dir ) );
fd = VG_(open)(filename, 0, VKI_S_IRUSR);
if ( !sr_isError(fd) ) {
Int res = VG_(fstat)( sr_Res(fd), &stat_buf );
|