Another patch by Vasilis Kaoutsis:
* Use find_directory() for the hash for preloaded modules. I am not sure this patch is needed, since it only concerns the hash. Please review. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@25511 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -950,7 +950,8 @@ register_preloaded_module_image(struct preloaded_image *image)
|
|||||||
// that module). Also helpful for recurse_directory().
|
// that module). Also helpful for recurse_directory().
|
||||||
{
|
{
|
||||||
// ToDo: this is kind of a hack to have the full path in the hash
|
// 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 directory)
|
// (it always assumes the preloaded add-ons to be in the system
|
||||||
|
// directory)
|
||||||
char path[B_FILE_NAME_LENGTH];
|
char path[B_FILE_NAME_LENGTH];
|
||||||
const char *name, *suffix;
|
const char *name, *suffix;
|
||||||
if (moduleImage->info[0]
|
if (moduleImage->info[0]
|
||||||
@@ -958,12 +959,31 @@ register_preloaded_module_image(struct preloaded_image *image)
|
|||||||
image->name)) != NULL) {
|
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
|
||||||
size_t length = strlcpy(path, "/boot/beos/system/add-ons/kernel/",
|
KPath addonsKernelPath;
|
||||||
sizeof(path));
|
status_t status = find_directory(B_BEOS_ADDONS_DIRECTORY,
|
||||||
strlcpy(path + length, name, strlen(image->name)
|
gBootDevice, false, addonsKernelPath.LockBuffer(),
|
||||||
+ 1 + (suffix - name));
|
addonsKernelPath.BufferSize());
|
||||||
|
if (status != B_OK) {
|
||||||
|
dprintf("register_preloaded_module_image: find_directory() "
|
||||||
|
"failed: %s\n", strerror(status));
|
||||||
|
}
|
||||||
|
addonsKernelPath.UnlockBuffer();
|
||||||
|
if (status == B_OK) {
|
||||||
|
status = addonsKernelPath.Append("kernel/");
|
||||||
|
// KPath does not remove the trailing '/'
|
||||||
|
}
|
||||||
|
if (status == B_OK) {
|
||||||
|
size_t length = strlcpy(path, addonsKernelPath.Path(),
|
||||||
|
sizeof(path));
|
||||||
|
strlcpy(path + length, name, strlen(image->name)
|
||||||
|
+ 1 + (suffix - name));
|
||||||
|
|
||||||
moduleImage->path = strdup(path);
|
moduleImage->path = strdup(path);
|
||||||
|
} else {
|
||||||
|
moduleImage->path = NULL;
|
||||||
|
// this will trigger B_NO_MEMORY, which is the only
|
||||||
|
// reason to get here anyways...
|
||||||
|
}
|
||||||
} else
|
} else
|
||||||
moduleImage->path = strdup(image->name);
|
moduleImage->path = strdup(image->name);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user