On VMS, stdout may very well lead to a file that is written to in a
[openssl.git] / apps / dsaparam.c
index 47d92cc10d7b65507f42ad2f60e2148d3f81cacc..f861ec7b1ad8cf2d1c6e31b70b5c85d30f2974a2 100644 (file)
@@ -85,6 +85,9 @@
  */
 
 static void MS_CALLBACK dsa_cb(int p, int n, void *arg);
+
+int MAIN(int, char **);
+
 int MAIN(int argc, char **argv)
        {
        DSA *dsa=NULL;
@@ -202,7 +205,15 @@ bad:
                        }
                }
        if (outfile == NULL)
+               {
                BIO_set_fp(out,stdout,BIO_NOCLOSE);
+#ifdef VMS
+               {
+               BIO *tmpbio = BIO_new(BIO_f_linebuffer());
+               out = BIO_push(tmpbio, out);
+               }
+#endif
+               }
        else
                {
                if (BIO_write_filename(out,outfile) <= 0)
@@ -257,10 +268,10 @@ bad:
                bits_p=BN_num_bits(dsa->p);
                bits_q=BN_num_bits(dsa->q);
                bits_g=BN_num_bits(dsa->g);
-               data=(unsigned char *)Malloc(len+20);
+               data=(unsigned char *)OPENSSL_malloc(len+20);
                if (data == NULL)
                        {
-                       perror("Malloc");
+                       perror("OPENSSL_malloc");
                        goto end;
                        }
                l=BN_bn2bin(dsa->p,data);
@@ -317,7 +328,7 @@ bad:
                        }
                if (!i)
                        {
-                       BIO_printf(bio_err,"unable to write DSA paramaters\n");
+                       BIO_printf(bio_err,"unable to write DSA parameters\n");
                        ERR_print_errors(bio_err);
                        goto end;
                        }
@@ -344,7 +355,7 @@ bad:
        ret=0;
 end:
        if (in != NULL) BIO_free(in);
-       if (out != NULL) BIO_free(out);
+       if (out != NULL) BIO_free_all(out);
        if (dsa != NULL) DSA_free(dsa);
        EXIT(ret);
        }