mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-10 13:04:23 +01:00
fixed realloc not working correctly with M_GUARD
This commit is contained in:
parent
97d3149e92
commit
dc6d5b2a41
@ -1,3 +1,8 @@
|
|||||||
|
2001-12-22 Stefan Bellon <sbellon@sbellon.de>
|
||||||
|
|
||||||
|
* memory.c (realloc): Fixed realloc not working when M_GUARD is
|
||||||
|
defined and first parameter is NULL.
|
||||||
|
|
||||||
2001-12-22 Timo Schulz <ts@winpt.org>
|
2001-12-22 Timo Schulz <ts@winpt.org>
|
||||||
|
|
||||||
* fileutil.c (is_file_compressed): New.
|
* fileutil.c (is_file_compressed): New.
|
||||||
|
@ -475,23 +475,26 @@ FNAME(alloc_secure_clear)( size_t n FNAMEPRT)
|
|||||||
void *
|
void *
|
||||||
FNAME(realloc)( void *a, size_t n FNAMEPRT )
|
FNAME(realloc)( void *a, size_t n FNAMEPRT )
|
||||||
{
|
{
|
||||||
|
void *b;
|
||||||
|
|
||||||
#ifdef M_GUARD
|
#ifdef M_GUARD
|
||||||
unsigned char *p = a;
|
if( a ) {
|
||||||
void *b;
|
unsigned char *p = a;
|
||||||
size_t len = m_size(a);
|
size_t len = m_size(a);
|
||||||
|
|
||||||
if( len >= n ) /* we don't shrink for now */
|
if( len >= n ) /* we don't shrink for now */
|
||||||
return a;
|
return a;
|
||||||
if( p[-1] == MAGIC_SEC_BYTE )
|
if( p[-1] == MAGIC_SEC_BYTE )
|
||||||
b = FNAME(alloc_secure_clear)(n FNAMEARG);
|
b = FNAME(alloc_secure_clear)(n FNAMEARG);
|
||||||
|
else
|
||||||
|
b = FNAME(alloc_clear)(n FNAMEARG);
|
||||||
|
FNAME(check)(NULL FNAMEARG);
|
||||||
|
memcpy(b, a, len );
|
||||||
|
FNAME(free)(p FNAMEARG);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
b = FNAME(alloc_clear)(n FNAMEARG);
|
b = FNAME(alloc)(n);
|
||||||
FNAME(check)(NULL FNAMEARG);
|
|
||||||
memcpy(b, a, len );
|
|
||||||
FNAME(free)(p FNAMEARG);
|
|
||||||
#else
|
#else
|
||||||
void *b;
|
|
||||||
|
|
||||||
if( m_is_secure(a) ) {
|
if( m_is_secure(a) ) {
|
||||||
if( !(b = secmem_realloc( a, n )) )
|
if( !(b = secmem_realloc( a, n )) )
|
||||||
out_of_core(n,1);
|
out_of_core(n,1);
|
||||||
@ -501,6 +504,7 @@ FNAME(realloc)( void *a, size_t n FNAMEPRT )
|
|||||||
out_of_core(n,0);
|
out_of_core(n,0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user