diff options
| author | joerg <joerg@NetBSD.org> | 2010-08-07 19:47:34 +0000 |
|---|---|---|
| committer | joerg <joerg@NetBSD.org> | 2010-08-07 19:47:34 +0000 |
| commit | 6972211664f92203016e0973eb3baf2bbbb3267c (patch) | |
| tree | 6c1ab06c5f1550768592e58214d28963bebc60c6 /libexec | |
| parent | 167fe0b1f6d28eeb6fb3ebdc4735700a6f4c5fb2 (diff) | |
Stricter matching for _rtld_invalid_paths by ensuring separator.
Use mem* functions instead of str* for strings of known size.
Diffstat (limited to 'libexec')
| -rw-r--r-- | libexec/ld.elf_so/search.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/libexec/ld.elf_so/search.c b/libexec/ld.elf_so/search.c index 6b0aa27a3b0..682dc7827c3 100644 --- a/libexec/ld.elf_so/search.c +++ b/libexec/ld.elf_so/search.c @@ -1,4 +1,4 @@ -/* $NetBSD: search.c,v 1.21 2006/03/21 17:48:10 christos Exp $ */ +/* $NetBSD: search.c,v 1.22 2010/08/07 19:47:34 joerg Exp $ */ /* * Copyright 1996 Matt Thomas <matt@3am-software.com> @@ -38,7 +38,7 @@ #include <sys/cdefs.h> #ifndef lint -__RCSID("$NetBSD: search.c,v 1.21 2006/03/21 17:48:10 christos Exp $"); +__RCSID("$NetBSD: search.c,v 1.22 2010/08/07 19:47:34 joerg Exp $"); #endif /* not lint */ #include <err.h> @@ -80,15 +80,17 @@ _rtld_search_library_path(const char *name, size_t namelen, for (sp = _rtld_invalid_paths; sp != NULL; sp = sp->sp_next) { if (sp->sp_pathlen == pathnamelen && + sp->sp_path[dirlen] == '/' && !memcmp(name, sp->sp_path + dirlen + 1, namelen) && !memcmp(dir, sp->sp_path, dirlen)) { return NULL; } } - (void)strncpy(pathname, dir, dirlen); + memcpy(pathname, dir, dirlen); pathname[dirlen] = '/'; - strcpy(pathname + dirlen + 1, name); + memcpy(pathname + dirlen + 1, name, namelen); + pathname[pathnamelen] = '\0'; dbg((" Trying \"%s\"", pathname)); obj = _rtld_load_object(pathname, mode); |
