Break circular dependency between pem and err.
[openssl.git] / crypto / err / err.c
index a65192493af3acab7bc0f2bdd151469ae87a109c..fcd92284e086177c6e984b59ffe71f62e4d5db46 100644 (file)
@@ -81,6 +81,7 @@ static unsigned long err_hash();
 static int err_cmp();
 static unsigned long pid_hash();
 static int pid_cmp();
+static unsigned long get_error_values();
 static void ERR_STATE_free();
 ERR_STATE *s;
 #endif
@@ -107,6 +108,7 @@ static ERR_STRING_DATA ERR_str_libraries[]=
 {ERR_PACK(ERR_LIB_PROXY,0,0)           ,"Proxy routines"},
 {ERR_PACK(ERR_LIB_BIO,0,0)             ,"BIO routines"},
 {ERR_PACK(ERR_LIB_PKCS7,0,0)           ,"PKCS7 routines"},
+{ERR_PACK(ERR_LIB_X509V3,0,0)          ,"X509 V3 routines"},
 {0,NULL},
        };
 
@@ -148,6 +150,14 @@ static ERR_STRING_DATA ERR_str_reasons[]=
 {ERR_R_PKCS7_LIB                       ,"PKCS7 lib"},
 {ERR_R_MALLOC_FAILURE                  ,"Malloc failure"},
 {ERR_R_SHOULD_NOT_HAVE_BEEN_CALLED     ,"called a fuction you should not call"},
+{ERR_R_PASSED_NULL_PARAMETER           ,"passed a null parameter"},
+{ERR_R_NESTED_ASN1_ERROR               ,"nested asn1 error"},
+{ERR_R_BAD_ASN1_OBJECT_HEADER          ,"bad asn1 object header"},
+{ERR_R_BAD_GET_ASN1_OBJECT_CALL                ,"bad get asn1 object call"},
+{ERR_R_EXPECTING_AN_ASN1_SEQUENCE      ,"expecting an asn1 sequence"},
+{ERR_R_ASN1_LENGTH_MISMATCH            ,"asn1 length mismatch"},
+{ERR_R_MISSING_ASN1_EOS                        ,"missing asn1 eos"},
+
 {0,NULL},
        };
 #endif
@@ -166,6 +176,9 @@ ERR_STATE *s;
        {
        int i;
 
+       if(s == NULL)
+           return;
+
        for (i=0; i<ERR_NUM_ERRORS; i++)
                {
                err_clear_data(s,i);
@@ -539,7 +552,9 @@ ERR_STATE *ERR_get_state()
                CRYPTO_w_lock(CRYPTO_LOCK_ERR);
                if (thread_hash == NULL)
                        {
+                       MemCheck_off();
                        thread_hash=lh_new(pid_hash,pid_cmp);
+                       MemCheck_on();
                        CRYPTO_w_unlock(CRYPTO_LOCK_ERR);
                        if (thread_hash == NULL) return(&fallback);
                        }
@@ -618,20 +633,24 @@ VAR_ALIST
        for (i=0; i<num; i++)
                {
                VAR_ARG(args,char *,a);
-               n+=strlen(a);
-               if (n > s)
+               /* ignore NULLs, thanks to Bob Beck <beck@obtuse.com> */
+               if (a != NULL)
                        {
-                       s=n+20;
-                       p=Realloc(str,s+1);
-                       if (p == NULL)
+                       n+=strlen(a);
+                       if (n > s)
                                {
-                               Free(str);
-                               return;
+                               s=n+20;
+                               p=Realloc(str,s+1);
+                               if (p == NULL)
+                                       {
+                                       Free(str);
+                                       return;
+                                       }
+                               else
+                                       str=p;
                                }
-                       else
-                               str=p;
+                       strcat(str,a);
                        }
-               strcat(str,a);
                }
        ERR_set_error_data(str,ERR_TXT_MALLOCED|ERR_TXT_STRING);