From 9a406c8279f3a968898c7f8889c39bca628c1e22 Mon Sep 17 00:00:00 2001 From: Florian Krohm Date: Sat, 27 Sep 2014 18:01:19 +0000 Subject: [PATCH] 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. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@14580 --- coregrind/m_commandline.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/coregrind/m_commandline.c b/coregrind/m_commandline.c index 3a4c271429..7ac4969012 100644 --- a/coregrind/m_commandline.c +++ b/coregrind/m_commandline.c @@ -59,10 +59,13 @@ static HChar* read_dot_valgrindrc ( const HChar* dir ) 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 ); -- 2.47.2