Some more changes for renaming the binary from ssleay to openssl.
[openssl.git] / apps / crl.c
index 9642ee52684b9eb4eef0dfd11bc9607f5551ce60..acb5cb9b243863379f5dba33d0efc522829d124a 100644 (file)
@@ -1,5 +1,5 @@
 /* apps/crl.c */
-/* Copyright (C) 1995-1997 Eric Young (eay@cryptsoft.com)
+/* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com)
  * All rights reserved.
  *
  * This package is an SSL implementation written
 #undef POSTFIX
 #define        POSTFIX ".rvk"
 
-#define FORMAT_UNDEF   0
-#define FORMAT_ASN1    1
-#define FORMAT_TEXT    2
-#define FORMAT_PEM     3
-
 static char *crl_usage[]={
 "usage: crl args\n",
 "\n",
@@ -109,7 +104,6 @@ char **argv;
        BIO *out=NULL;
        int informat,outformat;
        char *infile=NULL,*outfile=NULL;
-       char *str=NULL;
        int hash=0,issuer=0,lastupdate=0,nextupdate=0,noout=0;
        char **pp,buf[256];
 
@@ -117,7 +111,7 @@ char **argv;
 
        if (bio_err == NULL)
                if ((bio_err=BIO_new(BIO_s_file())) != NULL)
-                       BIO_set_fp(bio_err,stderr,BIO_NOCLOSE);
+                       BIO_set_fp(bio_err,stderr,BIO_NOCLOSE|BIO_FP_TEXT);
 
        if (bio_out == NULL)
                if ((bio_out=BIO_new(BIO_s_file())) != NULL)
@@ -209,7 +203,7 @@ bad:
                        if (issuer == i)
                                {
                                X509_NAME_oneline(x->crl->issuer,buf,256);
-                               fprintf(stdout,"issuer= %s\n",str);
+                               fprintf(stdout,"issuer= %s\n",buf);
                                }
 
                        if (hash == i)
@@ -226,7 +220,10 @@ bad:
                        if (nextupdate == i)
                                {
                                fprintf(stdout,"nextUpdate=");
-                               ASN1_UTCTIME_print(bio_out,x->crl->nextUpdate);
+                               if (x->crl->nextUpdate != NULL)
+                                       ASN1_UTCTIME_print(bio_out,x->crl->nextUpdate);
+                               else
+                                       fprintf(stdout,"NONE");
                                fprintf(stdout,"\n");
                                }
                        }
@@ -259,8 +256,10 @@ bad:
        else if (outformat == FORMAT_TEXT)
                {
                X509_REVOKED *r;
+               STACK *sk;
 
-               while ((r=(X509_REVOKED *)sk_pop(x->crl->revoked)) != NULL)
+               sk=sk_dup(x->crl->revoked);
+               while ((r=(X509_REVOKED *)sk_pop(sk)) != NULL)
                        {
                        fprintf(stdout,"revoked: serialNumber=");
                        i2a_ASN1_INTEGER(out,r->serialNumber);
@@ -268,6 +267,7 @@ bad:
                        ASN1_UTCTIME_print(bio_out,r->revocationDate);
                        fprintf(stdout,"\n");
                        }
+               sk_free(sk);
                i=1;
                }
        else