diff options
Diffstat (limited to 'util')
-rw-r--r-- | util/ChangeLog | 12 | ||||
-rw-r--r-- | util/logger.c | 4 | ||||
-rw-r--r-- | util/memory.c | 28 | ||||
-rw-r--r-- | util/riscos.c | 1 |
4 files changed, 34 insertions, 11 deletions
diff --git a/util/ChangeLog b/util/ChangeLog index d8553456f..673476291 100644 --- a/util/ChangeLog +++ b/util/ChangeLog @@ -1,3 +1,15 @@ +2002-05-10 Stefan Bellon <[email protected]> + + * memory.c (add_entry) [M_DEBUG]: Added some missing EXTRA_ALIGN. + (free_entry) [M_DEBUG]: Free secure memory via secmem_free. + (alloc_secure): Malloc at least 1 byte. + (realloc) [M_GUARD]: Added missing FNAMEARG to function call. + + * logger.c (g10_log_bug0) [__riscos__]: Make use of first + g10_log_bug0 function for later Norcroft compiler. + + * riscos.c: Added stdlib.h include. + 2002-05-04 Werner Koch <[email protected]> * http.c (write_server) [__MINGW32__]: Replaced WriteFile by send diff --git a/util/logger.c b/util/logger.c index 2e9fad5c6..a51455798 100644 --- a/util/logger.c +++ b/util/logger.c @@ -241,8 +241,8 @@ g10_log_bug( const char *fmt, ... ) abort(); } -#if !defined (__riscos__) \ - && ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )) +#if defined (__riscos__) \ + || ( __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 5 )) void g10_log_bug0( const char *file, int line, const char *func ) { diff --git a/util/memory.c b/util/memory.c index fb099f852..9fab9ea3b 100644 --- a/util/memory.c +++ b/util/memory.c @@ -78,7 +78,7 @@ info, __FUNCTION__); } while(0) #else #define store_len(p,n,m) do { add_entry(p,n,m, \ - info, "[" __FILE__ ":" STR(__LINE__) "]" ); } while(0) + info, __func__ ); } while(0) #endif #else #define FNAME(a) m_ ##a @@ -175,7 +175,7 @@ add_entry( byte *p, unsigned n, int mode, const char *info, const char *by ) e = memtbl+index; if( e->inuse ) membug("Ooops: entry %u is flagged as in use\n", index); - e->user_p = p + 4; + e->user_p = p + EXTRA_ALIGN + 4; e->user_n = n; e->count++; if( e->next ) @@ -197,10 +197,10 @@ add_entry( byte *p, unsigned n, int mode, const char *info, const char *by ) e->inuse = 1; /* put the index at the start of the memory */ - p[0] = index; - p[1] = index >> 8 ; - p[2] = index >> 16 ; - p[3] = mode? MAGIC_SEC_BYTE : MAGIC_NOR_BYTE ; + p[EXTRA_ALIGN+0] = index; + p[EXTRA_ALIGN+1] = index >> 8 ; + p[EXTRA_ALIGN+2] = index >> 16 ; + p[EXTRA_ALIGN+3] = mode? MAGIC_SEC_BYTE : MAGIC_NOR_BYTE ; if( DBG_MEMORY ) log_debug( "%s allocates %u bytes using %s\n", info, e->user_n, by ); } @@ -277,8 +277,12 @@ free_entry( byte *p, const char *info ) ; e2->next = e; } - memset(p,'f', e->user_n+5); - free(p); + if( m_is_secure(p+EXTRA_ALIGN+4) ) + secmem_free(p); + else { + memset(p,'f', e->user_n+5); + free(p); + } } static void @@ -444,12 +448,18 @@ FNAME(alloc_secure)( size_t n FNAMEPRT ) char *p; #ifdef M_GUARD + if(!n) + out_of_core(n,1); /* should never happen */ if( !(p = secmem_malloc( n +EXTRA_ALIGN+ 5 )) ) out_of_core(n,1); store_len(p,n,1); p[4+EXTRA_ALIGN+n] = MAGIC_END_BYTE; return p+EXTRA_ALIGN+4; #else + /* mallocing zero bytes is undefined by ISO-C, so we better make + sure that it won't happen */ + if (!n) + n = 1; if( !(p = secmem_malloc( n )) ) out_of_core(n,1); return p; @@ -499,7 +509,7 @@ FNAME(realloc)( void *a, size_t n FNAMEPRT ) FNAME(free)(p FNAMEARG); } else - b = FNAME(alloc)(n); + b = FNAME(alloc)(n FNAMEARG); #else if( m_is_secure(a) ) { if( !(b = secmem_realloc( a, n )) ) diff --git a/util/riscos.c b/util/riscos.c index 2b4e92bd5..65b8d10bb 100644 --- a/util/riscos.c +++ b/util/riscos.c @@ -22,6 +22,7 @@ #define __RISCOS__C__ #include <config.h> +#include <stdlib.h> #include <stdarg.h> #include <sys/types.h> #include <sys/stat.h> |