Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/libexec/ld.elf_so Stricter matching for _rtld_invalid_paths ...



details:   https://anonhg.NetBSD.org/src/rev/c2c280042172
branches:  trunk
changeset: 756918:c2c280042172
user:      joerg <joerg%NetBSD.org@localhost>
date:      Sat Aug 07 19:47:34 2010 +0000

description:
Stricter matching for _rtld_invalid_paths by ensuring separator.
Use mem* functions instead of str* for strings of known size.

diffstat:

 libexec/ld.elf_so/search.c |  10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)

diffs (38 lines):

diff -r 35366aa831d7 -r c2c280042172 libexec/ld.elf_so/search.c
--- a/libexec/ld.elf_so/search.c        Sat Aug 07 19:18:04 2010 +0000
+++ b/libexec/ld.elf_so/search.c        Sat Aug 07 19:47:34 2010 +0000
@@ -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@localhost>
@@ -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 @@
 
        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);



Home | Main Index | Thread Index | Old Index