summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbeck <>2014-04-15 22:43:53 +0000
committerbeck <>2014-04-15 22:43:53 +0000
commit264435a4c81c28ea4b057c86da0baca70c05a13c (patch)
tree673eb248cb2658aeb40813bb1b1e966b181aa7f5 /src
parent906dbb22bd36083093ed2f5612b6622f6922ccf7 (diff)
downloadopenbsd-264435a4c81c28ea4b057c86da0baca70c05a13c.tar.gz
openbsd-264435a4c81c28ea4b057c86da0baca70c05a13c.tar.bz2
openbsd-264435a4c81c28ea4b057c86da0baca70c05a13c.zip
o_dir.c had a very funny odor. all users of this now use standard functions.
consign it to the Attic. ok deraadt@
Diffstat (limited to 'src')
-rw-r--r--src/lib/libssl/src/ssl/LPdir_unix.c121
-rw-r--r--src/lib/libssl/src/ssl/o_dir.c73
-rw-r--r--src/lib/libssl/src/ssl/o_dir.h54
-rw-r--r--src/lib/libssl/src/ssl/ssl_cert.c1
-rw-r--r--src/lib/libssl/ssl_cert.c1
5 files changed, 0 insertions, 250 deletions
diff --git a/src/lib/libssl/src/ssl/LPdir_unix.c b/src/lib/libssl/src/ssl/LPdir_unix.c
deleted file mode 100644
index 000a1bd819..0000000000
--- a/src/lib/libssl/src/ssl/LPdir_unix.c
+++ /dev/null
@@ -1,121 +0,0 @@
1/* $LP: LPlib/source/LPdir_unix.c,v 1.11 2004/09/23 22:07:22 _cvs_levitte Exp $ */
2/*
3 * Copyright (c) 2004, Richard Levitte <richard@levitte.org>
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 *
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */
27
28#include <stddef.h>
29#include <stdlib.h>
30#include <limits.h>
31#include <string.h>
32#include <sys/types.h>
33#include <dirent.h>
34#include <errno.h>
35#ifndef LPDIR_H
36#include "LPdir.h"
37#endif
38
39/* The POSIXly macro for the maximum number of characters in a file path
40 is NAME_MAX. However, some operating systems use PATH_MAX instead.
41 Therefore, it seems natural to first check for PATH_MAX and use that,
42 and if it doesn't exist, use NAME_MAX. */
43#if defined(PATH_MAX)
44# define LP_ENTRY_SIZE PATH_MAX
45#elif defined(NAME_MAX)
46# define LP_ENTRY_SIZE NAME_MAX
47#endif
48
49/* Of course, there's the possibility that neither PATH_MAX nor NAME_MAX
50 exist. It's also possible that NAME_MAX exists but is define to a
51 very small value (HP-UX offers 14), so we need to check if we got a
52 result, and if it meets a minimum standard, and create or change it
53 if not. */
54#if !defined(LP_ENTRY_SIZE) || LP_ENTRY_SIZE<255
55# undef LP_ENTRY_SIZE
56# define LP_ENTRY_SIZE 255
57#endif
58
59struct LP_dir_context_st {
60 DIR *dir;
61 char entry_name[LP_ENTRY_SIZE + 1];
62};
63
64const char
65*LP_find_file(LP_DIR_CTX **ctx, const char *directory)
66{
67 struct dirent *direntry = NULL;
68
69 if (ctx == NULL || directory == NULL) {
70 errno = EINVAL;
71 return 0;
72 }
73
74 errno = 0;
75 if (*ctx == NULL) {
76 *ctx = (LP_DIR_CTX *)malloc(sizeof(LP_DIR_CTX));
77 if (*ctx == NULL) {
78 errno = ENOMEM;
79 return 0;
80 }
81 memset(*ctx, '\0', sizeof(LP_DIR_CTX));
82
83 (*ctx)->dir = opendir(directory);
84 if ((*ctx)->dir == NULL) {
85 int save_errno = errno; /* Probably not needed, but I'm paranoid */
86 free(*ctx);
87 *ctx = NULL;
88 errno = save_errno;
89 return 0;
90 }
91 }
92
93 direntry = readdir((*ctx)->dir);
94 if (direntry == NULL) {
95 return 0;
96 }
97
98 strncpy((*ctx)->entry_name, direntry->d_name, sizeof((*ctx)->entry_name) - 1);
99 (*ctx)->entry_name[sizeof((*ctx)->entry_name) - 1] = '\0';
100 return (*ctx)->entry_name;
101}
102
103int
104LP_find_file_end(LP_DIR_CTX **ctx)
105{
106 if (ctx != NULL && *ctx != NULL) {
107 int ret = closedir((*ctx)->dir);
108
109 free(*ctx);
110 switch (ret) {
111 case 0:
112 return 1;
113 case -1:
114 return 0;
115 default:
116 break;
117 }
118 }
119 errno = EINVAL;
120 return 0;
121}
diff --git a/src/lib/libssl/src/ssl/o_dir.c b/src/lib/libssl/src/ssl/o_dir.c
deleted file mode 100644
index 68bd1f4d04..0000000000
--- a/src/lib/libssl/src/ssl/o_dir.c
+++ /dev/null
@@ -1,73 +0,0 @@
1/* crypto/o_dir.c -*- mode:C; c-file-style: "eay" -*- */
2/* Written by Richard Levitte (richard@levitte.org) for the OpenSSL
3 * project 2004.
4 */
5/* ====================================================================
6 * Copyright (c) 2004 The OpenSSL Project. All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 *
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 *
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in
17 * the documentation and/or other materials provided with the
18 * distribution.
19 *
20 * 3. All advertising materials mentioning features or use of this
21 * software must display the following acknowledgment:
22 * "This product includes software developed by the OpenSSL Project
23 * for use in the OpenSSL Toolkit. (http://www.openssl.org/)"
24 *
25 * 4. The names "OpenSSL Toolkit" and "OpenSSL Project" must not be used to
26 * endorse or promote products derived from this software without
27 * prior written permission. For written permission, please contact
28 * openssl-core@openssl.org.
29 *
30 * 5. Products derived from this software may not be called "OpenSSL"
31 * nor may "OpenSSL" appear in their names without prior written
32 * permission of the OpenSSL Project.
33 *
34 * 6. Redistributions of any form whatsoever must retain the following
35 * acknowledgment:
36 * "This product includes software developed by the OpenSSL Project
37 * for use in the OpenSSL Toolkit (http://www.openssl.org/)"
38 *
39 * THIS SOFTWARE IS PROVIDED BY THE OpenSSL PROJECT ``AS IS'' AND ANY
40 * EXPRESSED OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
41 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
42 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE OpenSSL PROJECT OR
43 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
44 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
45 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
46 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
47 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
48 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
49 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
50 * OF THE POSSIBILITY OF SUCH DAMAGE.
51 * ====================================================================
52 *
53 * This product includes cryptographic software written by Eric Young
54 * (eay@cryptsoft.com). This product includes software written by Tim
55 * Hudson (tjh@cryptsoft.com).
56 *
57 */
58
59#include <errno.h>
60#include <e_os.h>
61
62/* The routines really come from the Levitte Programming, so to make
63 life simple, let's just use the raw files and hack the symbols to
64 fit our namespace. */
65#define LP_DIR_CTX OPENSSL_DIR_CTX
66#define LP_dir_context_st OPENSSL_dir_context_st
67#define LP_find_file OPENSSL_DIR_read
68#define LP_find_file_end OPENSSL_DIR_end
69
70#include "o_dir.h"
71
72#define LPDIR_H
73#include "LPdir_unix.c"
diff --git a/src/lib/libssl/src/ssl/o_dir.h b/src/lib/libssl/src/ssl/o_dir.h
deleted file mode 100644
index cf4a95911a..0000000000
--- a/src/lib/libssl/src/ssl/o_dir.h
+++ /dev/null
@@ -1,54 +0,0 @@
1/* crypto/o_dir.h -*- mode:C; c-file-style: "eay" -*- */
2/* Copied from Richard Levitte's (richard@levitte.org) LP library. All
3 * symbol names have been changed, with permission from the author.
4 */
5
6/* $LP: LPlib/source/LPdir.h,v 1.1 2004/06/14 08:56:04 _cvs_levitte Exp $ */
7/*
8 * Copyright (c) 2004, Richard Levitte <richard@levitte.org>
9 * All rights reserved.
10 *
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
13 * are met:
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30 * SUCH DAMAGE.
31 */
32
33
34#ifndef O_DIR_H
35#define O_DIR_H
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41typedef struct OPENSSL_dir_context_st OPENSSL_DIR_CTX;
42
43/* returns NULL on error or end-of-directory.
44 If it is end-of-directory, errno will be zero */
45const char *OPENSSL_DIR_read(OPENSSL_DIR_CTX **ctx, const char *directory);
46
47/* returns 1 on success, 0 on error */
48int OPENSSL_DIR_end(OPENSSL_DIR_CTX **ctx);
49
50#ifdef __cplusplus
51}
52#endif
53
54#endif /* LPDIR_H */
diff --git a/src/lib/libssl/src/ssl/ssl_cert.c b/src/lib/libssl/src/ssl/ssl_cert.c
index 9c952f452a..72b5d8d2bd 100644
--- a/src/lib/libssl/src/ssl/ssl_cert.c
+++ b/src/lib/libssl/src/ssl/ssl_cert.c
@@ -122,7 +122,6 @@
122 122
123#include <openssl/opensslconf.h> 123#include <openssl/opensslconf.h>
124#include <openssl/e_os2.h> 124#include <openssl/e_os2.h>
125#include "o_dir.h"
126#include <openssl/objects.h> 125#include <openssl/objects.h>
127#include <openssl/bio.h> 126#include <openssl/bio.h>
128#include <openssl/pem.h> 127#include <openssl/pem.h>
diff --git a/src/lib/libssl/ssl_cert.c b/src/lib/libssl/ssl_cert.c
index 9c952f452a..72b5d8d2bd 100644
--- a/src/lib/libssl/ssl_cert.c
+++ b/src/lib/libssl/ssl_cert.c
@@ -122,7 +122,6 @@
122 122
123#include <openssl/opensslconf.h> 123#include <openssl/opensslconf.h>
124#include <openssl/e_os2.h> 124#include <openssl/e_os2.h>
125#include "o_dir.h"
126#include <openssl/objects.h> 125#include <openssl/objects.h>
127#include <openssl/bio.h> 126#include <openssl/bio.h>
128#include <openssl/pem.h> 127#include <openssl/pem.h>