]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Merge r14208 from BUF_REMOVAL branch to trunk.
authorFlorian Krohm <florian@eich-krohm.de>
Sat, 27 Sep 2014 18:01:19 +0000 (18:01 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Sat, 27 Sep 2014 18:01:19 +0000 (18:01 +0000)
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

index 3a4c271429e72bd55e0fe7d88e2750223613c898..7ac496901275b0959eb8cd135afe426704b98885 100644 (file)
@@ -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 );