From: Florian Krohm Date: Wed, 19 Feb 2014 11:16:00 +0000 (+0000) Subject: Fix BZ #327212. Check for absolute path name at the end of X-Git-Tag: svn/VALGRIND_3_10_0~620 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bc1f32fb679e84afaafda6150c48cbed7c9cf02c;p=thirdparty%2Fvalgrind.git Fix BZ #327212. Check for absolute path name at the end of expand_file_name -- not at the beginning. git-svn-id: svn://svn.valgrind.org/valgrind/trunk@13816 --- diff --git a/NEWS b/NEWS index c0517932da..4ffd3af414 100644 --- 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 diff --git a/coregrind/m_options.c b/coregrind/m_options.c index 4aaa52c8f7..78ffe9d6ad 100644 --- a/coregrind/m_options.c +++ b/coregrind/m_options.c @@ -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: { diff --git a/docs/internals/3_9_BUGSTATUS.txt b/docs/internals/3_9_BUGSTATUS.txt index 0448153530..e960e5b478 100644 --- a/docs/internals/3_9_BUGSTATUS.txt +++ b/docs/internals/3_9_BUGSTATUS.txt @@ -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