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 a5019735-40e9-0310-863c-91ae7b9d1cf9
diff --git a/NEWS b/NEWS
index c051793..4ffd3af 100644
--- a/NEWS
+++ b/NEWS
@@ -39,6 +39,7 @@
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 4aaa52c..78ffe9d 100644
--- a/coregrind/m_options.c
+++ b/coregrind/m_options.c
@@ -168,18 +168,8 @@
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 @@
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 0448153..e960e5b 100644
--- a/docs/internals/3_9_BUGSTATUS.txt
+++ b/docs/internals/3_9_BUGSTATUS.txt
@@ -38,7 +38,6 @@
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