1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-09-22 15:11:41 +02:00

(secmem_realloc): Take control information into account

when checking whether a resize is needed.
This commit is contained in:
Werner Koch 2005-03-10 09:52:05 +00:00
parent c91e30fda4
commit 1ccebd117d
3 changed files with 28 additions and 5 deletions

View File

@ -1,3 +1,12 @@
2005-03-10 Werner Koch <wk@g10code.com>
* secmem.c (secmem_realloc): Take control information into account
when checking whether a resize is needed.
2005-03-08 Werner Koch <wk@g10code.com>
* miscutil.c (asctimestamp) [W32]: Don't use %Z.
2005-02-03 Werner Koch <wk@g10code.com>
* w32reg.c (read_w32_registry_string): Fallback to HKLM also for a
@ -1468,7 +1477,8 @@ Fri Feb 13 15:14:13 1998 Werner Koch (wk@isil.d.shuttle.de)
Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004,
2005 Free Software Foundation, Inc.
This file is free software; as a special exception the author gives
unlimited permission to copy and/or distribute it, with or without

View File

@ -167,7 +167,13 @@ asctimestamp( u32 stamp )
* These locales from glibc don't put the " %Z":
* fi_FI hr_HR ja_JP lt_LT lv_LV POSIX ru_RU ru_SU sv_FI sv_SE zh_CN
*/
strftime( buffer, DIM(buffer)-1, "%c %Z", tp );
strftime( buffer, DIM(buffer)-1,
#ifdef HAVE_W32_SYSTEM
"%c"
#else
"%c %Z"
#endif
, tp );
#endif
buffer[DIM(buffer)-1] = 0;
#else

View File

@ -349,7 +349,10 @@ secmem_malloc( size_t size )
print_warn();
}
/* blocks are always a multiple of 32 */
/* Blocks are always a multiple of 32. Note that we allocate an
extra of the size of an entire MEMBLOCK. This is required
becuase we do not only need the SIZE info but also extra space
to chain up unused memory blocks. */
size += sizeof(MEMBLOCK);
size = ((size + 31) / 32) * 32;
@ -398,8 +401,12 @@ secmem_realloc( void *p, size_t newsize )
mb = (MEMBLOCK*)((char*)p - ((size_t) &((MEMBLOCK*)0)->u.aligned.c));
size = mb->size;
if( newsize < size )
return p; /* it is easier not to shrink the memory */
if (size < sizeof(MEMBLOCK))
log_bug ("secure memory corrupted at block %p\n", mb);
size -= ((size_t) &((MEMBLOCK*)0)->u.aligned.c);
if( newsize <= size )
return p; /* It is easier not to shrink the memory. */
a = secmem_malloc( newsize );
if ( a ) {
memcpy(a, p, size);