Commit 645749ef authored by Richard Levitte's avatar Richard Levitte
Browse files

On VMS, stdout may very well lead to a file that is written to in a

record-oriented fashion.  That means that every write() will write a
separate record, which will be read separately by the programs trying
to read from it.  This can be very confusing.

The solution is to put a BIO filter in the way that will buffer text
until a linefeed is reached, and then write everything a line at a
time, so every record written will be an actual line, not chunks of
lines and not (usually doesn't happen, but I've seen it once) several
lines in one record.  Voila, BIO_f_linebuffer() is born.

Since we're so close to release time, I'm making this VMS-only for
now, just to make sure no code is needlessly broken by this.  After
the release, this BIO method will be enabled on all other platforms as
well.
parent 9a0c0d3f
Loading
Loading
Loading
Loading
+16 −0
Original line number Original line Diff line number Diff line
@@ -4,6 +4,22 @@


 Changes between 0.9.5a and 0.9.6  [xx XXX 2000]
 Changes between 0.9.5a and 0.9.6  [xx XXX 2000]


  *) On VMS, stdout may very well lead to a file that is written to
     in a record-oriented fashion.  That means that every write() will
     write a separate record, which will be read separately by the
     programs trying to read from it.  This can be very confusing.

     The solution is to put a BIO filter in the way that will buffer
     text until a linefeed is reached, and then write everything a
     line at a time, so every record written will be an actual line,
     not chunks of lines and not (usually doesn't happen, but I've
     seen it once) several lines in one record.  BIO_f_linebuffer() is
     the answer.

     Currently, it's a VMS-only method, because that's where it has
     been tested well enough.
     [Richard Levitte]

  *) Remove 'optimized' squaring variant in BN_mod_mul_montgomery,
  *) Remove 'optimized' squaring variant in BN_mod_mul_montgomery,
     it can return incorrect results.
     it can return incorrect results.
     (Note: The buggy variant was not enabled in OpenSSL 0.9.5a,
     (Note: The buggy variant was not enabled in OpenSSL 0.9.5a,
+7 −1
Original line number Original line Diff line number Diff line
@@ -206,6 +206,12 @@ bad:
		goto end;
		goto end;
		}
		}
	BIO_set_fp(out,stdout,BIO_NOCLOSE|BIO_FP_TEXT);
	BIO_set_fp(out,stdout,BIO_NOCLOSE|BIO_FP_TEXT);
#ifdef VMS
	{
	BIO *tmpbio = BIO_new(BIO_f_linebuffer());
	out = BIO_push(tmpbio, out);
	}
#endif


	if (oidfile != NULL)
	if (oidfile != NULL)
		{
		{
@@ -315,7 +321,7 @@ bad:
end:
end:
	BIO_free(derout);
	BIO_free(derout);
	if (in != NULL) BIO_free(in);
	if (in != NULL) BIO_free(in);
	if (out != NULL) BIO_free(out);
	if (out != NULL) BIO_free_all(out);
	if (b64 != NULL) BIO_free(b64);
	if (b64 != NULL) BIO_free(b64);
	if (ret != 0)
	if (ret != 0)
		ERR_print_errors(bio_err);
		ERR_print_errors(bio_err);
+19 −5
Original line number Original line Diff line number Diff line
@@ -690,6 +690,12 @@ bad:
	if (verbose)
	if (verbose)
		{
		{
		BIO_set_fp(out,stdout,BIO_NOCLOSE|BIO_FP_TEXT); /* cannot fail */
		BIO_set_fp(out,stdout,BIO_NOCLOSE|BIO_FP_TEXT); /* cannot fail */
#ifdef VMS
		{
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
		out = BIO_push(tmpbio, out);
		}
#endif
		TXT_DB_write(out,db);
		TXT_DB_write(out,db);
		BIO_printf(bio_err,"%d entries loaded from the database\n",
		BIO_printf(bio_err,"%d entries loaded from the database\n",
			db->data->num);
			db->data->num);
@@ -724,7 +730,15 @@ bad:
				}
				}
			}
			}
		else
		else
			{
			BIO_set_fp(Sout,stdout,BIO_NOCLOSE|BIO_FP_TEXT);
			BIO_set_fp(Sout,stdout,BIO_NOCLOSE|BIO_FP_TEXT);
#ifdef VMS
			{
			BIO *tmpbio = BIO_new(BIO_f_linebuffer());
			Sout = BIO_push(tmpbio, Sout);
			}
#endif
			}
		}
		}


	if (req)
	if (req)
@@ -1020,7 +1034,7 @@ bad:
#endif
#endif


			BIO_free(in);
			BIO_free(in);
			BIO_free(out);
			BIO_free_all(out);
			in=NULL;
			in=NULL;
			out=NULL;
			out=NULL;
			if (rename(serialfile,buf[2]) < 0)
			if (rename(serialfile,buf[2]) < 0)
@@ -1237,9 +1251,9 @@ bad:
	ret=0;
	ret=0;
err:
err:
	BIO_free(hex);
	BIO_free(hex);
	BIO_free(Cout);
	BIO_free_all(Cout);
	BIO_free(Sout);
	BIO_free_all(Sout);
	BIO_free(out);
	BIO_free_all(out);
	BIO_free(in);
	BIO_free(in);


	sk_X509_pop_free(cert_sk,X509_free);
	sk_X509_pop_free(cert_sk,X509_free);
@@ -1354,7 +1368,7 @@ static int save_serial(char *serialfile, BIGNUM *serial)
	BIO_puts(out,"\n");
	BIO_puts(out,"\n");
	ret=1;
	ret=1;
err:
err:
	if (out != NULL) BIO_free(out);
	if (out != NULL) BIO_free_all(out);
	if (ai != NULL) ASN1_INTEGER_free(ai);
	if (ai != NULL) ASN1_INTEGER_free(ai);
	return(ret);
	return(ret);
	}
	}
+7 −1
Original line number Original line Diff line number Diff line
@@ -108,6 +108,12 @@ int MAIN(int argc, char **argv)
	if (bio_err == NULL)
	if (bio_err == NULL)
		bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
		bio_err=BIO_new_fp(stderr,BIO_NOCLOSE);
	STDout=BIO_new_fp(stdout,BIO_NOCLOSE);
	STDout=BIO_new_fp(stdout,BIO_NOCLOSE);
#ifdef VMS
	{
	BIO *tmpbio = BIO_new(BIO_f_linebuffer());
	STDout = BIO_push(tmpbio, STDout);
	}
#endif


	argc--;
	argc--;
	argv++;
	argv++;
@@ -195,7 +201,7 @@ err:
end:
end:
	if (ctx != NULL) SSL_CTX_free(ctx);
	if (ctx != NULL) SSL_CTX_free(ctx);
	if (ssl != NULL) SSL_free(ssl);
	if (ssl != NULL) SSL_free(ssl);
	if (STDout != NULL) BIO_free(STDout);
	if (STDout != NULL) BIO_free_all(STDout);
	EXIT(ret);
	EXIT(ret);
	}
	}
+18 −2
Original line number Original line Diff line number Diff line
@@ -122,7 +122,15 @@ int MAIN(int argc, char **argv)


	if (bio_out == NULL)
	if (bio_out == NULL)
		if ((bio_out=BIO_new(BIO_s_file())) != NULL)
		if ((bio_out=BIO_new(BIO_s_file())) != NULL)
			{
			BIO_set_fp(bio_out,stdout,BIO_NOCLOSE);
			BIO_set_fp(bio_out,stdout,BIO_NOCLOSE);
#ifdef VMS
			{
			BIO *tmpbio = BIO_new(BIO_f_linebuffer());
			bio_out = BIO_push(tmpbio, bio_out);
			}
#endif
			}


	informat=FORMAT_PEM;
	informat=FORMAT_PEM;
	outformat=FORMAT_PEM;
	outformat=FORMAT_PEM;
@@ -314,7 +322,15 @@ bad:
		}
		}


	if (outfile == NULL)
	if (outfile == NULL)
		{
		BIO_set_fp(out,stdout,BIO_NOCLOSE);
		BIO_set_fp(out,stdout,BIO_NOCLOSE);
#ifdef VMS
		{
		BIO *tmpbio = BIO_new(BIO_f_linebuffer());
		out = BIO_push(tmpbio, out);
		}
#endif
		}
	else
	else
		{
		{
		if (BIO_write_filename(out,outfile) <= 0)
		if (BIO_write_filename(out,outfile) <= 0)
@@ -340,8 +356,8 @@ bad:
	if (!i) { BIO_printf(bio_err,"unable to write CRL\n"); goto end; }
	if (!i) { BIO_printf(bio_err,"unable to write CRL\n"); goto end; }
	ret=0;
	ret=0;
end:
end:
	BIO_free(out);
	BIO_free_all(out);
	BIO_free(bio_out);
	BIO_free_all(bio_out);
	bio_out=NULL;
	bio_out=NULL;
	X509_CRL_free(x);
	X509_CRL_free(x);
	if(store) {
	if(store) {
Loading