changeset 38217:d52638985bec

relocatable: Fix that /@unixroot prefix is not working on OS/2 kLIBC OS/2 kLIBC has a feature to rewrite some path components. For example, '/@unixroot' is replaced with a value of $UNIXROOT if it is. So prepending a drive letter to the path starting with '/' makes the path starting with '/@unixroot' to 'x:/@unixroot' which is unexpected. This will breaks the behavior of some programs depending on /@unixroot prefix. * lib/relocatable.c (relocate): Do not touch pathname if it is started with '/@unixroot'.
author KO Myung-Hun <komh78@gmail.com>
date Thu, 01 Dec 2016 19:52:44 +0900
parents 06066d898505
children 5bc20d24ba69
files ChangeLog lib/relocatable.c
diffstat 2 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Thu Dec 01 19:52:43 2016 +0900
+++ b/ChangeLog	Thu Dec 01 19:52:44 2016 +0900
@@ -1,3 +1,9 @@
+2016-12-01  KO Myung-Hun  <komh78@gmail.com>
+
+	relocatable: Fix that /@unixroot prefix is not working on OS/2 kLIBC
+	* lib/relocatable.c (relocate): Do not touch pathname if it is started
+	with '/@unixroot'.
+
 2016-12-01  KO Myung-Hun  <komh78@gmail.com>
 
 	sys_socket: typedef sa_family_t correctly on OS/2 kLIBC
--- a/lib/relocatable.c	Thu Dec 01 19:52:43 2016 +0900
+++ b/lib/relocatable.c	Thu Dec 01 19:52:44 2016 +0900
@@ -539,6 +539,18 @@
     }
 
 #ifdef __EMX__
+# ifdef __KLIBC__
+#  undef strncmp
+
+  if (pathname && strncmp (pathname, "/@unixroot", 10) == 0
+      && (pathname[10] == '\0' || pathname[10] == '/' || pathname[10] == '\\'))
+    {
+      /* kLIBC itself processes /@unixroot prefix */
+
+      return pathname;
+    }
+  else
+# endif
   if (pathname && ISSLASH (pathname[0]))
     {
       const char *unixroot = getenv ("UNIXROOT");