From 0f6b2cb3f84f6ef416f0841d33fce0efab4c10d3 Mon Sep 17 00:00:00 2001 From: Paul Traina Date: Mon, 26 Feb 1996 02:22:33 +0000 Subject: [PATCH] Bring in some of Paul K's fixes for ldconfig from NetBSD-current. This solves the problem of being unable to use shared libraries with dots in their names before the ".so." code. This should be brought into -stable. There are more changes from Paul that look like they should be included, but they change the format of the hints file, so I'm not going to bring them in now (but we should in the future). Obtained from: pk@netbsd.org --- gnu/usr.bin/ld/ldconfig/ldconfig.c | 44 ++++++++++++++++++++++-------- sbin/ldconfig/ldconfig.c | 44 ++++++++++++++++++++++-------- 2 files changed, 64 insertions(+), 24 deletions(-) diff --git a/gnu/usr.bin/ld/ldconfig/ldconfig.c b/gnu/usr.bin/ld/ldconfig/ldconfig.c index 1b3f8f27a28..13cd2974303 100644 --- a/gnu/usr.bin/ld/ldconfig/ldconfig.c +++ b/gnu/usr.bin/ld/ldconfig/ldconfig.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1993 Paul Kranenburg + * Copyright (c) 1993,1995 Paul Kranenburg * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,7 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: ldconfig.c,v 1.10 1995/06/24 10:08:44 asami Exp $ + * $Id: ldconfig.c,v 1.13 1996/01/09 00:04:35 pk Exp $ */ #include @@ -139,7 +139,7 @@ int silent; { DIR *dd; struct dirent *dp; - char name[MAXPATHLEN], rest[MAXPATHLEN]; + char name[MAXPATHLEN]; int dewey[MAXDEWEY], ndewey; if ((dd = opendir(dir)) == NULL) { @@ -149,17 +149,38 @@ int silent; } while ((dp = readdir(dd)) != NULL) { - int n; + register int n; + register char *cp; - name[0] = rest[0] = '\0'; - - n = sscanf(dp->d_name, "lib%[^.].so.%s", - name, rest); - - if (n < 2 || rest[0] == '\0') + /* Check for `lib' prefix */ + if (dp->d_name[0] != 'l' || + dp->d_name[1] != 'i' || + dp->d_name[2] != 'b') continue; - ndewey = getdewey(dewey, rest); + /* Copy the entry minus prefix */ + (void)strcpy(name, dp->d_name + 3); + n = strlen(name); + if (n < 4) + continue; + + /* Find ".so." in name */ + for (cp = name + n - 4; cp > name; --cp) { + if (cp[0] == '.' && + cp[1] == 's' && + cp[2] == 'o' && + cp[3] == '.') + break; + } + if (cp <= name) + continue; + + *cp = '\0'; + if (!isdigit(*(cp+4))) + continue; + + bzero((caddr_t)dewey, sizeof(dewey)); + ndewey = getdewey(dewey, cp + 4); enter(dir, dp->d_name, name, dewey, ndewey); } @@ -450,4 +471,3 @@ listhints() return; } - diff --git a/sbin/ldconfig/ldconfig.c b/sbin/ldconfig/ldconfig.c index 1b3f8f27a28..13cd2974303 100644 --- a/sbin/ldconfig/ldconfig.c +++ b/sbin/ldconfig/ldconfig.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1993 Paul Kranenburg + * Copyright (c) 1993,1995 Paul Kranenburg * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -27,7 +27,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: ldconfig.c,v 1.10 1995/06/24 10:08:44 asami Exp $ + * $Id: ldconfig.c,v 1.13 1996/01/09 00:04:35 pk Exp $ */ #include @@ -139,7 +139,7 @@ int silent; { DIR *dd; struct dirent *dp; - char name[MAXPATHLEN], rest[MAXPATHLEN]; + char name[MAXPATHLEN]; int dewey[MAXDEWEY], ndewey; if ((dd = opendir(dir)) == NULL) { @@ -149,17 +149,38 @@ int silent; } while ((dp = readdir(dd)) != NULL) { - int n; + register int n; + register char *cp; - name[0] = rest[0] = '\0'; - - n = sscanf(dp->d_name, "lib%[^.].so.%s", - name, rest); - - if (n < 2 || rest[0] == '\0') + /* Check for `lib' prefix */ + if (dp->d_name[0] != 'l' || + dp->d_name[1] != 'i' || + dp->d_name[2] != 'b') continue; - ndewey = getdewey(dewey, rest); + /* Copy the entry minus prefix */ + (void)strcpy(name, dp->d_name + 3); + n = strlen(name); + if (n < 4) + continue; + + /* Find ".so." in name */ + for (cp = name + n - 4; cp > name; --cp) { + if (cp[0] == '.' && + cp[1] == 's' && + cp[2] == 'o' && + cp[3] == '.') + break; + } + if (cp <= name) + continue; + + *cp = '\0'; + if (!isdigit(*(cp+4))) + continue; + + bzero((caddr_t)dewey, sizeof(dewey)); + ndewey = getdewey(dewey, cp + 4); enter(dir, dp->d_name, name, dewey, ndewey); } @@ -450,4 +471,3 @@ listhints() return; } -