https://bugs.kde.org/show_bug.cgi?id=387773

Mark Wielaard <m...@klomp.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
     Ever confirmed|0                           |1
         Resolution|FIXED                       |---

--- Comment #2 from Mark Wielaard <m...@klomp.org> ---
This is still not completely correct. If the symlink itself contains a relative
path then we need to add the symlink dir before it. Something like the
following:

diff --git a/coregrind/m_debuginfo/readelf.c b/coregrind/m_debuginfo/readelf.c
index c19ff212b..70c28e629 100644
--- a/coregrind/m_debuginfo/readelf.c
+++ b/coregrind/m_debuginfo/readelf.c
@@ -1582,6 +1582,24 @@ static HChar* readlink_path (const HChar *path)
       return NULL;
    }

+  if (buf[0] == '/')
+    return buf;
+
+  /* Relative path, add link dir.  */
+  HChar *linkdirptr;
+  SizeT linkdir_len = VG_(strlen)(path);
+  if ((linkdirptr = VG_(strrchr)(path, '/')) != NULL)
+    linkdir_len -= VG_(strlen)(linkdirptr + 1);
+
+  SizeT buflen = VG_(strlen)(buf);
+  SizeT needed = linkdir_len + buflen + 1;
+  if (bufsiz < needed)
+    buf = ML_(dinfo_realloc)("readlink_path.linkdir", buf, needed);
+
+  VG_(memmove)(buf + linkdir_len, buf, buflen);
+  VG_(memcpy)(buf, path, linkdir_len);
+  buf[needed - 1] = '\0';
+
   return buf;
 }

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to