mirror of
git://git.gnupg.org/gnupg.git
synced 2025-01-21 14:47:03 +01:00
bug fixes
This commit is contained in:
parent
4e8c3794b3
commit
b13e238a19
@ -1,3 +1,7 @@
|
|||||||
|
Fri Feb 27 13:14:17 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||||
|
|
||||||
|
* configure.in (--disable-m-guard): New.
|
||||||
|
|
||||||
Thu Feb 26 17:09:27 1998 Werner Koch (wk@isil.d.shuttle.de)
|
Thu Feb 26 17:09:27 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||||
|
|
||||||
* configure.in, acinclude.m4, intl/, po/: New macros taken
|
* configure.in, acinclude.m4, intl/, po/: New macros taken
|
||||||
|
15
INSTALL
15
INSTALL
@ -4,10 +4,10 @@ Please read the Basic Installation section somewhere below.
|
|||||||
Configure options for GNUPG
|
Configure options for GNUPG
|
||||||
===========================
|
===========================
|
||||||
|
|
||||||
--with-zlib Forces usage of the local zlib sources. Default is
|
--with-included-zlib Forces usage of the local zlib sources. Default is
|
||||||
to use the (sahred) library of the system.
|
to use the (shared) library of the system.
|
||||||
|
|
||||||
--disable-nls Disable NLS support
|
--disable-nls Disable NLS support (See ABOUT-NLS)
|
||||||
|
|
||||||
--enable-m-debug Compile with the integrated malloc debugging stuff.
|
--enable-m-debug Compile with the integrated malloc debugging stuff.
|
||||||
This makes the program slower but is checks every
|
This makes the program slower but is checks every
|
||||||
@ -18,13 +18,18 @@ Configure options for GNUPG
|
|||||||
option "--debug 128" displays a memory statistic after
|
option "--debug 128" displays a memory statistic after
|
||||||
the program run.
|
the program run.
|
||||||
|
|
||||||
|
--disable-m-guard Disable the integrated malloc checking code. As a
|
||||||
|
side-effect, this removes all debugging code and uses
|
||||||
|
the -O2 flag for all C files.
|
||||||
|
|
||||||
|
|
||||||
Problems
|
Problems
|
||||||
========
|
========
|
||||||
|
|
||||||
If you have compile problems, use the configure options "--with-zlib" and
|
If you have compile problems, use the configure options "--with-zlib" and
|
||||||
"--disable-nls".
|
"--disable-nls" (See ABOUT-NLS).
|
||||||
|
|
||||||
I cant check alls assembles files; so if you have problems assembling them
|
I cant check all assembler files; so if you have problems assembling them
|
||||||
(or the program crashes), simply delete the files in the mpi/<cpu> directory.
|
(or the program crashes), simply delete the files in the mpi/<cpu> directory.
|
||||||
The configure scripts may consider several subdirectories to get all
|
The configure scripts may consider several subdirectories to get all
|
||||||
available assembler files; be sure to delete the correct ones. The
|
available assembler files; be sure to delete the correct ones. The
|
||||||
|
22
NEWS
22
NEWS
@ -1,3 +1,25 @@
|
|||||||
|
Noteworthy changes in version 0.2.10
|
||||||
|
------------------------------------
|
||||||
|
|
||||||
|
* Code for the alpha is much faster (about 20 times); the data
|
||||||
|
was misaligned and the kernel traps this, so nearly all time
|
||||||
|
was used by system to trap the misalignments and to write
|
||||||
|
syslog messages. Shame on me and thanks to Ralph for
|
||||||
|
pointing me at this while drinking some beer yesterday.
|
||||||
|
|
||||||
|
* Changed some configure options and add an option
|
||||||
|
--disable-m-guard to remove the memory checking code
|
||||||
|
and to compile everthing with optimization on.
|
||||||
|
|
||||||
|
* New environment variable GNUPGHOME, which can be used to set
|
||||||
|
another homedir than ~/.gnupg. Changed default homedir for
|
||||||
|
Windoze version to c:/gnupg.
|
||||||
|
|
||||||
|
* Fixed detached signatures; detached PGP signatures caused a SEGV.
|
||||||
|
|
||||||
|
* The Windoze version works (as usual w/o a strong RNG).
|
||||||
|
|
||||||
|
|
||||||
Noteworthy changes in version 0.2.9
|
Noteworthy changes in version 0.2.9
|
||||||
-----------------------------------
|
-----------------------------------
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
@TOP@
|
@TOP@
|
||||||
|
|
||||||
#undef M_DEBUG
|
#undef M_DEBUG
|
||||||
|
#undef M_GUARD
|
||||||
#undef VERSION
|
#undef VERSION
|
||||||
#undef PACKAGE
|
#undef PACKAGE
|
||||||
#undef G10_LOCALEDIR
|
#undef G10_LOCALEDIR
|
||||||
|
@ -12,7 +12,7 @@ TEST_FILES = pubring.asc secring.asc gnupg.asc plain-1 plain-2 plain-3o.asc \
|
|||||||
|
|
||||||
DATA_FILES = data-500 data-9000 data-32000 data-80000
|
DATA_FILES = data-500 data-9000 data-32000 data-80000
|
||||||
|
|
||||||
EXTRA_DIST = $(TESTS) $(TEST_FILES)
|
EXTRA_DIST = defs.inc $(TESTS) $(TEST_FILES)
|
||||||
CLEANFILES = prepared.stamp x y z out err $(DATA_FILES)
|
CLEANFILES = prepared.stamp x y z out err $(DATA_FILES)
|
||||||
|
|
||||||
check: prepared.stamp
|
check: prepared.stamp
|
||||||
|
@ -1,3 +1,7 @@
|
|||||||
|
Fri Feb 27 16:39:34 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||||
|
|
||||||
|
* md.c (md_enable): No init if called twice.
|
||||||
|
|
||||||
Thu Feb 26 07:57:02 1998 Werner Koch (wk@isil.d.shuttle.de)
|
Thu Feb 26 07:57:02 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||||
|
|
||||||
* primegen.c (generate_elg_prime): Changed the progress printing.
|
* primegen.c (generate_elg_prime): Changed the progress printing.
|
||||||
|
@ -49,14 +49,17 @@ void
|
|||||||
md_enable( MD_HANDLE h, int algo )
|
md_enable( MD_HANDLE h, int algo )
|
||||||
{
|
{
|
||||||
if( algo == DIGEST_ALGO_MD5 ) {
|
if( algo == DIGEST_ALGO_MD5 ) {
|
||||||
|
if( !h->use_md5 )
|
||||||
md5_init( &h->md5 );
|
md5_init( &h->md5 );
|
||||||
h->use_md5 = 1;
|
h->use_md5 = 1;
|
||||||
}
|
}
|
||||||
else if( algo == DIGEST_ALGO_RMD160 ) {
|
else if( algo == DIGEST_ALGO_RMD160 ) {
|
||||||
|
if( !h->use_rmd160 )
|
||||||
rmd160_init( &h->rmd160 );
|
rmd160_init( &h->rmd160 );
|
||||||
h->use_rmd160 = 1;
|
h->use_rmd160 = 1;
|
||||||
}
|
}
|
||||||
else if( algo == DIGEST_ALGO_SHA1 ) {
|
else if( algo == DIGEST_ALGO_SHA1 ) {
|
||||||
|
if( !h->use_sha1 )
|
||||||
sha1_init( &h->sha1 );
|
sha1_init( &h->sha1 );
|
||||||
h->use_sha1 = 1;
|
h->use_sha1 = 1;
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,7 @@
|
|||||||
#undef STDC_HEADERS
|
#undef STDC_HEADERS
|
||||||
|
|
||||||
#undef M_DEBUG
|
#undef M_DEBUG
|
||||||
|
#undef M_GUARD
|
||||||
#undef VERSION
|
#undef VERSION
|
||||||
#undef PACKAGE
|
#undef PACKAGE
|
||||||
#undef G10_LOCALEDIR
|
#undef G10_LOCALEDIR
|
||||||
|
30
configure.in
30
configure.in
@ -27,18 +27,34 @@ AC_SUBST(PACKAGE)
|
|||||||
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
|
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
|
||||||
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
|
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
|
||||||
|
|
||||||
|
AC_MSG_CHECKING([whether memory debugging is requested])
|
||||||
AC_ARG_ENABLE(m-debug,
|
AC_ARG_ENABLE(m-debug,
|
||||||
[ --enable-m-debug Enable debugging of memory allocation])
|
[ --enable-m-debug enable debugging of memory allocation],
|
||||||
if test "$enableval" = y || test "$enableval" = yes; then
|
use_m_debug=$enableval, use_m_debug=no)
|
||||||
|
AC_MSG_RESULT($use_m_debug)
|
||||||
|
if test "$use_m_debug" = yes; then
|
||||||
AC_DEFINE(M_DEBUG)
|
AC_DEFINE(M_DEBUG)
|
||||||
|
use_m_guard=yes
|
||||||
|
else
|
||||||
|
AC_MSG_CHECKING([whether memory guard is requested])
|
||||||
|
AC_ARG_ENABLE(m-guard,
|
||||||
|
[ --disable-m-guard disable memory guard facility],
|
||||||
|
use_m_guard=$enableval, use_m_guard=yes)
|
||||||
|
AC_MSG_RESULT($use_m_guard)
|
||||||
|
fi
|
||||||
|
if test "$use_m_guard" = yes ; then
|
||||||
|
AC_DEFINE(M_GUARD)
|
||||||
|
CFLAGS="-g -Wall"
|
||||||
|
else
|
||||||
|
CFLAGS="-O2 -Wall"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
AC_ARG_WITH(zlib,
|
|
||||||
[ --with-zlib link against static zlib],
|
AC_MSG_CHECKING([whether included zlib is requested])
|
||||||
|
AC_ARG_WITH(included-zlib,
|
||||||
|
[ --with-included-zlib use the zlib code included here],
|
||||||
[g10_force_zlib=yes], [g10_force_zlib=no] )
|
[g10_force_zlib=yes], [g10_force_zlib=no] )
|
||||||
|
AC_MSG_RESULT($g10_force_zlib)
|
||||||
CFLAGS="-g -Wall"
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
AC_CANONICAL_SYSTEM
|
AC_CANONICAL_SYSTEM
|
||||||
|
@ -172,7 +172,8 @@ B<--secret-keyring> I<file>
|
|||||||
B<--homedir> I<dir>
|
B<--homedir> I<dir>
|
||||||
Set the name of the home directory to I<dir>. If this
|
Set the name of the home directory to I<dir>. If this
|
||||||
option is not used it defaults to F<~/.gnupg>. It does
|
option is not used it defaults to F<~/.gnupg>. It does
|
||||||
not make sense to use this in a options file.
|
not make sense to use this in a options file. This
|
||||||
|
also overrides the environment variable C<GNUPGHOME>.
|
||||||
|
|
||||||
B<--options> I<file>
|
B<--options> I<file>
|
||||||
Read options from I<file> and do not try to read
|
Read options from I<file> and do not try to read
|
||||||
@ -267,6 +268,7 @@ a signature was bad and other errorcode for fatal errors.
|
|||||||
=head1 ENVIRONMENT
|
=head1 ENVIRONMENT
|
||||||
|
|
||||||
C<HOME> Used to locate the default home directory.
|
C<HOME> Used to locate the default home directory.
|
||||||
|
C<GNUPGHOME> If set, direcory used instead of F<~/.gnupg>.
|
||||||
|
|
||||||
=head1 FILES
|
=head1 FILES
|
||||||
|
|
||||||
|
@ -1,3 +1,23 @@
|
|||||||
|
Fri Feb 27 18:14:03 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||||
|
|
||||||
|
* armor.c (find_header): Removed trailing CR on headers.
|
||||||
|
|
||||||
|
Fri Feb 27 18:02:48 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||||
|
|
||||||
|
* ringedit.c (keyring_search) [MINGW32]: Open and close file here
|
||||||
|
because rename does not work on open files. Chnaged callers.
|
||||||
|
|
||||||
|
Fri Feb 27 16:43:11 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||||
|
|
||||||
|
* sig-check.c (do_check): Add an md_enable.
|
||||||
|
* mainproc.c (do_check_sig): Use md_open in case of detached sig
|
||||||
|
(proc_tree): Take detached sigs into account.
|
||||||
|
|
||||||
|
Fri Feb 27 15:22:46 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||||
|
|
||||||
|
* g10.c (main): Make use of GNUPGHOME envvar.
|
||||||
|
* g10main.c (main): Ditto.
|
||||||
|
|
||||||
Wed Feb 25 11:40:04 1998 Werner Koch (wk@isil.d.shuttle.de)
|
Wed Feb 25 11:40:04 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||||
|
|
||||||
* plaintext.c (ask_for_detached_datafile): add opt.verbose to
|
* plaintext.c (ask_for_detached_datafile): add opt.verbose to
|
||||||
|
@ -318,6 +318,8 @@ find_header( fhdr_state_t state, byte *buf, size_t *r_buflen,
|
|||||||
if( n < buflen || c == '\n' ) {
|
if( n < buflen || c == '\n' ) {
|
||||||
if( n && buf[0] != '\r') { /* maybe a header */
|
if( n && buf[0] != '\r') { /* maybe a header */
|
||||||
if( strchr( buf, ':') ) { /* yes */
|
if( strchr( buf, ':') ) { /* yes */
|
||||||
|
if( buf[n-1] == '\r' )
|
||||||
|
buf[--n] = 0;
|
||||||
if( opt.verbose ) {
|
if( opt.verbose ) {
|
||||||
log_info("armor header: ");
|
log_info("armor header: ");
|
||||||
print_string( stderr, buf, n );
|
print_string( stderr, buf, n );
|
||||||
|
@ -326,7 +326,14 @@ main( int argc, char **argv )
|
|||||||
opt.def_digest_algo = DIGEST_ALGO_RMD160;
|
opt.def_digest_algo = DIGEST_ALGO_RMD160;
|
||||||
opt.completes_needed = 1;
|
opt.completes_needed = 1;
|
||||||
opt.marginals_needed = 3;
|
opt.marginals_needed = 3;
|
||||||
|
opt.homedir = getenv("GNUPGHOME");
|
||||||
|
if( !opt.homedir || !*opt.homedir ) {
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
opt.homedir = "c:/gnupg";
|
||||||
|
#else
|
||||||
opt.homedir = "~/.gnupg";
|
opt.homedir = "~/.gnupg";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* check wether we have a config file on the commandline */
|
/* check wether we have a config file on the commandline */
|
||||||
orig_argc = argc;
|
orig_argc = argc;
|
||||||
|
@ -258,7 +258,14 @@ main( int argc, char **argv )
|
|||||||
opt.def_digest_algo = DIGEST_ALGO_RMD160;
|
opt.def_digest_algo = DIGEST_ALGO_RMD160;
|
||||||
opt.completes_needed = 1;
|
opt.completes_needed = 1;
|
||||||
opt.marginals_needed = 3;
|
opt.marginals_needed = 3;
|
||||||
|
opt.homedir = getenv("GNUPGHOME");
|
||||||
|
if( !opt.homedir || !*opt.homedir ) {
|
||||||
|
#ifdef __MINGW32__
|
||||||
|
opt.homedir = "c:/gnupg";
|
||||||
|
#else
|
||||||
opt.homedir = "~/.gnupg";
|
opt.homedir = "~/.gnupg";
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/* check wether we have a config file on the commandline */
|
/* check wether we have a config file on the commandline */
|
||||||
orig_argc = argc;
|
orig_argc = argc;
|
||||||
|
@ -272,12 +272,18 @@ do_check_sig( CTX c, KBNODE node )
|
|||||||
return rc;
|
return rc;
|
||||||
|
|
||||||
if( sig->sig_class == 0x00 ) {
|
if( sig->sig_class == 0x00 ) {
|
||||||
|
if( c->mfx.md )
|
||||||
md = md_copy( c->mfx.md );
|
md = md_copy( c->mfx.md );
|
||||||
|
else /* detached signature */
|
||||||
|
md = md_open( 0, 0 ); /* signature_check() will enable the md*/
|
||||||
}
|
}
|
||||||
else if( sig->sig_class == 0x01 ) {
|
else if( sig->sig_class == 0x01 ) {
|
||||||
/* how do we know that we have to hash the (already hashed) text
|
/* how do we know that we have to hash the (already hashed) text
|
||||||
* in canonical mode ??? (calculating both modes???) */
|
* in canonical mode ??? (calculating both modes???) */
|
||||||
|
if( c->mfx.md )
|
||||||
md = md_copy( c->mfx.md );
|
md = md_copy( c->mfx.md );
|
||||||
|
else /* detached signature */
|
||||||
|
md = md_open( 0, 0 ); /* signature_check() will enable the md*/
|
||||||
}
|
}
|
||||||
else if( (sig->sig_class&~3) == 0x10
|
else if( (sig->sig_class&~3) == 0x10
|
||||||
|| sig->sig_class == 0x20
|
|| sig->sig_class == 0x20
|
||||||
@ -620,8 +626,6 @@ proc_tree( CTX c, KBNODE node )
|
|||||||
else if( node->pkt->pkttype == PKT_SIGNATURE ) {
|
else if( node->pkt->pkttype == PKT_SIGNATURE ) {
|
||||||
PKT_signature *sig = node->pkt->pkt.signature;
|
PKT_signature *sig = node->pkt->pkt.signature;
|
||||||
|
|
||||||
if( !c->have_data && (sig->sig_class&~3) == 0x10 ) {
|
|
||||||
log_info("old style signature\n");
|
|
||||||
if( !c->have_data ) {
|
if( !c->have_data ) {
|
||||||
free_md_filter_context( &c->mfx );
|
free_md_filter_context( &c->mfx );
|
||||||
c->mfx.md = md_open(digest_algo_from_sig(sig), 0);
|
c->mfx.md = md_open(digest_algo_from_sig(sig), 0);
|
||||||
@ -632,7 +636,8 @@ proc_tree( CTX c, KBNODE node )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
log_info("old style signature\n");
|
||||||
|
|
||||||
check_sig_and_print( c, node );
|
check_sig_and_print( c, node );
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,8 @@ static RESTBL resource_table[MAX_RESOURCES];
|
|||||||
static int search( PACKET *pkt, KBPOS *kbpos, int secret );
|
static int search( PACKET *pkt, KBPOS *kbpos, int secret );
|
||||||
|
|
||||||
|
|
||||||
static int keyring_search( PACKET *pkt, KBPOS *kbpos, IOBUF iobuf );
|
static int keyring_search( PACKET *pkt, KBPOS *kbpos, IOBUF iobuf,
|
||||||
|
const char *fname );
|
||||||
static int keyring_search2( PUBKEY_FIND_INFO info, KBPOS *kbpos,
|
static int keyring_search2( PUBKEY_FIND_INFO info, KBPOS *kbpos,
|
||||||
const char *fname);
|
const char *fname);
|
||||||
static int keyring_read( KBPOS *kbpos, KBNODE *ret_root );
|
static int keyring_read( KBPOS *kbpos, KBNODE *ret_root );
|
||||||
@ -113,9 +114,13 @@ add_keyblock_resource( const char *filename, int force, int secret )
|
|||||||
if( i == MAX_RESOURCES )
|
if( i == MAX_RESOURCES )
|
||||||
return G10ERR_RESOURCE_LIMIT;
|
return G10ERR_RESOURCE_LIMIT;
|
||||||
|
|
||||||
|
#if __MINGW32__
|
||||||
|
iobuf = NULL;
|
||||||
|
#else
|
||||||
iobuf = iobuf_open( filename );
|
iobuf = iobuf_open( filename );
|
||||||
if( !iobuf && !force )
|
if( !iobuf && !force )
|
||||||
return G10ERR_OPEN_FILE;
|
return G10ERR_OPEN_FILE;
|
||||||
|
#endif
|
||||||
resource_table[i].used = 1;
|
resource_table[i].used = 1;
|
||||||
resource_table[i].secret = !!secret;
|
resource_table[i].secret = !!secret;
|
||||||
resource_table[i].fname = m_strdup(filename);
|
resource_table[i].fname = m_strdup(filename);
|
||||||
@ -211,7 +216,8 @@ search( PACKET *pkt, KBPOS *kbpos, int secret )
|
|||||||
if( resource_table[i].used && !resource_table[i].secret == !secret ) {
|
if( resource_table[i].used && !resource_table[i].secret == !secret ) {
|
||||||
/* note: here we have to add different search functions,
|
/* note: here we have to add different search functions,
|
||||||
* depending on the type of the resource */
|
* depending on the type of the resource */
|
||||||
rc = keyring_search( pkt, kbpos, resource_table[i].iobuf );
|
rc = keyring_search( pkt, kbpos, resource_table[i].iobuf,
|
||||||
|
resource_table[i].fname );
|
||||||
if( !rc ) {
|
if( !rc ) {
|
||||||
kbpos->resno = i;
|
kbpos->resno = i;
|
||||||
kbpos->fp = NULL;
|
kbpos->fp = NULL;
|
||||||
@ -469,7 +475,7 @@ update_keyblock( KBPOS *kbpos, KBNODE root )
|
|||||||
* search one keyring, return 0 if found, -1 if not found or an errorcode.
|
* search one keyring, return 0 if found, -1 if not found or an errorcode.
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
keyring_search( PACKET *req, KBPOS *kbpos, IOBUF iobuf )
|
keyring_search( PACKET *req, KBPOS *kbpos, IOBUF iobuf, const char *fname )
|
||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
PACKET pkt;
|
PACKET pkt;
|
||||||
@ -482,11 +488,21 @@ keyring_search( PACKET *req, KBPOS *kbpos, IOBUF iobuf )
|
|||||||
init_packet(&pkt);
|
init_packet(&pkt);
|
||||||
save_mode = set_packet_list_mode(0);
|
save_mode = set_packet_list_mode(0);
|
||||||
|
|
||||||
|
#if __MINGW32__
|
||||||
|
assert(!iobuf);
|
||||||
|
iobuf = iobuf_open( fname );
|
||||||
|
if( !iobuf ) {
|
||||||
|
log_error("%s: can't open keyring file\n", fname);
|
||||||
|
rc = G10ERR_KEYRING_OPEN;
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
|
#else
|
||||||
if( iobuf_seek( iobuf, 0 ) ) {
|
if( iobuf_seek( iobuf, 0 ) ) {
|
||||||
log_error("can't rewind keyring file\n");
|
log_error("can't rewind keyring file\n");
|
||||||
rc = G10ERR_KEYRING_OPEN;
|
rc = G10ERR_KEYRING_OPEN;
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
while( !(rc=search_packet(iobuf, &pkt, pkttype, &offset)) ) {
|
while( !(rc=search_packet(iobuf, &pkt, pkttype, &offset)) ) {
|
||||||
if( pkt.pkttype == PKT_SECRET_CERT ) {
|
if( pkt.pkttype == PKT_SECRET_CERT ) {
|
||||||
@ -539,6 +555,9 @@ keyring_search( PACKET *req, KBPOS *kbpos, IOBUF iobuf )
|
|||||||
leave:
|
leave:
|
||||||
free_packet(&pkt);
|
free_packet(&pkt);
|
||||||
set_packet_list_mode(save_mode);
|
set_packet_list_mode(save_mode);
|
||||||
|
#if __MINGW32__
|
||||||
|
iobuf_close(iobuf);
|
||||||
|
#endif
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -872,7 +891,11 @@ keyring_copy( KBPOS *kbpos, int mode, KBNODE root )
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* close both files */
|
/* close both files */
|
||||||
iobuf_close(fp);
|
if( iobuf_close(fp) ) {
|
||||||
|
log_error("%s: close failed: %s\n", rentry->fname, strerror(errno) );
|
||||||
|
rc = G10ERR_CLOSE_FILE;
|
||||||
|
goto leave;
|
||||||
|
}
|
||||||
if( iobuf_close(newfp) ) {
|
if( iobuf_close(newfp) ) {
|
||||||
log_error("%s: close failed: %s\n", tmpfname, strerror(errno) );
|
log_error("%s: close failed: %s\n", tmpfname, strerror(errno) );
|
||||||
rc = G10ERR_CLOSE_FILE;
|
rc = G10ERR_CLOSE_FILE;
|
||||||
|
@ -68,6 +68,9 @@ do_check( PKT_public_cert *pkc, PKT_signature *sig, MD_HANDLE digest )
|
|||||||
|
|
||||||
if( (rc=check_digest_algo(sig->d.elg.digest_algo)) )
|
if( (rc=check_digest_algo(sig->d.elg.digest_algo)) )
|
||||||
goto leave;
|
goto leave;
|
||||||
|
/* make sure the digest algo is enabled (in case of a detached
|
||||||
|
* signature */
|
||||||
|
md_enable( digest, sig->d.elg.digest_algo );
|
||||||
/* complete the digest */
|
/* complete the digest */
|
||||||
md_putc( digest, sig->sig_class );
|
md_putc( digest, sig->sig_class );
|
||||||
{ u32 a = sig->timestamp;
|
{ u32 a = sig->timestamp;
|
||||||
@ -124,6 +127,7 @@ do_check( PKT_public_cert *pkc, PKT_signature *sig, MD_HANDLE digest )
|
|||||||
|
|
||||||
if( (rc=check_digest_algo(sig->d.rsa.digest_algo)) )
|
if( (rc=check_digest_algo(sig->d.rsa.digest_algo)) )
|
||||||
goto leave; /* unsupported algo */
|
goto leave; /* unsupported algo */
|
||||||
|
md_enable( digest, sig->d.rsa.digest_algo );
|
||||||
asn = md_asn_oid( sig->d.rsa.digest_algo, &asnlen, &mdlen );
|
asn = md_asn_oid( sig->d.rsa.digest_algo, &asnlen, &mdlen );
|
||||||
|
|
||||||
for(i=mdlen,j=asnlen-1; (c=mpi_getbyte(result, i)) != -1 && j >= 0;
|
for(i=mdlen,j=asnlen-1; (c=mpi_getbyte(result, i)) != -1 && j >= 0;
|
||||||
|
@ -163,6 +163,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
|
|||||||
iobuf_push_filter( out, encrypt_filter, &efx );
|
iobuf_push_filter( out, encrypt_filter, &efx );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if( !detached ) {
|
||||||
/* loop over the secret certificates and build headers */
|
/* loop over the secret certificates and build headers */
|
||||||
for( skc_rover = skc_list; skc_rover; skc_rover = skc_rover->next ) {
|
for( skc_rover = skc_list; skc_rover; skc_rover = skc_rover->next ) {
|
||||||
PKT_secret_cert *skc;
|
PKT_secret_cert *skc;
|
||||||
@ -182,10 +183,12 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
|
|||||||
rc = build_packet( out, &pkt );
|
rc = build_packet( out, &pkt );
|
||||||
free_packet( &pkt );
|
free_packet( &pkt );
|
||||||
if( rc ) {
|
if( rc ) {
|
||||||
log_error("build onepass_sig packet failed: %s\n", g10_errstr(rc));
|
log_error("build onepass_sig packet failed: %s\n",
|
||||||
|
g10_errstr(rc));
|
||||||
goto leave;
|
goto leave;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/* setup the inner packet */
|
/* setup the inner packet */
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
#define m_realloc(n,m) m_debug_realloc((n),(m), M_DBGINFO(__LINE__) )
|
#define m_realloc(n,m) m_debug_realloc((n),(m), M_DBGINFO(__LINE__) )
|
||||||
#define m_free(n) m_debug_free((n), M_DBGINFO(__LINE__) )
|
#define m_free(n) m_debug_free((n), M_DBGINFO(__LINE__) )
|
||||||
#define m_check(n) m_debug_check((n), M_DBGINFO(__LINE__) )
|
#define m_check(n) m_debug_check((n), M_DBGINFO(__LINE__) )
|
||||||
#define m_copy(a) m_debug_copy((a), M_DBGINFO(__LINE__) )
|
/*#define m_copy(a) m_debug_copy((a), M_DBGINFO(__LINE__) )*/
|
||||||
#define m_strdup(a) m_debug_strdup((a), M_DBGINFO(__LINE__) )
|
#define m_strdup(a) m_debug_strdup((a), M_DBGINFO(__LINE__) )
|
||||||
|
|
||||||
void *m_debug_alloc( size_t n, const char *info );
|
void *m_debug_alloc( size_t n, const char *info );
|
||||||
@ -43,7 +43,7 @@ void *m_debug_alloc_secure_clear( size_t n, const char *info );
|
|||||||
void *m_debug_realloc( void *a, size_t n, const char *info );
|
void *m_debug_realloc( void *a, size_t n, const char *info );
|
||||||
void m_debug_free( void *p, const char *info );
|
void m_debug_free( void *p, const char *info );
|
||||||
void m_debug_check( const void *a, const char *info );
|
void m_debug_check( const void *a, const char *info );
|
||||||
void *m_debug_copy( const void *a, const char *info );
|
/*void *m_debug_copy( const void *a, const char *info );*/
|
||||||
char *m_debug_strdup( const char *a, const char *info );
|
char *m_debug_strdup( const char *a, const char *info );
|
||||||
|
|
||||||
#else
|
#else
|
||||||
@ -54,18 +54,19 @@ void *m_alloc_secure_clear( size_t n );
|
|||||||
void *m_realloc( void *a, size_t n );
|
void *m_realloc( void *a, size_t n );
|
||||||
void m_free( void *p );
|
void m_free( void *p );
|
||||||
void m_check( const void *a );
|
void m_check( const void *a );
|
||||||
void *m_copy( const void *a );
|
/*void *m_copy( const void *a );*/
|
||||||
char *m_strdup( const char * a);
|
char *m_strdup( const char * a);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
size_t m_size( const void *a );
|
size_t m_size( const void *a );
|
||||||
int m_is_secure( const void *p );
|
|
||||||
|
|
||||||
/*-- secmem.c --*/
|
/*-- secmem.c --*/
|
||||||
void secmem_init( size_t npool );
|
void secmem_init( size_t npool );
|
||||||
void secmem_term( void );
|
void secmem_term( void );
|
||||||
void *secmem_malloc( size_t size );
|
void *secmem_malloc( size_t size );
|
||||||
|
void *secmem_realloc( void *a, size_t newsize );
|
||||||
void secmem_free( void *a );
|
void secmem_free( void *a );
|
||||||
|
int m_is_secure( const void *p );
|
||||||
void secmem_dump_stats(void);
|
void secmem_dump_stats(void);
|
||||||
void secmem_set_flags( unsigned flags );
|
void secmem_set_flags( unsigned flags );
|
||||||
unsigned secmem_get_flags(void);
|
unsigned secmem_get_flags(void);
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
Fri Feb 27 10:20:03 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||||
|
|
||||||
|
* memory.c (m_is_secure): Removed.
|
||||||
|
* secmem.c (m_is_secure): Moved to here.
|
||||||
|
|
||||||
|
* secmem.c (secmem_realloc): New.
|
||||||
|
* memory.c (M_GUARD,EXTRA_ALIGN): New (all functions).
|
||||||
|
|
||||||
Thu Feb 26 14:36:51 1998 Werner Koch (wk@isil.d.shuttle.de)
|
Thu Feb 26 14:36:51 1998 Werner Koch (wk@isil.d.shuttle.de)
|
||||||
|
|
||||||
* secmem.c (lock_pool): No error if EAGAIN is returned instead
|
* secmem.c (lock_pool): No error if EAGAIN is returned instead
|
||||||
|
135
util/memory.c
135
util/memory.c
@ -4,13 +4,11 @@
|
|||||||
* We use our own memory allocation functions instead of plain malloc(),
|
* We use our own memory allocation functions instead of plain malloc(),
|
||||||
* so that we can provide some special enhancements:
|
* so that we can provide some special enhancements:
|
||||||
* a) functions to provide memory from a secure memory.
|
* a) functions to provide memory from a secure memory.
|
||||||
* Don't know how to handle it yet, but it may be possible to
|
|
||||||
* use memory which can't be swapped out.
|
|
||||||
* b) By looking at the requested allocation size we
|
* b) By looking at the requested allocation size we
|
||||||
* can reuse memory very quickly (e.g. MPI storage)
|
* can reuse memory very quickly (e.g. MPI storage)
|
||||||
* c) A controlbyte gives us the opportunity to use only one
|
* (really needed?)
|
||||||
* free() function and do some overflow checking.
|
* c) memory usage reporting if compiled with M_DEBUG
|
||||||
* d) memory checking and reporting if compiled with M_DEBUG
|
* d) memory checking if compiled with M_GUARD
|
||||||
*
|
*
|
||||||
* This file is part of GNUPG.
|
* This file is part of GNUPG.
|
||||||
*
|
*
|
||||||
@ -44,9 +42,18 @@
|
|||||||
#define MAGIC_SEC_BYTE 0xcc
|
#define MAGIC_SEC_BYTE 0xcc
|
||||||
#define MAGIC_END_BYTE 0xaa
|
#define MAGIC_END_BYTE 0xaa
|
||||||
|
|
||||||
|
#if SIZEOF_UNSIGNED_LONG == 8
|
||||||
|
#define EXTRA_ALIGN 4
|
||||||
|
#else
|
||||||
|
#define EXTRA_ALIGN 0
|
||||||
|
#endif
|
||||||
|
|
||||||
const void membug( const char *fmt, ... );
|
const void membug( const char *fmt, ... );
|
||||||
|
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
|
#ifndef M_GUARD
|
||||||
|
#define M_GUARD 1
|
||||||
|
#endif
|
||||||
#undef m_alloc
|
#undef m_alloc
|
||||||
#undef m_alloc_clear
|
#undef m_alloc_clear
|
||||||
#undef m_alloc_secure
|
#undef m_alloc_secure
|
||||||
@ -64,10 +71,10 @@ const void membug( const char *fmt, ... );
|
|||||||
#define FNAME(a) m_ ##a
|
#define FNAME(a) m_ ##a
|
||||||
#define FNAMEPRT
|
#define FNAMEPRT
|
||||||
#define FNAMEARG
|
#define FNAMEARG
|
||||||
#define store_len(p,n,m) do { ((byte*)p)[0] = n; \
|
#define store_len(p,n,m) do { ((byte*)p)[EXTRA_ALIGN+0] = n; \
|
||||||
((byte*)p)[1] = n >> 8 ; \
|
((byte*)p)[EXTRA_ALIGN+1] = n >> 8 ; \
|
||||||
((byte*)p)[2] = n >> 16 ; \
|
((byte*)p)[EXTRA_ALIGN+2] = n >> 16 ; \
|
||||||
((byte*)p)[3] = m? MAGIC_SEC_BYTE \
|
((byte*)p)[EXTRA_ALIGN+3] = m? MAGIC_SEC_BYTE \
|
||||||
: MAGIC_NOR_BYTE; \
|
: MAGIC_NOR_BYTE; \
|
||||||
} while(0)
|
} while(0)
|
||||||
#endif
|
#endif
|
||||||
@ -196,24 +203,29 @@ check_mem( const byte *p, const char *info )
|
|||||||
unsigned n;
|
unsigned n;
|
||||||
struct memtbl_entry *e;
|
struct memtbl_entry *e;
|
||||||
|
|
||||||
n = p[0];
|
n = p[EXTRA_ALIGN+0];
|
||||||
n |= p[1] << 8;
|
n |= p[EXTRA_ALIGN+1] << 8;
|
||||||
n |= p[2] << 16;
|
n |= p[EXTRA_ALIGN+2] << 16;
|
||||||
|
|
||||||
if( n >= memtbl_len )
|
if( n >= memtbl_len )
|
||||||
membug("memory at %p corrupted: index=%u table_len=%u (%s)\n",
|
membug("memory at %p corrupted: index=%u table_len=%u (%s)\n",
|
||||||
p+4, n, memtbl_len, info );
|
p+EXTRA_ALIGN+4, n, memtbl_len, info );
|
||||||
e = memtbl+n;
|
e = memtbl+n;
|
||||||
|
|
||||||
if( e->user_p != p+4 )
|
if( e->user_p != p+EXTRA_ALIGN+4 )
|
||||||
membug("memory at %p corrupted: reference mismatch (%s)\n", p+4, info );
|
membug("memory at %p corrupted: reference mismatch (%s)\n",
|
||||||
|
p+EXTRA_ALIGN+4, info );
|
||||||
if( !e->inuse )
|
if( !e->inuse )
|
||||||
membug("memory at %p corrupted: marked as free (%s)\n", p+4, info );
|
membug("memory at %p corrupted: marked as free (%s)\n",
|
||||||
|
p+EXTRA_ALIGN+4, info );
|
||||||
|
|
||||||
if( !(p[3] == MAGIC_NOR_BYTE || p[3] == MAGIC_SEC_BYTE) )
|
if( !(p[EXTRA_ALIGN+3] == MAGIC_NOR_BYTE
|
||||||
membug("memory at %p corrupted: underflow=%02x (%s)\n", p+4, p[3], info );
|
|| p[EXTRA_ALIGN+3] == MAGIC_SEC_BYTE) )
|
||||||
if( p[4+e->user_n] != MAGIC_END_BYTE )
|
membug("memory at %p corrupted: underflow=%02x (%s)\n",
|
||||||
membug("memory at %p corrupted: overflow=%02x (%s)\n", p+4, p[4+e->user_n], info );
|
p+EXTRA_ALIGN+4, p[EXTRA_ALIGN+3], info );
|
||||||
|
if( p[EXTRA_ALIGN+4+e->user_n] != MAGIC_END_BYTE )
|
||||||
|
membug("memory at %p corrupted: overflow=%02x (%s)\n",
|
||||||
|
p+EXTRA_ALIGN+4, p[EXTRA_ALIGN+4+e->user_n], info );
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -233,10 +245,10 @@ free_entry( byte *p, const char *info )
|
|||||||
log_debug( "%s frees %u bytes alloced by %s\n",
|
log_debug( "%s frees %u bytes alloced by %s\n",
|
||||||
info, e->user_n, e->info->info );
|
info, e->user_n, e->info->info );
|
||||||
if( !e->inuse ) {
|
if( !e->inuse ) {
|
||||||
if( e->user_p == p + 4 )
|
if( e->user_p == p + EXTRA_ALIGN+ 4 )
|
||||||
membug("freeing an already freed pointer at %p\n", p+4 );
|
membug("freeing an already freed pointer at %p\n", p+EXTRA_ALIGN+4 );
|
||||||
else
|
else
|
||||||
membug("freeing pointer %p which is flagged as freed\n", p+4 );
|
membug("freeing pointer %p which is flagged as freed\n", p+EXTRA_ALIGN+4 );
|
||||||
}
|
}
|
||||||
|
|
||||||
e->inuse = 0;
|
e->inuse = 0;
|
||||||
@ -298,7 +310,7 @@ check_allmem( const char *info )
|
|||||||
|
|
||||||
for( e = memtbl, n = 0; n < memtbl_len; n++, e++ )
|
for( e = memtbl, n = 0; n < memtbl_len; n++, e++ )
|
||||||
if( e->inuse )
|
if( e->inuse )
|
||||||
check_mem(e->user_p-4, info);
|
check_mem(e->user_p-4-EXTRA_ALIGN, info);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* M_DEBUG */
|
#endif /* M_DEBUG */
|
||||||
@ -337,11 +349,17 @@ FNAME(alloc)( size_t n FNAMEPRT )
|
|||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if( !(p = malloc( n + 5 )) )
|
#ifdef M_GUARD
|
||||||
|
if( !(p = malloc( n + EXTRA_ALIGN+5 )) )
|
||||||
out_of_core(n,0);
|
out_of_core(n,0);
|
||||||
store_len(p,n,0);
|
store_len(p,n,0);
|
||||||
p[4+n] = MAGIC_END_BYTE; /* need to add the length somewhere */
|
p[4+EXTRA_ALIGN+n] = MAGIC_END_BYTE;
|
||||||
return p+4;
|
return p+EXTRA_ALIGN+4;
|
||||||
|
#else
|
||||||
|
if( !(p = malloc( n )) )
|
||||||
|
out_of_core(n,0);
|
||||||
|
return p;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
@ -353,11 +371,17 @@ FNAME(alloc_secure)( size_t n FNAMEPRT )
|
|||||||
{
|
{
|
||||||
char *p;
|
char *p;
|
||||||
|
|
||||||
if( !(p = secmem_malloc( n + 5 )) )
|
#ifdef M_GUARD
|
||||||
|
if( !(p = secmem_malloc( n +EXTRA_ALIGN+ 5 )) )
|
||||||
out_of_core(n,1);
|
out_of_core(n,1);
|
||||||
store_len(p,n,1);
|
store_len(p,n,1);
|
||||||
p[4+n] = MAGIC_END_BYTE;
|
p[4+EXTRA_ALIGN+n] = MAGIC_END_BYTE;
|
||||||
return p+4;
|
return p+EXTRA_ALIGN+4;
|
||||||
|
#else
|
||||||
|
if( !(p = secmem_malloc( n )) )
|
||||||
|
out_of_core(n,1);
|
||||||
|
return p;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void *
|
void *
|
||||||
@ -384,7 +408,8 @@ 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 )
|
||||||
{ /* FIXME: should be optimized :-) */
|
{
|
||||||
|
#ifdef M_GUARD
|
||||||
unsigned char *p = a;
|
unsigned char *p = a;
|
||||||
void *b;
|
void *b;
|
||||||
size_t len = m_size(a);
|
size_t len = m_size(a);
|
||||||
@ -398,6 +423,18 @@ FNAME(realloc)( void *a, size_t n FNAMEPRT )
|
|||||||
FNAME(check)(NULL FNAMEARG);
|
FNAME(check)(NULL FNAMEARG);
|
||||||
memcpy(b, a, len );
|
memcpy(b, a, len );
|
||||||
FNAME(free)(p FNAMEARG);
|
FNAME(free)(p FNAMEARG);
|
||||||
|
#else
|
||||||
|
void *b;
|
||||||
|
|
||||||
|
if( m_is_secure(a) ) {
|
||||||
|
if( !(b = secmem_realloc( a, n )) )
|
||||||
|
out_of_core(n,1);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if( !(b = realloc( a, n )) )
|
||||||
|
out_of_core(n,0);
|
||||||
|
}
|
||||||
|
#endif
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -414,13 +451,18 @@ FNAME(free)( void *a FNAMEPRT )
|
|||||||
if( !p )
|
if( !p )
|
||||||
return;
|
return;
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
free_entry(p-4, info);
|
free_entry(p-EXTRA_ALIGN-4, info);
|
||||||
#else
|
#elif M_GUARD
|
||||||
m_check(p);
|
m_check(p);
|
||||||
if( m_is_secure(a) )
|
if( m_is_secure(a) )
|
||||||
secmem_free(p-4);
|
secmem_free(p-EXTRA_ALIGN-4);
|
||||||
else
|
else
|
||||||
free(p-4);
|
free(p-EXTRA_ALIGN-4);
|
||||||
|
#else
|
||||||
|
if( m_is_secure(a) )
|
||||||
|
secmem_free(p);
|
||||||
|
else
|
||||||
|
free(p);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,11 +470,12 @@ FNAME(free)( void *a FNAMEPRT )
|
|||||||
void
|
void
|
||||||
FNAME(check)( const void *a FNAMEPRT )
|
FNAME(check)( const void *a FNAMEPRT )
|
||||||
{
|
{
|
||||||
|
#ifdef M_GUARD
|
||||||
const byte *p = a;
|
const byte *p = a;
|
||||||
|
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
if( p )
|
if( p )
|
||||||
check_mem(p-4, info);
|
check_mem(p-EXTRA_ALIGN-4, info);
|
||||||
else
|
else
|
||||||
check_allmem(info);
|
check_allmem(info);
|
||||||
#else
|
#else
|
||||||
@ -443,33 +486,33 @@ FNAME(check)( const void *a FNAMEPRT )
|
|||||||
else if( p[m_size(p)] != MAGIC_END_BYTE )
|
else if( p[m_size(p)] != MAGIC_END_BYTE )
|
||||||
membug("memory at %p corrupted (overflow=%02x)\n", p, p[-1] );
|
membug("memory at %p corrupted (overflow=%02x)\n", p, p[-1] );
|
||||||
#endif
|
#endif
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
size_t
|
size_t
|
||||||
m_size( const void *a )
|
m_size( const void *a )
|
||||||
{
|
{
|
||||||
|
#ifndef M_GUARD
|
||||||
|
log_debug("Ooops, m_size called\n");
|
||||||
|
return 0;
|
||||||
|
#else
|
||||||
const byte *p = a;
|
const byte *p = a;
|
||||||
size_t n;
|
size_t n;
|
||||||
|
|
||||||
#ifdef M_DEBUG
|
#ifdef M_DEBUG
|
||||||
n = check_mem(p-4, "m_size")->user_n;
|
n = check_mem(p-EXTRA_ALIGN-4, "m_size")->user_n;
|
||||||
#else
|
#else
|
||||||
n = ((byte*)p)[-4];
|
n = ((byte*)p)[-4];
|
||||||
n |= ((byte*)p)[-3] << 8;
|
n |= ((byte*)p)[-3] << 8;
|
||||||
n |= ((byte*)p)[-2] << 16;
|
n |= ((byte*)p)[-2] << 16;
|
||||||
#endif
|
#endif
|
||||||
return n;
|
return n;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
#if 0 /* not used */
|
||||||
m_is_secure( const void *p )
|
|
||||||
{
|
|
||||||
return p && ((byte*)p)[-1] == MAGIC_SEC_BYTE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/****************
|
/****************
|
||||||
* Make a copy of the memory block at a
|
* Make a copy of the memory block at a
|
||||||
*/
|
*/
|
||||||
@ -482,7 +525,7 @@ FNAME(copy)( const void *a FNAMEPRT )
|
|||||||
if( !a )
|
if( !a )
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
n = m_size(a);
|
n = m_size(a); Aiiiih woher nehmen
|
||||||
if( m_is_secure(a) )
|
if( m_is_secure(a) )
|
||||||
b = FNAME(alloc_secure)(n FNAMEARG);
|
b = FNAME(alloc_secure)(n FNAMEARG);
|
||||||
else
|
else
|
||||||
@ -490,7 +533,7 @@ FNAME(copy)( const void *a FNAMEPRT )
|
|||||||
memcpy(b, a, n );
|
memcpy(b, a, n );
|
||||||
return b;
|
return b;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
char *
|
char *
|
||||||
FNAME(strdup)( const char *a FNAMEPRT )
|
FNAME(strdup)( const char *a FNAMEPRT )
|
||||||
|
@ -219,6 +219,25 @@ secmem_malloc( size_t size )
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void *
|
||||||
|
secmem_realloc( void *p, size_t newsize )
|
||||||
|
{
|
||||||
|
MEMBLOCK *mb;
|
||||||
|
size_t size;
|
||||||
|
void *a;
|
||||||
|
|
||||||
|
mb = (MEMBLOCK*)((char*)p - ((size_t) &((MEMBLOCK*)0)->u.d));
|
||||||
|
size = mb->size;
|
||||||
|
if( newsize < size )
|
||||||
|
return p; /* it is easier not to shrink the memory */
|
||||||
|
a = secmem_malloc( newsize );
|
||||||
|
memcpy(a, p, size);
|
||||||
|
memset(a+size, 0, newsize-size);
|
||||||
|
secmem_free(p);
|
||||||
|
return a;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
secmem_free( void *a )
|
secmem_free( void *a )
|
||||||
{
|
{
|
||||||
@ -241,6 +260,12 @@ secmem_free( void *a )
|
|||||||
cur_alloced -= size;
|
cur_alloced -= size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
m_is_secure( const void *p )
|
||||||
|
{
|
||||||
|
return p >= pool && p < (pool+poolsize);
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
secmem_term()
|
secmem_term()
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user