Add some code to test libraries to make sure they are a.out before adding

them to hints.
This commit is contained in:
matt 2000-05-27 17:06:34 +00:00
parent 3ac3c9b124
commit 7e083f3d75
1 changed files with 17 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: ldconfig.c,v 1.28 2000/05/27 06:53:29 matt Exp $ */ /* $NetBSD: ldconfig.c,v 1.29 2000/05/27 17:06:34 matt Exp $ */
/*- /*-
* Copyright (c) 1998 The NetBSD Foundation, Inc. * Copyright (c) 1998 The NetBSD Foundation, Inc.
@ -42,6 +42,7 @@
#include <sys/file.h> #include <sys/file.h>
#include <sys/time.h> #include <sys/time.h>
#include <sys/mman.h> #include <sys/mman.h>
#include <a.out.h>
#include <ctype.h> #include <ctype.h>
#include <dirent.h> #include <dirent.h>
#include <err.h> #include <err.h>
@ -232,7 +233,9 @@ dodir(dir, silent, update_dir_list)
while ((dp = readdir(dd)) != NULL) { while ((dp = readdir(dd)) != NULL) {
int n; int n;
char *cp; char *cp, *path;
FILE *fp;
struct exec ex;
/* Check for `lib' prefix */ /* Check for `lib' prefix */
if (dp->d_name[0] != 'l' || if (dp->d_name[0] != 'l' ||
@ -257,6 +260,18 @@ dodir(dir, silent, update_dir_list)
if (cp <= name) if (cp <= name)
continue; continue;
path = concat(dir, "/", dp->d_name);
fp = fopen(path, "r");
free(path);
if (fp == NULL)
continue;
n = fread(&ex, 1, sizeof(ex), fp);
fclose(fp);
if (n != sizeof(ex)
|| N_GETMAGIC(ex) != ZMAGIC
|| (N_GETFLAG(ex) & EX_DYNAMIC) == 0)
continue;
*cp = '\0'; *cp = '\0';
if (!isdigit(*(cp+4))) if (!isdigit(*(cp+4)))
continue; continue;