projects
/
oweals
/
openssl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Pass phrase reorganisation.
[oweals/openssl.git]
/
crypto
/
x509
/
by_dir.c
diff --git
a/crypto/x509/by_dir.c
b/crypto/x509/by_dir.c
index 11725ec94c6e4e26facd6f8370e1cc72d66cfbe1..14d12c56bd709e47198ecb8b73547624c7f08a3a 100644
(file)
--- a/
crypto/x509/by_dir.c
+++ b/
crypto/x509/by_dir.c
@@
-59,13
+59,20
@@
#include <stdio.h>
#include <time.h>
#include <errno.h>
#include <stdio.h>
#include <time.h>
#include <errno.h>
-#include <sys/types.h>
-#include <sys/stat.h>
#include "cryptlib.h"
#include "cryptlib.h"
-#include "lhash.h"
-#include "x509.h"
-#include "pem.h"
+
+#ifndef NO_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef MAC_OS_pre_X
+# include <stat.h>
+#else
+# include <sys/stat.h>
+#endif
+
+#include <openssl/lhash.h>
+#include <openssl/x509.h>
typedef struct lookup_dir_st
{
typedef struct lookup_dir_st
{
@@
-76,21
+83,13
@@
typedef struct lookup_dir_st
int num_dirs_alloced;
} BY_DIR;
int num_dirs_alloced;
} BY_DIR;
-#ifndef NOPROTO
-
static int dir_ctrl(X509_LOOKUP *ctx,int cmd,char *argp,long argl,
char **ret);
+static int dir_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
+
char **ret);
static int new_dir(X509_LOOKUP *lu);
static void free_dir(X509_LOOKUP *lu);
static int new_dir(X509_LOOKUP *lu);
static void free_dir(X509_LOOKUP *lu);
-static int add_cert_dir(BY_DIR *ctx,char *dir,int type);
+static int add_cert_dir(BY_DIR *ctx,c
onst c
har *dir,int type);
static int get_cert_by_subject(X509_LOOKUP *xl,int type,X509_NAME *name,
X509_OBJECT *ret);
static int get_cert_by_subject(X509_LOOKUP *xl,int type,X509_NAME *name,
X509_OBJECT *ret);
-#else
-static int dir_ctrl();
-static int new_dir();
-static void free_dir();
-static int add_cert_dir();
-static int get_cert_by_subject();
-#endif
-
X509_LOOKUP_METHOD x509_dir_lookup=
{
"Load certs from files in a directory",
X509_LOOKUP_METHOD x509_dir_lookup=
{
"Load certs from files in a directory",
@@
-105,17
+104,13
@@
X509_LOOKUP_METHOD x509_dir_lookup=
NULL, /* get_by_alias */
};
NULL, /* get_by_alias */
};
-X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir()
+X509_LOOKUP_METHOD *X509_LOOKUP_hash_dir(
void
)
{
return(&x509_dir_lookup);
}
{
return(&x509_dir_lookup);
}
-static int dir_ctrl(ctx,cmd,argp,argl,retp)
-X509_LOOKUP *ctx;
-int cmd;
-long argl;
-char *argp;
-char **retp;
+static int dir_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, long argl,
+ char **retp)
{
int ret=0;
BY_DIR *ld;
{
int ret=0;
BY_DIR *ld;
@@
-147,8
+142,7
@@
char **retp;
return(ret);
}
return(ret);
}
-static int new_dir(lu)
-X509_LOOKUP *lu;
+static int new_dir(X509_LOOKUP *lu)
{
BY_DIR *a;
{
BY_DIR *a;
@@
-167,8
+161,7
@@
X509_LOOKUP *lu;
return(1);
}
return(1);
}
-static void free_dir(lu)
-X509_LOOKUP *lu;
+static void free_dir(X509_LOOKUP *lu)
{
BY_DIR *a;
int i;
{
BY_DIR *a;
int i;
@@
-182,17
+175,18
@@
X509_LOOKUP *lu;
Free(a);
}
Free(a);
}
-static int add_cert_dir(ctx,dir, type)
-BY_DIR *ctx;
-char *dir;
-int type;
+static int add_cert_dir(BY_DIR *ctx, const char *dir, int type)
{
int j,len;
int *ip;
{
int j,len;
int *ip;
- char *s,*ss,*p;
+ c
onst c
har *s,*ss,*p;
char **pp;
char **pp;
- if (dir == NULL) return(0);
+ if (dir == NULL || !*dir)
+ {
+ X509err(X509_F_ADD_CERT_DIR,X509_R_INVALID_DIRECTORY);
+ return 0;
+ }
s=dir;
p=s;
s=dir;
p=s;
@@
-224,9
+218,9
@@
int type;
memcpy(ip,ctx->dirs_type,(ctx->num_dirs_alloced-10)*
sizeof(int));
if (ctx->dirs != NULL)
memcpy(ip,ctx->dirs_type,(ctx->num_dirs_alloced-10)*
sizeof(int));
if (ctx->dirs != NULL)
- Free(
(char *)
ctx->dirs);
+ Free(ctx->dirs);
if (ctx->dirs_type != NULL)
if (ctx->dirs_type != NULL)
- Free(
(char *)
ctx->dirs_type);
+ Free(ctx->dirs_type);
ctx->dirs=pp;
ctx->dirs_type=ip;
}
ctx->dirs=pp;
ctx->dirs_type=ip;
}
@@
-243,11
+237,8
@@
int type;
return(1);
}
return(1);
}
-static int get_cert_by_subject(xl,type,name,ret)
-X509_LOOKUP *xl;
-int type;
-X509_NAME *name;
-X509_OBJECT *ret;
+static int get_cert_by_subject(X509_LOOKUP *xl, int type, X509_NAME *name,
+ X509_OBJECT *ret)
{
BY_DIR *ctx;
union {
{
BY_DIR *ctx;
union {
@@
-266,7
+257,7
@@
X509_OBJECT *ret;
BUF_MEM *b=NULL;
struct stat st;
X509_OBJECT stmp,*tmp;
BUF_MEM *b=NULL;
struct stat st;
X509_OBJECT stmp,*tmp;
- char *postfix="";
+ c
onst c
har *postfix="";
if (name == NULL) return(0);
if (name == NULL) return(0);
@@
-335,8
+326,7
@@
X509_OBJECT *ret;
/* we have added it to the cache so now pull
* it out again */
CRYPTO_r_lock(CRYPTO_LOCK_X509_STORE);
/* we have added it to the cache so now pull
* it out again */
CRYPTO_r_lock(CRYPTO_LOCK_X509_STORE);
- tmp=(X509_OBJECT *)lh_retrieve(xl->store_ctx->certs,
- (char *)&stmp);
+ tmp=(X509_OBJECT *)lh_retrieve(xl->store_ctx->certs,&stmp);
CRYPTO_r_unlock(CRYPTO_LOCK_X509_STORE);
if (tmp != NULL)
CRYPTO_r_unlock(CRYPTO_LOCK_X509_STORE);
if (tmp != NULL)