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.
diff --git a/crypto/rsa/rsa_eay.c b/crypto/rsa/rsa_eay.c
index b7d2460..618b5bd 100644
--- a/crypto/rsa/rsa_eay.c
+++ b/crypto/rsa/rsa_eay.c
@@ -106,7 +106,7 @@
BN_init(&ret);
if ((ctx=BN_CTX_new()) == NULL) goto err;
num=BN_num_bytes(rsa->n);
- if ((buf=(unsigned char *)Malloc(num)) == NULL)
+ if ((buf=(unsigned char *)OPENSSL_malloc(num)) == NULL)
{
RSAerr(RSA_F_RSA_EAY_PUBLIC_ENCRYPT,ERR_R_MALLOC_FAILURE);
goto err;
@@ -161,7 +161,7 @@
if (buf != NULL)
{
memset(buf,0,num);
- Free(buf);
+ OPENSSL_free(buf);
}
return(r);
}
@@ -179,7 +179,7 @@
if ((ctx=BN_CTX_new()) == NULL) goto err;
num=BN_num_bytes(rsa->n);
- if ((buf=(unsigned char *)Malloc(num)) == NULL)
+ if ((buf=(unsigned char *)OPENSSL_malloc(num)) == NULL)
{
RSAerr(RSA_F_RSA_EAY_PRIVATE_ENCRYPT,ERR_R_MALLOC_FAILURE);
goto err;
@@ -237,7 +237,7 @@
if (buf != NULL)
{
memset(buf,0,num);
- Free(buf);
+ OPENSSL_free(buf);
}
return(r);
}
@@ -258,7 +258,7 @@
num=BN_num_bytes(rsa->n);
- if ((buf=(unsigned char *)Malloc(num)) == NULL)
+ if ((buf=(unsigned char *)OPENSSL_malloc(num)) == NULL)
{
RSAerr(RSA_F_RSA_EAY_PRIVATE_DECRYPT,ERR_R_MALLOC_FAILURE);
goto err;
@@ -330,7 +330,7 @@
if (buf != NULL)
{
memset(buf,0,num);
- Free(buf);
+ OPENSSL_free(buf);
}
return(r);
}
@@ -350,7 +350,7 @@
if (ctx == NULL) goto err;
num=BN_num_bytes(rsa->n);
- buf=(unsigned char *)Malloc(num);
+ buf=(unsigned char *)OPENSSL_malloc(num);
if (buf == NULL)
{
RSAerr(RSA_F_RSA_EAY_PUBLIC_DECRYPT,ERR_R_MALLOC_FAILURE);
@@ -402,7 +402,7 @@
if (buf != NULL)
{
memset(buf,0,num);
- Free(buf);
+ OPENSSL_free(buf);
}
return(r);
}
diff --git a/crypto/rsa/rsa_lib.c b/crypto/rsa/rsa_lib.c
index 88d93a4..bbddd3f 100644
--- a/crypto/rsa/rsa_lib.c
+++ b/crypto/rsa/rsa_lib.c
@@ -116,7 +116,7 @@
{
RSA *ret;
- ret=(RSA *)Malloc(sizeof(RSA));
+ ret=(RSA *)OPENSSL_malloc(sizeof(RSA));
if (ret == NULL)
{
RSAerr(RSA_F_RSA_NEW_METHOD,ERR_R_MALLOC_FAILURE);
@@ -147,7 +147,7 @@
ret->flags=ret->meth->flags;
if ((ret->meth->init != NULL) && !ret->meth->init(ret))
{
- Free(ret);
+ OPENSSL_free(ret);
ret=NULL;
}
else
@@ -188,8 +188,8 @@
if (r->dmq1 != NULL) BN_clear_free(r->dmq1);
if (r->iqmp != NULL) BN_clear_free(r->iqmp);
if (r->blinding != NULL) BN_BLINDING_free(r->blinding);
- if (r->bignum_data != NULL) Free_locked(r->bignum_data);
- Free(r);
+ if (r->bignum_data != NULL) OPENSSL_free_locked(r->bignum_data);
+ OPENSSL_free(r);
}
int RSA_get_ex_new_index(long argl, void *argp, CRYPTO_EX_new *new_func,
@@ -306,7 +306,7 @@
j=1;
for (i=0; i<6; i++)
j+= (*t[i])->top;
- if ((p=Malloc_locked((off+j)*sizeof(BN_ULONG))) == NULL)
+ if ((p=OPENSSL_malloc_locked((off+j)*sizeof(BN_ULONG))) == NULL)
{
RSAerr(RSA_F_MEMORY_LOCK,ERR_R_MALLOC_FAILURE);
return(0);
diff --git a/crypto/rsa/rsa_oaep.c b/crypto/rsa/rsa_oaep.c
index 1465c01..fd0b7f3 100644
--- a/crypto/rsa/rsa_oaep.c
+++ b/crypto/rsa/rsa_oaep.c
@@ -34,7 +34,7 @@
return (0);
}
- dbmask = Malloc(emlen - SHA_DIGEST_LENGTH);
+ dbmask = OPENSSL_malloc(emlen - SHA_DIGEST_LENGTH);
if (dbmask == NULL)
{
RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, ERR_R_MALLOC_FAILURE);
@@ -66,7 +66,7 @@
for (i = 0; i < SHA_DIGEST_LENGTH; i++)
seed[i] ^= seedmask[i];
- Free(dbmask);
+ OPENSSL_free(dbmask);
return (1);
}
@@ -86,7 +86,7 @@
}
dblen = num - SHA_DIGEST_LENGTH;
- db = Malloc(dblen);
+ db = OPENSSL_malloc(dblen);
if (db == NULL)
{
RSAerr(RSA_F_RSA_PADDING_ADD_PKCS1_OAEP, ERR_R_MALLOC_FAILURE);
@@ -128,7 +128,7 @@
memcpy(to, db + i, mlen);
}
}
- Free(db);
+ OPENSSL_free(db);
return (mlen);
}
diff --git a/crypto/rsa/rsa_saos.c b/crypto/rsa/rsa_saos.c
index 61efb0b..c77f438 100644
--- a/crypto/rsa/rsa_saos.c
+++ b/crypto/rsa/rsa_saos.c
@@ -81,7 +81,7 @@
RSAerr(RSA_F_RSA_SIGN_ASN1_OCTET_STRING,RSA_R_DIGEST_TOO_BIG_FOR_RSA_KEY);
return(0);
}
- s=(unsigned char *)Malloc((unsigned int)j+1);
+ s=(unsigned char *)OPENSSL_malloc((unsigned int)j+1);
if (s == NULL)
{
RSAerr(RSA_F_RSA_SIGN_ASN1_OCTET_STRING,ERR_R_MALLOC_FAILURE);
@@ -96,7 +96,7 @@
*siglen=i;
memset(s,0,(unsigned int)j+1);
- Free(s);
+ OPENSSL_free(s);
return(ret);
}
@@ -114,7 +114,7 @@
return(0);
}
- s=(unsigned char *)Malloc((unsigned int)siglen);
+ s=(unsigned char *)OPENSSL_malloc((unsigned int)siglen);
if (s == NULL)
{
RSAerr(RSA_F_RSA_VERIFY_ASN1_OCTET_STRING,ERR_R_MALLOC_FAILURE);
@@ -138,7 +138,7 @@
err:
if (sig != NULL) M_ASN1_OCTET_STRING_free(sig);
memset(s,0,(unsigned int)siglen);
- Free(s);
+ OPENSSL_free(s);
return(ret);
}
diff --git a/crypto/rsa/rsa_sign.c b/crypto/rsa/rsa_sign.c
index 05bb7fb..31049b9 100644
--- a/crypto/rsa/rsa_sign.c
+++ b/crypto/rsa/rsa_sign.c
@@ -115,7 +115,7 @@
return(0);
}
if(type != NID_md5_sha1) {
- s=(unsigned char *)Malloc((unsigned int)j+1);
+ s=(unsigned char *)OPENSSL_malloc((unsigned int)j+1);
if (s == NULL)
{
RSAerr(RSA_F_RSA_SIGN,ERR_R_MALLOC_FAILURE);
@@ -132,7 +132,7 @@
if(type != NID_md5_sha1) {
memset(s,0,(unsigned int)j+1);
- Free(s);
+ OPENSSL_free(s);
}
return(ret);
}
@@ -153,7 +153,7 @@
if(rsa->flags & RSA_FLAG_SIGN_VER)
return rsa->meth->rsa_verify(dtype, m, m_len, sigbuf, siglen, rsa);
- s=(unsigned char *)Malloc((unsigned int)siglen);
+ s=(unsigned char *)OPENSSL_malloc((unsigned int)siglen);
if (s == NULL)
{
RSAerr(RSA_F_RSA_VERIFY,ERR_R_MALLOC_FAILURE);
@@ -215,7 +215,7 @@
err:
if (sig != NULL) X509_SIG_free(sig);
memset(s,0,(unsigned int)siglen);
- Free(s);
+ OPENSSL_free(s);
return(ret);
}