Ticket #4979: gnutls-3.3.1-gnutls_secure_malloc-1.patch
File gnutls-3.3.1-gnutls_secure_malloc-1.patch, 3.6 KB (added by , 11 years ago) |
---|
-
TabularUnified lib/gnutls_mem.c
Submitted By: Fernando de Oliveira <famobr at yahoo dot com dot br> Date: 2014-04-20 Initial Package Version: 3.3.1 Upstream Status: Not submitted Origin: self Description: Fix error : 'gnutls_secure_malloc' undeclared
old new 43 43 return ret; 44 44 } 45 45 46 svoid *gnutls_secure_calloc(size_t nmemb, size_t size) 47 { 48 svoid *ret; 49 size_t n = xtimes(nmemb, size); 50 ret = (size_in_bounds_p(n) ? gnutls_secure_malloc(n) : NULL); 51 if (ret != NULL) 52 memset(ret, 0, size); 53 return ret; 54 } 55 46 56 /* This realloc will free ptr in case realloc 47 57 * fails. 48 58 */ … … 72 82 return ret; 73 83 } 74 84 85 void _gnutls_bzero(void *mem, size_t size) 86 { 87 /* The reason we use that function instead of directly 88 * calling memset is to prevent the compiler 89 * optimizing out certain calls that may look 90 * pointless to him, but needed to erase 91 * private keys. */ 92 memset(mem, 0, size); 93 } 94 75 95 #if 0 76 96 /* don't use them. They are included for documentation. 77 97 */ -
TabularUnified lib/gnutls_mem.h
old new 23 23 #ifndef GNUTLS_MEM_H 24 24 #define GNUTLS_MEM_H 25 25 26 typedef void svoid; /* for functions that allocate using gnutls_secure_malloc */ 27 28 extern int (*_gnutls_is_secure_memory) (const void *); 29 26 30 /* this realloc function will return ptr if size==0, and 27 31 * will free the ptr if the new allocation failed. 28 32 */ 29 33 void *gnutls_realloc_fast(void *ptr, size_t size); 30 34 35 svoid *gnutls_secure_calloc(size_t nmemb, size_t size); 36 31 37 void *_gnutls_calloc(size_t nmemb, size_t size); 32 38 char *_gnutls_strdup(const char *); 33 39 40 void _gnutls_bzero(void *v, size_t n); 41 34 42 #define zrelease_mpi_key(mpi) if (*mpi!=NULL) { \ 35 43 _gnutls_mpi_clear(*mpi); \ 36 44 _gnutls_mpi_release(mpi); \ 37 45 } 38 46 39 void _gnutls_safe_memset(void *data, int c, size_t size); 40 41 #define zeroize_key(x, size) _gnutls_safe_memset(x, 0, size) 47 #define zeroize_key(x, size) _gnutls_bzero(x, size) 42 48 43 #define zeroize_temp_key zeroize_key 44 #define zrelease_temp_mpi_key zrelease_mpi_key 49 #ifdef ENABLE_FIPS140 50 # define zeroize_temp_key zeroize_key 51 # define zrelease_temp_mpi_key zrelease_mpi_key 52 #else 53 # define zeroize_temp_key(x, size) 54 # define zrelease_temp_mpi_key(mpi) _gnutls_mpi_release(mpi) 55 #endif 45 56 46 57 #endif /* GNUTLS_MEM_H */ -
TabularUnified lib/auth/rsa_psk.c
old new 148 145 gnutls_datum_t premaster_secret; 149 146 premaster_secret.size = GNUTLS_MASTER_SIZE; 150 147 premaster_secret.data = 151 gnutls_ malloc(premaster_secret.size);148 gnutls_secure_malloc(premaster_secret.size); 152 149 153 150 if (premaster_secret.data == NULL) { 154 151 gnutls_assert(); -
TabularUnified lib/includes/gnutls/gnutls.h.in
old new 1465 1465 1466 1466 /* For use in callbacks */ 1467 1467 extern gnutls_alloc_function gnutls_malloc; 1468 extern gnutls_alloc_function gnutls_secure_malloc; 1468 1469 extern gnutls_realloc_function gnutls_realloc; 1469 1470 extern gnutls_calloc_function gnutls_calloc; 1470 1471 extern gnutls_free_function gnutls_free; -
TabularUnified lib/libgnutls.map
old new 303 303 gnutls_rsa_params_import_pkcs1; 304 304 gnutls_rsa_params_import_raw; 305 305 gnutls_rsa_params_init; 306 gnutls_secure_calloc; 306 307 gnutls_secure_malloc; 307 308 gnutls_server_name_get; 308 309 gnutls_server_name_set;