]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Fix BZ #327212. Check for absolute path name at the end of
authorFlorian Krohm <florian@eich-krohm.de>
Wed, 19 Feb 2014 11:16:00 +0000 (11:16 +0000)
committerFlorian Krohm <florian@eich-krohm.de>
Wed, 19 Feb 2014 11:16:00 +0000 (11:16 +0000)
expand_file_name -- not at the beginning.

git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13816

NEWS
coregrind/m_options.c
docs/internals/3_9_BUGSTATUS.txt

diff --git a/NEWS b/NEWS
index c0517932da1d45acd2389237c4a1efdc36550c9a..4ffd3af414aac5316c16b5f7ab0f90f6620f837f 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,7 @@ where XXXXXX is the bug number as listed below.
 326444  Cavium MIPS Octeon Specific Load Indexed Instructions
 326462  Refactor vgdb to isolate invoker stuff into separate module
 326983  Clear direction flag after tests on amd64.
+327212  Do not prepend the current directory to absolute path names.
 327238  Callgrind Assertion 'passed <= last_bb->cjmp_count' failed
 327284  s390x: Fix translation of the risbg instruction
 327837  dwz compressed alternate .debug_info and .debug_str not read correctly
index 4aaa52c8f72e87edadee278c80070877453b8de3..78ffe9d6ad7c0918aa25c76bb66c6f7a52f9bf24 100644 (file)
@@ -168,18 +168,8 @@ HChar* VG_(expand_file_name)(const HChar* option_name, const HChar* format)
       goto bad;
    }
 
-   // If 'format' starts with a '/', do not prefix with startup dir.
-   if (format[0] != '/') {
-      j += VG_(strlen)(base_dir);
-   }
-
-   // The 10 is slop, it should be enough in most cases.
-   len = j + VG_(strlen)(format) + 10;
+   len = VG_(strlen)(format) + 1;
    out = VG_(malloc)( "options.efn.1", len );
-   if (format[0] != '/') {
-      VG_(strcpy)(out, base_dir);
-      out[j++] = '/';
-   }
 
 #define ENSURE_THIS_MUCH_SPACE(x) \
    if (j + x >= len) { \
@@ -261,6 +251,18 @@ HChar* VG_(expand_file_name)(const HChar* option_name, const HChar* format)
    ENSURE_THIS_MUCH_SPACE(1);
    out[j++] = 0;
 
+   // If 'out' is not an absolute path name, prefix it with the startup dir.
+   if (out[0] != '/') {
+      len = VG_(strlen)(base_dir) + 1 + VG_(strlen)(out) + 1;
+
+      HChar *absout = VG_(malloc)("options.efn.4", len);
+      VG_(strcpy)(absout, base_dir);
+      VG_(strcat)(absout, "/");
+      VG_(strcat)(absout, out);
+      VG_(free)(out);
+      out = absout;
+   }
+
    return out;
 
   bad: {
index 044815353045b3f4c35f06cc68216826cf7fd9f4..e960e5b4789ecb832b2be17a5f7814aff2e5b0db 100644 (file)
@@ -38,7 +38,6 @@ For bugs reported before this time, see 3_8_BUGSTATUS.txt
 327138  valgrind.h __VALGRIND_MINOR__  says 8, in 3.9.0 tarball
 327151  valgrind appears to stop compiling when it enters the drd directory
 327155  Valgrind compilation hang on MIPS
-327212  expand_file_name prepends current directory when expansion starts with /
 327223  Support for Cavium MIPS Octeon Atomic and Count Instructions
 327238  assertion failure in Callgrind: bbcc.c:585 (vgCallgrind_setup_bbcc): Assertion 'passed <= last_bb->cjmp_count' failed
 327284  s390x VEX miscompilation of -march=z10 binary