PR: 2069
[openssl.git] / apps / apps.c
index b04bfbd3c3460ce6cad070ad47f59aa593860974..09d9df2817a7e669f7b2a92279b9a998b5fcb79b 100644 (file)
  *
  */
 
  *
  */
 
+#ifndef _POSIX_C_SOURCE
 #define _POSIX_C_SOURCE 2      /* On VMS, you need to define this to get
                                   the declaration of fileno().  The value
                                   2 is to make sure no function defined
                                   in POSIX-2 is left undefined. */
 #define _POSIX_C_SOURCE 2      /* On VMS, you need to define this to get
                                   the declaration of fileno().  The value
                                   2 is to make sure no function defined
                                   in POSIX-2 is left undefined. */
+#endif
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#ifndef OPENSSL_SYSNAME_WIN32
+#if !defined(OPENSSL_SYSNAME_WIN32) && !defined(NETWARE_CLIB)
 #include <strings.h>
 #endif
 #include <sys/types.h>
 #include <strings.h>
 #endif
 #include <sys/types.h>
@@ -1486,7 +1488,7 @@ char *make_config_name()
        return p;
        }
 
        return p;
        }
 
-static unsigned long index_serial_hash(const CSTRING *a)
+static unsigned long index_serial_hash(const OPENSSL_CSTRING *a)
        {
        const char *n;
 
        {
        const char *n;
 
@@ -1495,7 +1497,7 @@ static unsigned long index_serial_hash(const CSTRING *a)
        return(lh_strhash(n));
        }
 
        return(lh_strhash(n));
        }
 
-static int index_serial_cmp(const CSTRING *a, const CSTRING *b)
+static int index_serial_cmp(const OPENSSL_CSTRING *a, const OPENSSL_CSTRING *b)
        {
        const char *aa,*bb;
 
        {
        const char *aa,*bb;
 
@@ -1507,16 +1509,16 @@ static int index_serial_cmp(const CSTRING *a, const CSTRING *b)
 static int index_name_qual(char **a)
        { return(a[0][0] == 'V'); }
 
 static int index_name_qual(char **a)
        { return(a[0][0] == 'V'); }
 
-static unsigned long index_name_hash(const CSTRING *a)
+static unsigned long index_name_hash(const OPENSSL_CSTRING *a)
        { return(lh_strhash(a[DB_name])); }
 
        { return(lh_strhash(a[DB_name])); }
 
-int index_name_cmp(const CSTRING *a, const CSTRING *b)
+int index_name_cmp(const OPENSSL_CSTRING *a, const OPENSSL_CSTRING *b)
        { return(strcmp(a[DB_name], b[DB_name])); }
 
        { return(strcmp(a[DB_name], b[DB_name])); }
 
-static IMPLEMENT_LHASH_HASH_FN(index_serial, CSTRING)
-static IMPLEMENT_LHASH_COMP_FN(index_serial, CSTRING)
-static IMPLEMENT_LHASH_HASH_FN(index_name, CSTRING)
-static IMPLEMENT_LHASH_COMP_FN(index_name, CSTRING)
+static IMPLEMENT_LHASH_HASH_FN(index_serial, OPENSSL_CSTRING)
+static IMPLEMENT_LHASH_COMP_FN(index_serial, OPENSSL_CSTRING)
+static IMPLEMENT_LHASH_HASH_FN(index_name, OPENSSL_CSTRING)
+static IMPLEMENT_LHASH_COMP_FN(index_name, OPENSSL_CSTRING)
 
 #undef BSIZE
 #define BSIZE 256
 
 #undef BSIZE
 #define BSIZE 256
@@ -2190,7 +2192,7 @@ int args_verify(char ***pargs, int *pargc,
        ASN1_OBJECT *otmp = NULL;
        unsigned long flags = 0;
        int i;
        ASN1_OBJECT *otmp = NULL;
        unsigned long flags = 0;
        int i;
-       int purpose = 0;
+       int purpose = 0, depth = -1;
        char **oldargs = *pargs;
        char *arg = **pargs, *argn = (*pargs)[1];
        if (!strcmp(arg, "-policy"))
        char **oldargs = *pargs;
        char *arg = **pargs, *argn = (*pargs)[1];
        if (!strcmp(arg, "-policy"))
@@ -2230,6 +2232,21 @@ int args_verify(char ***pargs, int *pargc,
                        }
                (*pargs)++;
                }
                        }
                (*pargs)++;
                }
+       else if (strcmp(arg,"-verify_depth") == 0)
+               {
+               if (!argn)
+                       *badarg = 1;
+               else
+                       {
+                       depth = atoi(argn);
+                       if(depth < 0)
+                               {
+                               BIO_printf(err, "invalid depth\n");
+                               *badarg = 1;
+                               }
+                       }
+               (*pargs)++;
+               }
        else if (!strcmp(arg, "-ignore_critical"))
                flags |= X509_V_FLAG_IGNORE_CRITICAL;
        else if (!strcmp(arg, "-issuer_checks"))
        else if (!strcmp(arg, "-ignore_critical"))
                flags |= X509_V_FLAG_IGNORE_CRITICAL;
        else if (!strcmp(arg, "-issuer_checks"))
@@ -2254,6 +2271,8 @@ int args_verify(char ***pargs, int *pargc,
                flags |= X509_V_FLAG_USE_DELTAS;
        else if (!strcmp(arg, "-policy_print"))
                flags |= X509_V_FLAG_NOTIFY_POLICY;
                flags |= X509_V_FLAG_USE_DELTAS;
        else if (!strcmp(arg, "-policy_print"))
                flags |= X509_V_FLAG_NOTIFY_POLICY;
+       else if (!strcmp(arg, "-check_ss_sig"))
+               flags |= X509_V_FLAG_CHECK_SS_SIGNATURE;
        else
                return 0;
 
        else
                return 0;
 
@@ -2279,6 +2298,9 @@ int args_verify(char ***pargs, int *pargc,
        if (purpose)
                X509_VERIFY_PARAM_set_purpose(*pm, purpose);
 
        if (purpose)
                X509_VERIFY_PARAM_set_purpose(*pm, purpose);
 
+       if (depth >= 0)
+               X509_VERIFY_PARAM_set_depth(*pm, depth);
+
        end:
 
        (*pargs)++;
        end:
 
        (*pargs)++;