Hi Jeff

Hmmm, I cannot reproduce this. Using the attached as a test case I see the
following output (i.e. no crashes):

Test one
Return code 0
Test two
<NULL> 1 (0x1)
Return code 1
Test three
Return code 0
Test four
1 (0x1)
Return code 1

The NULL bio should be checked ultimately in BIO_write before an attempt is
made to use it:

int BIO_write(BIO *b, const void *in, int inl)
{
int i;
long (*cb)(BIO *,int,const char *,int,long,long);

if (b == NULL)
return(0);

I checked this on master, and 1.0.1.

Please can you confirm which platform and release you are using.

Thanks

Matt

#include <openssl/bn.h>
#include <openssl/bio.h>
#include <openssl/evp.h>

void printErr(void) {
	
}

int main(void) {
	const char *label="label";
	char buffer[1024];
	BIGNUM *bn;
	int rc;

 	/* Load the human readable error strings for libcrypto */
	ERR_load_crypto_strings();

	BIO *bio = BIO_new_fp(stderr, BIO_NOCLOSE);

	bn = BN_new();
	BN_one(bn);

	fprintf(stderr,"Test one\n");
	rc = ASN1_bn_print(NULL, NULL, bn, buffer, 0);
	ERR_print_errors_fp(stderr);
	fprintf(stderr,"Return code %d\n", rc);

	fprintf(stderr,"Test two\n");
	rc = ASN1_bn_print(bio, NULL, bn, buffer, 0);
	ERR_print_errors_fp(stderr);
	fprintf(stderr,"Return code %d\n", rc);

	fprintf(stderr,"Test three\n");
	rc = ASN1_bn_print(NULL, label, bn, buffer, 0);
	ERR_print_errors_fp(stderr);
	fprintf(stderr,"Return code %d\n", rc);

	fprintf(stderr,"Test four\n");
	rc = ASN1_bn_print(bio, "", bn, buffer, 0);
	ERR_print_errors_fp(stderr);
	fprintf(stderr,"Return code %d\n", rc);

	BN_free(bn);
	BIO_free(bio);

	/* Remove error strings */
	ERR_free_strings();
}


Reply via email to