Avoid keeping a dangling pointer when the mappings array is resized.

Sponsored by:	Dell EMC Isilon
This commit is contained in:
Mark Johnston 2017-09-06 16:24:34 +00:00
parent 85d88d8799
commit 2c73c414eb
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=323227
3 changed files with 4 additions and 3 deletions

View File

@ -72,7 +72,7 @@ struct proc_handle {
struct map_info *mappings; /* File mappings for proc. */
size_t maparrsz; /* Map array size. */
size_t nmappings; /* Number of mappings. */
prmap_t *exec_map; /* Executable text mapping. */
size_t exec_map; /* Executable text mapping index. */
lwpstatus_t lwps; /* Process status. */
struct procstat *procstat; /* libprocstat handle. */
char execpath[PATH_MAX]; /* Path to program executable. */

View File

@ -62,7 +62,7 @@ map_iter(const rd_loadobj_t *lop, void *arg)
rdl2prmap(lop, &mapping->map);
if (strcmp(lop->rdl_path, phdl->execpath) == 0 &&
(lop->rdl_prot & RD_RDL_X) != 0)
phdl->exec_map = &mapping->map;
phdl->exec_map = phdl->nmappings;
file = NULL;
if (lop->rdl_path[0] != '\0') {

View File

@ -511,7 +511,8 @@ _proc_name2map(struct proc_handle *p, const char *name)
return (&p->mappings[i]);
}
if (strcmp(name, "a.out") == 0)
return (_proc_addr2map(p, p->exec_map->pr_vaddr));
return (_proc_addr2map(p,
p->mappings[p->exec_map].map.pr_vaddr));
return (NULL);
}