From: Nikos Mavrogiannopoulos Date: Fri, 6 Dec 2002 17:28:35 +0000 (+0000) Subject: Changed the semantics of gnutls_pem_base64_encode_alloc() X-Git-Tag: gnutls_0_6_0~16 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e9ba5c4963ce480ffa49cb74d2ae3d985a097df0;p=thirdparty%2Fgnutls.git Changed the semantics of gnutls_pem_base64_encode_alloc() and gnutls_pem_base64_decode_alloc(). In the default case were the gnutls library is used with malloc/realloc/free, these are binary compatible. They now require the returned data to be freed using the gnutls_global_get_free_function(). --- diff --git a/NEWS b/NEWS index ef4b7dfdf1..27ad887648 100644 --- a/NEWS +++ b/NEWS @@ -18,6 +18,10 @@ Version 0.5.12 gnutls_get_malloc_function() gnutls_get_free_function() to be used in callbacks. +- Changed the semantics of gnutls_pem_base64_encode_alloc() + and gnutls_pem_base64_decode_alloc(). In the default case + were the gnutls library is used with malloc/realloc/free, + these are binary compatible. Version 0.5.11 (5/11/2002) - Some fixes in 'gnutls-cli' client program to prevent some segmentation diff --git a/lib/x509_b64.c b/lib/x509_b64.c index 3df4fd7cdb..538b3e7ead 100644 --- a/lib/x509_b64.c +++ b/lib/x509_b64.c @@ -291,7 +291,10 @@ int size; * * This function will convert the given data to printable data, using the base64 * encoding. This is the encoding used in PEM messages. This function will - * allocate (using malloc) the required memory to hold the encoded data. + * allocate the required memory to hold the encoded data. + * + * You should use the function returned by gnutls_global_get_free_function() to + * free the returned data. * **/ int gnutls_pem_base64_encode_alloc( const char* msg, const gnutls_datum *data, @@ -308,18 +311,8 @@ int size, res; gnutls_free(ret); return GNUTLS_E_INVALID_REQUEST; } else { - if (gnutls_malloc==malloc) { - result->data = ret; - result->size = size; - } else { - res = _gnutls_set_datum_m( result, ret, size, malloc); - gnutls_free(ret); - - if (res < 0) { - gnutls_assert(); - return res; - } - } + result->data = ret; + result->size = size; } return 0; @@ -508,11 +501,14 @@ int size; * @result: the place where decoded data lie * * This function will decode the given encoded data. The decoded data - * will be allocated, using malloc, and stored into result. + * will be allocated, and stored into result. * If the header given is non null this function will search for * "-----BEGIN header" and decode only this part. Otherwise it will decode the * first PEM packet found. * + * You should use the function returned by gnutls_global_get_free_function() to + * free the returned data. + * * Note that b64_data should be null terminated. * **/ @@ -530,18 +526,8 @@ int size, res; gnutls_free(ret); return GNUTLS_E_INVALID_REQUEST; } else { - if (gnutls_malloc==malloc) { - result->data = ret; - result->size = size; - } else { - res = _gnutls_set_datum_m( result, ret, size, malloc); - gnutls_free( ret); - - if (res < 0) { - gnutls_assert(); - return res; - } - } + result->data = ret; + result->size = size; } return 0; diff --git a/libextra/auth_srp_sb64.c b/libextra/auth_srp_sb64.c index 9408bd6698..2f3e313e81 100644 --- a/libextra/auth_srp_sb64.c +++ b/libextra/auth_srp_sb64.c @@ -313,7 +313,10 @@ int size; * * This function will convert the given data to printable data, using the base64 * encoding. This is the encoding used in SRP password files. This function will - * allocate (using malloc) the required memory to hold the encoded data. + * allocate the required memory to hold the encoded data. + * + * You should use the function returned by gnutls_global_get_free_function() to + * free the returned data. * **/ int gnutls_srp_base64_encode_alloc( const gnutls_datum *data, @@ -330,18 +333,8 @@ int size, res; gnutls_free(ret); return GNUTLS_E_INVALID_REQUEST; } else { - if (gnutls_malloc==malloc) { - result->data = ret; - result->size = size; - } else { - res = _gnutls_set_datum_m( result, ret, size, malloc); - gnutls_free(ret); - - if (res < 0) { - gnutls_assert(); - return res; - } - } + result->data = ret; + result->size = size; } return 0; @@ -389,8 +382,11 @@ int size; * @result: the place where decoded data lie * * This function will decode the given encoded data. The decoded data - * will be allocated, using malloc, and stored into result. + * will be allocated, and stored into result. * It will decode using the base64 algorithm found in libsrp. + * + * You should use the function returned by gnutls_global_get_free_function() to + * free the returned data. * **/ int gnutls_srp_base64_decode_alloc( const gnutls_datum *b64_data, @@ -407,18 +403,8 @@ int size, res; gnutls_free(ret); return GNUTLS_E_INVALID_REQUEST; } else { - if (gnutls_malloc==malloc) { - result->data = ret; - result->size = size; - } else { - res = _gnutls_set_datum_m( result, ret, size, malloc); - gnutls_free( ret); - - if (res < 0) { - gnutls_assert(); - return res; - } - } + result->data = ret; + result->size = size; } return 0;