From 6918dbf421520a3442a95995ccfb1393b027f506 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Fri, 8 Feb 2008 03:18:26 +0000 Subject: [PATCH] Normalize the given image path in load_container(). Just constructing some absolute path was not enough to always recognize a library as already loaded. This fixes problems with Perl where loading an add-on would cause another instance of libperl.so to be loaded, which would lead to crashes due to uninitialized static vars in the new instance. Perl builds now and the tests run, but quite a few do fail. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@23930 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/system/runtime_loader/elf.cpp | 27 ++++----------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/src/system/runtime_loader/elf.cpp b/src/system/runtime_loader/elf.cpp index 5b95efaae0..bba4cd4dd6 100644 --- a/src/system/runtime_loader/elf.cpp +++ b/src/system/runtime_loader/elf.cpp @@ -997,29 +997,10 @@ load_container(char const *name, image_type type, const char *rpath, image_t **_ return fd; } - // If the path is not absolute, we prepend the CWD to make it one. - if (path[0] != '/') { - char relativePath[PATH_MAX]; - if (!strncmp(path, "./", 2)) - strcpy(relativePath, path + 2); - else - strcpy(relativePath, path); - - // get the CWD - status = _kern_getcwd(path, sizeof(path)); - if (status < B_OK) { - FATAL("_kern_getcwd() failed\n"); - goto err1; - } - - if (strlcat(path, "/", sizeof(path)) >= sizeof(path) - || strlcat(path, relativePath, sizeof(path)) >= sizeof(path)) { - status = B_NAME_TOO_LONG; - FATAL("Absolute path of image %s is too " - "long!\n", relativePath); - goto err1; - } - } + // normalize the image path + status = _kern_normalize_path(path, true, path); + if (status != B_OK) + goto err1; // Test again if this image has been registered already - this time, // we can check the full path, not just its name as noted.