We now make sure, that images always have absolute paths, otherwise
their path could be invalid in other contexts (e.g. the debug server might be unabled to find them). This seems to be what BeOS does, too. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@13796 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
d08379a80b
commit
7f53c2cc96
@ -878,6 +878,22 @@ load_container(char const *name, image_type type, const char *rpath)
|
||||
fd = open_executable(path, type, rpath);
|
||||
FATAL((fd < 0), fd, "cannot open file %s\n", path);
|
||||
|
||||
// If the path is not absolute, we prepend the CWD to make it one.
|
||||
if (path[0] != '/') {
|
||||
char relativePath[PATH_MAX];
|
||||
strcpy(relativePath, path);
|
||||
|
||||
// get the CWD
|
||||
status = _kern_getcwd(path, sizeof(path));
|
||||
FATAL((status != B_OK), status, "_kern_getcwd() failed\n");
|
||||
|
||||
if (strlcat(path, "/", sizeof(path)) >= sizeof(path)
|
||||
|| strlcat(path, relativePath, sizeof(path)) >= sizeof(path)) {
|
||||
FATAL(true, B_NAME_TOO_LONG, "Absolute path of image %s is too "
|
||||
"long!\n", relativePath);
|
||||
}
|
||||
}
|
||||
|
||||
len = _kern_read(fd, 0, &eheader, sizeof(eheader));
|
||||
FATAL((len != sizeof(eheader)), B_BAD_DATA,
|
||||
"troubles reading ELF header\n");
|
||||
|
Loading…
Reference in New Issue
Block a user