diff options
Diffstat (limited to 'usr/src/lib/libproc/common')
-rw-r--r-- | usr/src/lib/libproc/common/Psymtab.c | 16 | ||||
-rw-r--r-- | usr/src/lib/libproc/common/Pzone.c | 10 |
2 files changed, 23 insertions, 3 deletions
diff --git a/usr/src/lib/libproc/common/Psymtab.c b/usr/src/lib/libproc/common/Psymtab.c index 3176e50448..7c8166d5c3 100644 --- a/usr/src/lib/libproc/common/Psymtab.c +++ b/usr/src/lib/libproc/common/Psymtab.c @@ -21,6 +21,7 @@ /* * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, Joyent, Inc. All rights reserved. */ #include <assert.h> @@ -1733,6 +1734,21 @@ Pbuild_file_symtab(struct ps_prochandle *P, file_info_t *fptr) (void) elf_end(elf); elf = newelf; dprintf("switched to faked up ELF file\n"); + + /* + * Check to see if the file that we just discovered + * to be an imposter matches the execname that was + * determined by Pfindexec(). If it does, we (clearly) + * don't have the right binary, and we zero out + * execname before anyone gets hurt. + */ + if (fptr->file_rname != NULL && P->execname != NULL && + strcmp(fptr->file_rname, P->execname) == 0) { + dprintf("file/in-core image mismatch was " + "on P->execname; discarding\n"); + free(P->execname); + P->execname = NULL; + } } } diff --git a/usr/src/lib/libproc/common/Pzone.c b/usr/src/lib/libproc/common/Pzone.c index c478b41624..68efea7a72 100644 --- a/usr/src/lib/libproc/common/Pzone.c +++ b/usr/src/lib/libproc/common/Pzone.c @@ -23,6 +23,9 @@ * Copyright 2009 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ +/* + * Copyright (c) 2013, Joyent, Inc. All rights reserved. + */ #include <assert.h> #include <dlfcn.h> @@ -792,9 +795,10 @@ Pfindmap(struct ps_prochandle *P, map_info_t *mptr, char *s, size_t n) (strcmp(mptr->map_pmap.pr_mapname, "a.out") == 0) || ((fptr != NULL) && (fptr->file_lname != NULL) && (strcmp(fptr->file_lname, "a.out") == 0))) { - (void) Pexecname(P, buf, sizeof (buf)); - (void) strlcpy(s, buf, n); - return (s); + if (Pexecname(P, buf, sizeof (buf)) != NULL) { + (void) strlcpy(s, buf, n); + return (s); + } } /* Try /proc first to get the real object name */ |