Commit 26a3a48d authored by Richard Levitte's avatar Richard Levitte
Browse files

There have been a number of complaints from a number of sources that names

like Malloc, Realloc and especially Free conflict with already existing names
on some operating systems or other packages.  That is reason enough to change
the names of the OpenSSL memory allocation macros to something that has a
better chance of being unique, like prepending them with OPENSSL_.

This change includes all the name changes needed throughout all C files.
parent de42b6a7
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -91,8 +91,8 @@ int args_from_file(char *file, int *argc, char **argv[])
	*argv=NULL;

	len=(unsigned int)stbuf.st_size;
	if (buf != NULL) Free(buf);
	buf=(char *)Malloc(len+1);
	if (buf != NULL) OPENSSL_free(buf);
	buf=(char *)OPENSSL_malloc(len+1);
	if (buf == NULL) return(0);

	len=fread(buf,1,len,fp);
@@ -102,8 +102,8 @@ int args_from_file(char *file, int *argc, char **argv[])
	i=0;
	for (p=buf; *p; p++)
		if (*p == '\n') i++;
	if (arg != NULL) Free(arg);
	arg=(char **)Malloc(sizeof(char *)*(i*2));
	if (arg != NULL) OPENSSL_free(arg);
	arg=(char **)OPENSSL_malloc(sizeof(char *)*(i*2));

	*argv=arg;
	num=0;
@@ -266,7 +266,7 @@ int chopup_args(ARGS *arg, char *buf, int *argc, char **argv[])
	if (arg->count == 0)
		{
		arg->count=20;
		arg->data=(char **)Malloc(sizeof(char *)*arg->count);
		arg->data=(char **)OPENSSL_malloc(sizeof(char *)*arg->count);
		}
	for (i=0; i<arg->count; i++)
		arg->data[i]=NULL;
@@ -285,7 +285,7 @@ int chopup_args(ARGS *arg, char *buf, int *argc, char **argv[])
		if (num >= arg->count)
			{
			arg->count+=20;
			arg->data=(char **)Realloc(arg->data,
			arg->data=(char **)OPENSSL_realloc(arg->data,
				sizeof(char *)*arg->count);
			if (argc == 0) return(0);
			}
+1 −1
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ int MAIN(int argc, char **argv)
	argv++;
	if ((osk=sk_new_null()) == NULL)
		{
		BIO_printf(bio_err,"Malloc failure\n");
		BIO_printf(bio_err,"Memory allocation failure\n");
		goto end;
		}
	while (argc >= 1)
+25 −25
Original line number Diff line number Diff line
@@ -808,7 +808,7 @@ bad:
			{
			if ((f=BN_bn2hex(serial)) == NULL) goto err;
			BIO_printf(bio_err,"next serial number is %s\n",f);
			Free(f);
			OPENSSL_free(f);
			}

		if ((attribs=CONF_get_section(conf,policy)) == NULL)
@@ -819,7 +819,7 @@ bad:

		if ((cert_sk=sk_X509_new_null()) == NULL)
			{
			BIO_printf(bio_err,"Malloc failure\n");
			BIO_printf(bio_err,"Memory allocation failure\n");
			goto err;
			}
		if (spkac_file != NULL)
@@ -836,7 +836,7 @@ bad:
				if (!BN_add_word(serial,1)) goto err;
				if (!sk_X509_push(cert_sk,x))
					{
					BIO_printf(bio_err,"Malloc failure\n");
					BIO_printf(bio_err,"Memory allocation failure\n");
					goto err;
					}
				if (outfile)
@@ -860,7 +860,7 @@ bad:
				if (!BN_add_word(serial,1)) goto err;
				if (!sk_X509_push(cert_sk,x))
					{
					BIO_printf(bio_err,"Malloc failure\n");
					BIO_printf(bio_err,"Memory allocation failure\n");
					goto err;
					}
				}
@@ -879,7 +879,7 @@ bad:
				if (!BN_add_word(serial,1)) goto err;
				if (!sk_X509_push(cert_sk,x))
					{
					BIO_printf(bio_err,"Malloc failure\n");
					BIO_printf(bio_err,"Memory allocation failure\n");
					goto err;
					}
				}
@@ -898,7 +898,7 @@ bad:
				if (!BN_add_word(serial,1)) goto err;
				if (!sk_X509_push(cert_sk,x))
					{
					BIO_printf(bio_err,"Malloc failure\n");
					BIO_printf(bio_err,"Memory allocation failure\n");
					goto err;
					}
				}
@@ -1580,7 +1580,7 @@ static int do_body(X509 **xret, EVP_PKEY *pkey, X509 *x509, const EVP_MD *dgst,
	/* Ok, now we check the 'policy' stuff. */
	if ((subject=X509_NAME_new()) == NULL)
		{
		BIO_printf(bio_err,"Malloc failure\n");
		BIO_printf(bio_err,"Memory allocation failure\n");
		goto err;
		}

@@ -1678,7 +1678,7 @@ again2:
					{
					if (push != NULL)
						X509_NAME_ENTRY_free(push);
					BIO_printf(bio_err,"Malloc failure\n");
					BIO_printf(bio_err,"Memory allocation failure\n");
					goto err;
					}
				}
@@ -1700,7 +1700,7 @@ again2:
	row[DB_serial]=BN_bn2hex(serial);
	if ((row[DB_name] == NULL) || (row[DB_serial] == NULL))
		{
		BIO_printf(bio_err,"Malloc failure\n");
		BIO_printf(bio_err,"Memory allocation failure\n");
		goto err;
		}

@@ -1841,32 +1841,32 @@ again2:
		goto err;

	/* We now just add it to the database */
	row[DB_type]=(char *)Malloc(2);
	row[DB_type]=(char *)OPENSSL_malloc(2);

	tm=X509_get_notAfter(ret);
	row[DB_exp_date]=(char *)Malloc(tm->length+1);
	row[DB_exp_date]=(char *)OPENSSL_malloc(tm->length+1);
	memcpy(row[DB_exp_date],tm->data,tm->length);
	row[DB_exp_date][tm->length]='\0';

	row[DB_rev_date]=NULL;

	/* row[DB_serial] done already */
	row[DB_file]=(char *)Malloc(8);
	row[DB_file]=(char *)OPENSSL_malloc(8);
	/* row[DB_name] done already */

	if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) ||
		(row[DB_file] == NULL))
		{
		BIO_printf(bio_err,"Malloc failure\n");
		BIO_printf(bio_err,"Memory allocation failure\n");
		goto err;
		}
	strcpy(row[DB_file],"unknown");
	row[DB_type][0]='V';
	row[DB_type][1]='\0';

	if ((irow=(char **)Malloc(sizeof(char *)*(DB_NUMBER+1))) == NULL)
	if ((irow=(char **)OPENSSL_malloc(sizeof(char *)*(DB_NUMBER+1))) == NULL)
		{
		BIO_printf(bio_err,"Malloc failure\n");
		BIO_printf(bio_err,"Memory allocation failure\n");
		goto err;
		}

@@ -1886,7 +1886,7 @@ again2:
	ok=1;
err:
	for (i=0; i<DB_NUMBER; i++)
		if (row[i] != NULL) Free(row[i]);
		if (row[i] != NULL) OPENSSL_free(row[i]);

	if (CAname != NULL)
		X509_NAME_free(CAname);
@@ -2137,7 +2137,7 @@ static int do_revoke(X509 *x509, TXT_DB *db)
	BN_free(bn);
	if ((row[DB_name] == NULL) || (row[DB_serial] == NULL))
		{
		BIO_printf(bio_err,"Malloc failure\n");
		BIO_printf(bio_err,"Memory allocation failure\n");
		goto err;
		}
	/* We have to lookup by serial number because name lookup
@@ -2149,33 +2149,33 @@ static int do_revoke(X509 *x509, TXT_DB *db)
		BIO_printf(bio_err,"Adding Entry to DB for %s\n", row[DB_name]);

		/* We now just add it to the database */
		row[DB_type]=(char *)Malloc(2);
		row[DB_type]=(char *)OPENSSL_malloc(2);

		tm=X509_get_notAfter(x509);
		row[DB_exp_date]=(char *)Malloc(tm->length+1);
		row[DB_exp_date]=(char *)OPENSSL_malloc(tm->length+1);
		memcpy(row[DB_exp_date],tm->data,tm->length);
		row[DB_exp_date][tm->length]='\0';

		row[DB_rev_date]=NULL;

		/* row[DB_serial] done already */
		row[DB_file]=(char *)Malloc(8);
		row[DB_file]=(char *)OPENSSL_malloc(8);

		/* row[DB_name] done already */

		if ((row[DB_type] == NULL) || (row[DB_exp_date] == NULL) ||
			(row[DB_file] == NULL))
			{
			BIO_printf(bio_err,"Malloc failure\n");
			BIO_printf(bio_err,"Memory allocation failure\n");
			goto err;
			}
		strcpy(row[DB_file],"unknown");
		row[DB_type][0]='V';
		row[DB_type][1]='\0';

		if ((irow=(char **)Malloc(sizeof(char *)*(DB_NUMBER+1))) == NULL)
		if ((irow=(char **)OPENSSL_malloc(sizeof(char *)*(DB_NUMBER+1))) == NULL)
			{
			BIO_printf(bio_err,"Malloc failure\n");
			BIO_printf(bio_err,"Memory allocation failure\n");
			goto err;
			}

@@ -2218,7 +2218,7 @@ static int do_revoke(X509 *x509, TXT_DB *db)
		revtm=X509_gmtime_adj(revtm,0);
		rrow[DB_type][0]='R';
		rrow[DB_type][1]='\0';
		rrow[DB_rev_date]=(char *)Malloc(revtm->length+1);
		rrow[DB_rev_date]=(char *)OPENSSL_malloc(revtm->length+1);
		memcpy(rrow[DB_rev_date],revtm->data,revtm->length);
		rrow[DB_rev_date][revtm->length]='\0';
		ASN1_UTCTIME_free(revtm);
@@ -2228,7 +2228,7 @@ err:
	for (i=0; i<DB_NUMBER; i++)
		{
		if (row[i] != NULL) 
			Free(row[i]);
			OPENSSL_free(row[i]);
		}
	return(ok);
}
+2 −2
Original line number Diff line number Diff line
@@ -220,7 +220,7 @@ bad:
	if (crl != NULL)
		{
		sk_X509_CRL_push(crl_stack,crl);
		crl=NULL; /* now part of p7 for Freeing */
		crl=NULL; /* now part of p7 for OPENSSL_freeing */
		}

	if ((cert_stack=sk_X509_new(NULL)) == NULL) goto end;
@@ -327,7 +327,7 @@ static int add_certs_from_file(STACK_OF(X509) *stack, char *certfile)

	ret=count;
end:
 	/* never need to Free x */
 	/* never need to OPENSSL_free x */
	if (in != NULL) BIO_free(in);
	if (sk != NULL) sk_X509_INFO_free(sk);
	return(ret);
+2 −2
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ int MAIN(int argc, char **argv)

	apps_startup();

	if ((buf=(unsigned char *)Malloc(BUFSIZE)) == NULL)
	if ((buf=(unsigned char *)OPENSSL_malloc(BUFSIZE)) == NULL)
		{
		BIO_printf(bio_err,"out of memory\n");
		goto end;
@@ -192,7 +192,7 @@ end:
	if (buf != NULL)
		{
		memset(buf,0,BUFSIZE);
		Free(buf);
		OPENSSL_free(buf);
		}
	if (in != NULL) BIO_free(in);
	if (bmd != NULL) BIO_free(bmd);
Loading