]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
Changed the semantics of gnutls_pem_base64_encode_alloc()
authorNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 6 Dec 2002 17:28:35 +0000 (17:28 +0000)
committerNikos Mavrogiannopoulos <nmav@gnutls.org>
Fri, 6 Dec 2002 17:28:35 +0000 (17:28 +0000)
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().

NEWS
lib/x509_b64.c
libextra/auth_srp_sb64.c

diff --git a/NEWS b/NEWS
index ef4b7dfdf199231db8c48f2c1919c426333549c9..27ad88764886d43596f880ab05a4a33199d53e4e 100644 (file)
--- 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 
index 3df4fd7cdb79086b95cde15dcff6885c4b82bcce..538b3e7eadd338f7256147795d2018f8534b2b56 100644 (file)
@@ -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;
index 9408bd66987448a5b5ab2903758ca11d38e91b0f..2f3e313e8109fc7d144a9732712ede0bbb46d54c 100644 (file)
@@ -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;