|
From: <sv...@va...> - 2014-09-27 18:01:26
|
Author: florian
Date: Sat Sep 27 19:01:19 2014
New Revision: 14580
Log:
Merge r14208 from BUF_REMOVAL branch to trunk.
In function 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:
trunk/ (props changed)
trunk/coregrind/m_commandline.c
Modified: trunk/coregrind/m_commandline.c
==============================================================================
--- trunk/coregrind/m_commandline.c (original)
+++ trunk/coregrind/m_commandline.c Sat Sep 27 19:01:19 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 );
|