The name elf_load_user_image() chooses for the area is now actually limited

to B_OS_NAME_LENGTH bytes, instead of 64. Also, it will now only consider
the leaf name for the area.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@15640 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2005-12-21 16:47:46 +00:00
parent 8f30140c63
commit d5abe15e84
+19 -11
View File
@@ -1013,11 +1013,11 @@ elf_load_user_image(const char *path, struct team *team, int flags, addr_t *entr
{ {
struct Elf32_Ehdr eheader; struct Elf32_Ehdr eheader;
struct Elf32_Phdr *pheaders = NULL; struct Elf32_Phdr *pheaders = NULL;
char baseName[64]; char baseName[B_OS_NAME_LENGTH];
int fd; status_t err;
int err;
int i;
ssize_t len; ssize_t len;
int fd;
int i;
TRACE(("elf_load: entry path '%s', team %p\n", path, team)); TRACE(("elf_load: entry path '%s', team %p\n", path, team));
@@ -1066,17 +1066,25 @@ elf_load_user_image(const char *path, struct team *team, int flags, addr_t *entr
// construct a nice name for the region we have to create below // construct a nice name for the region we have to create below
{ {
int32 length = strlen(path); int32 length;
if (length > 52)
sprintf(baseName, "...%s", path + length - 52); const char *leaf = strrchr(path, '/');
if (leaf == NULL)
leaf = path;
else else
strcpy(baseName, path); leaf++;
length = strlen(leaf);
if (length > B_OS_NAME_LENGTH - 8)
sprintf(baseName, "...%s", leaf + length + 8 - B_OS_NAME_LENGTH);
else
strcpy(baseName, leaf);
} }
// map the program's segments into memory // map the program's segments into memory
for (i = 0; i < eheader.e_phnum; i++) { for (i = 0; i < eheader.e_phnum; i++) {
char regionName[64]; char regionName[B_OS_NAME_LENGTH];
char *regionAddress; char *regionAddress;
area_id id; area_id id;
@@ -1126,7 +1134,7 @@ elf_load_user_image(const char *path, struct team *team, int flags, addr_t *entr
if (memUpperBound != fileUpperBound) { if (memUpperBound != fileUpperBound) {
size_t bss_size = memUpperBound - fileUpperBound; size_t bss_size = memUpperBound - fileUpperBound;
sprintf(regionName, "%s_bss%d", baseName, i); snprintf(regionName, B_OS_NAME_LENGTH, "%s_bss%d", baseName, i);
regionAddress += fileUpperBound; regionAddress += fileUpperBound;
id = create_area_etc(team, regionName, (void **)&regionAddress, id = create_area_etc(team, regionName, (void **)&regionAddress,
@@ -1141,7 +1149,7 @@ elf_load_user_image(const char *path, struct team *team, int flags, addr_t *entr
/* /*
* assume ro/text segment * assume ro/text segment
*/ */
sprintf(regionName, "%s_seg%dro", baseName, i); snprintf(regionName, B_OS_NAME_LENGTH, "%s_seg%dro", baseName, i);
id = vm_map_file(team->id, regionName, id = vm_map_file(team->id, regionName,
(void **)&regionAddress, (void **)&regionAddress,