* Do not try to recreate the path of a preloaded module if a full path has been

passed in by the boot loader.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@27686 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2008-09-22 09:13:30 +00:00
parent 18ee966f0a
commit 8c8b846226
+22 -13
View File
@@ -1085,25 +1085,32 @@ register_preloaded_module_image(struct preloaded_image* image)
image->is_module = true; image->is_module = true;
if (moduleImage->info[0] == NULL) {
status = B_BAD_DATA;
goto error;
}
moduleImage->dependencies = NULL; moduleImage->dependencies = NULL;
get_image_symbol(image->id, "module_dependencies", B_SYMBOL_TYPE_DATA, get_image_symbol(image->id, "module_dependencies", B_SYMBOL_TYPE_DATA,
(void**)&moduleImage->dependencies); (void**)&moduleImage->dependencies);
// this is allowed to be NULL // this is allowed to be NULL
// Try to recreate the full module path, so that we don't try to load the if (image->name[0] != '/') {
// image again when asked for a module it does not export (would only be // Try to recreate the full module path, so that we don't try to load
// problematic if it had got replaced and the new file actually exports // the image again when asked for a module it does not export (would
// that module). Also helpful for recurse_directory(). // only be problematic if it had got replaced and the new file actually
{ // exports that module). Also helpful for recurse_directory().
// ToDo: this is kind of a hack to have the full path in the hash
// TODO: check if there is a situation (like floppy/network boot) where
// relative paths are still passed in.
// TODO: this is kind of a hack to have the full path in the hash
// (it always assumes the preloaded add-ons to be in the system // (it always assumes the preloaded add-ons to be in the system
// directory) // directory)
char path[B_FILE_NAME_LENGTH]; const char* name = moduleImage->info[0]->name;
const char* suffix; const char* suffix = strstr(name, image->name);
const char* name; if (suffix != NULL) {
if (moduleImage->info[0] char path[B_FILE_NAME_LENGTH];
&& (suffix = strstr(name = moduleImage->info[0]->name,
image->name)) != NULL) {
// even if strlcpy() is used here, it's by no means safe // even if strlcpy() is used here, it's by no means safe
// against buffer overflows // against buffer overflows
KPath addonsKernelPath; KPath addonsKernelPath;
@@ -1133,7 +1140,9 @@ register_preloaded_module_image(struct preloaded_image* image)
} }
} else } else
moduleImage->path = strdup(image->name); moduleImage->path = strdup(image->name);
} } else
moduleImage->path = strdup(image->name);
if (moduleImage->path == NULL) { if (moduleImage->path == NULL) {
status = B_NO_MEMORY; status = B_NO_MEMORY;
goto error; goto error;