diff options
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | ruby.c | 6 |
2 files changed, 8 insertions, 3 deletions
@@ -1,3 +1,8 @@ +Wed Mar 11 06:12:47 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> + + * ruby.c (ruby_init_loadpath_safe): expands libpath and removes + last /lib. + Wed Mar 11 04:47:47 2009 Nobuyoshi Nakada <nobu@ruby-lang.org> * time.c (time_to_i, time_hash): time_t may be bigger than long @@ -348,15 +348,15 @@ ruby_init_loadpath_safe(int safe_level) char *p; int baselen; - libpath[0] = '\0'; #if defined _WIN32 || defined __CYGWIN__ GetModuleFileName(libruby, libpath, sizeof libpath); #elif defined(__EMX__) _execname(libpath, sizeof(libpath) - 1); #elif defined(HAVE_DLADDR) Dl_info dli; + libpath[0] = '\0'; if (dladdr(expand_include_path, &dli)) { - strlcpy(libpath, dli.dli_fname, sizeof(libpath)); + realpath(dli.dli_fname, libpath); } #endif @@ -373,7 +373,7 @@ ruby_init_loadpath_safe(int safe_level) p = strrchr(libpath, '/'); if (p) { *p = 0; - if (p - libpath > 3 && !STRCASECMP(p - 4, "/bin")) { + if (p - libpath > 3 && !(STRCASECMP(p - 4, "/bin") && strcmp(p - 4, "/lib"))) { p -= 4; *p = 0; } |