diff options
author | Simon Josefsson <simon@josefsson.org> | 2008-04-17 11:41:17 +0200 |
---|---|---|
committer | Simon Josefsson <simon@josefsson.org> | 2008-04-17 11:41:17 +0200 |
commit | 595b45ed9162701d8b62e301afaebbee56cbb138 (patch) | |
tree | 5de9632f97fb788696586b05edffd9947b3182db /lib/gnutls_pk.c | |
parent | 37f27eeb6694288d1985eb89c3fa1f4d0fc6c3e6 (diff) | |
download | gnutls-595b45ed9162701d8b62e301afaebbee56cbb138.tar.gz |
Remove all uses of gnutls_alloca/gnutls_afree.
Use normal gnutls_malloc instead. One reason is increased portability
to Windows, the other is that several of the uses may be unsafe
because the size of data allocated could be large. Reported by
Massimo Gaspari <massimo.gaspari@alice.it> in
<http://permalink.gmane.org/gmane.network.gnutls.general/1170>.
Diffstat (limited to 'lib/gnutls_pk.c')
-rw-r--r-- | lib/gnutls_pk.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/gnutls_pk.c b/lib/gnutls_pk.c index f9f4d4d499..5e31804419 100644 --- a/lib/gnutls_pk.c +++ b/lib/gnutls_pk.c @@ -75,7 +75,7 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext, return GNUTLS_E_PK_ENCRYPTION_FAILED; } - edata = gnutls_alloca (k); + edata = gnutls_malloc (k); if (edata == NULL) { gnutls_assert (); @@ -98,7 +98,7 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext, if (params_len < RSA_PUBLIC_PARAMS) { gnutls_assert (); - gnutls_afree (edata); + gnutls_free (edata); return GNUTLS_E_INTERNAL_ERROR; } @@ -106,7 +106,7 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext, if ( ret < 0) { gnutls_assert (); - gnutls_afree (edata); + gnutls_free (edata); return ret; } for (i = 0; i < psize; i++) @@ -116,7 +116,7 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext, if (ret < 0) { gnutls_assert (); - gnutls_afree (edata); + gnutls_free (edata); return ret; } } @@ -127,7 +127,7 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext, if (params_len < RSA_PRIVATE_PARAMS) { gnutls_assert (); - gnutls_afree (edata); + gnutls_free (edata); return GNUTLS_E_INTERNAL_ERROR; } @@ -136,7 +136,7 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext, break; default: gnutls_assert (); - gnutls_afree (edata); + gnutls_free (edata); return GNUTLS_E_INTERNAL_ERROR; } @@ -146,10 +146,10 @@ _gnutls_pkcs1_rsa_encrypt (gnutls_datum_t * ciphertext, if (_gnutls_mpi_scan_nz (&m, edata, &k) != 0) { gnutls_assert (); - gnutls_afree (edata); + gnutls_free (edata); return GNUTLS_E_MPI_SCAN_FAILED; } - gnutls_afree (edata); + gnutls_free (edata); if (btype == 2) /* encrypt */ ret = _gnutls_pk_encrypt (GCRY_PK_RSA, &res, m, params, params_len); @@ -256,7 +256,7 @@ _gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext, } _gnutls_mpi_print (NULL, &esize, res); - edata = gnutls_alloca (esize + 1); + edata = gnutls_malloc (esize + 1); if (edata == NULL) { gnutls_assert (); @@ -283,7 +283,7 @@ _gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext, if (edata[0] != 0 || edata[1] != btype) { gnutls_assert (); - gnutls_afree (edata); + gnutls_free (edata); return GNUTLS_E_DECRYPTION_FAILED; } @@ -319,7 +319,7 @@ _gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext, break; default: gnutls_assert (); - gnutls_afree (edata); + gnutls_free (edata); break; } i++; @@ -327,18 +327,18 @@ _gnutls_pkcs1_rsa_decrypt (gnutls_datum_t * plaintext, if (ret < 0) { gnutls_assert (); - gnutls_afree (edata); + gnutls_free (edata); return GNUTLS_E_DECRYPTION_FAILED; } if (_gnutls_sset_datum (plaintext, &edata[i], esize - i) < 0) { gnutls_assert (); - gnutls_afree (edata); + gnutls_free (edata); return GNUTLS_E_MEMORY_ERROR; } - gnutls_afree (edata); + gnutls_free (edata); return 0; } |