diff options
author | Niels Provos <provos@cvs.openbsd.org> | 2001-06-22 16:21:44 +0000 |
---|---|---|
committer | Niels Provos <provos@cvs.openbsd.org> | 2001-06-22 16:21:44 +0000 |
commit | 5ed87a9d28eb1ff9df894bfd7760f2bf77a0208b (patch) | |
tree | 46720005c3a5939e1c74a1b21232999f15cfe51c /sbin/isakmpd/x509.c | |
parent | 1f35c17c42d1470de7c58dc663da606c43796179 (diff) |
fix for filesystems where readdir does not return d_type, use stat instead.
okay deraadt@
Diffstat (limited to 'sbin/isakmpd/x509.c')
-rw-r--r-- | sbin/isakmpd/x509.c | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/sbin/isakmpd/x509.c b/sbin/isakmpd/x509.c index 89149eb4a7a..7be9a639734 100644 --- a/sbin/isakmpd/x509.c +++ b/sbin/isakmpd/x509.c @@ -1,4 +1,4 @@ -/* $OpenBSD: x509.c,v 1.57 2001/06/07 07:35:15 angelos Exp $ */ +/* $OpenBSD: x509.c,v 1.58 2001/06/22 16:21:43 provos Exp $ */ /* $EOM: x509.c,v 1.54 2001/01/16 18:42:16 ho Exp $ */ /* @@ -685,6 +685,22 @@ x509_read_from_dir (X509_STORE *ctx, char *name, int hash) while ((file = readdir (dir)) != NULL) { + strncpy (fullname + off, file->d_name, size); + fullname[off + size] = 0; + + if (file->d_type != DT_UNKNOWN) + { + if (file->d_type != DT_REG && file->d_type != DT_LNK) + continue; + } + else + { + struct stat sb; + + if (stat(fullname, &sb) == -1 || !(sb.st_mode & S_IFREG)) + continue; + } + if (file->d_type != DT_REG && file->d_type != DT_LNK) continue; @@ -698,9 +714,6 @@ x509_read_from_dir (X509_STORE *ctx, char *name, int hash) continue; } - strncpy (fullname + off, file->d_name, size); - fullname[off + size] = 0; - if (LC (BIO_read_filename, (certh, fullname)) == -1) { LC (BIO_free, (certh)); |