--enable-m-* options
Lachlan O'Dea
lodea@vet.com.au
Thu, 26 Aug 1999 00:27:47 +1000
--CXFpZVxO6m2Ol4tQ
Content-Type: multipart/mixed; boundary="//IivP0gvsAy3Can"
--//IivP0gvsAy3Can
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable
On Tue, Aug 24, 1999 at 09:30:04PM +1000, Lachlan O'Dea wrote:
> Hi,
>=20
> Since gnupg is still beta and I'm not really fussed about speed, I
> tried to build it with --enable-m-debug and --enable-m-guard options.
>=20
> However, I found that gnupg failed to build with these options (actually
> it looks like --enable-m-debug was the only problem). I've attached a
> simple patch that enabled me to build gnupg with these options.
Of course, I forgot to attach the patch. Since then I ran into some
other problems and did my best to fix them. I've now got gnupg 0.9.10
running with --enable-m-debug. The patches I used are attached, this
time.
--=20
Lachlan O'Dea <mailto:lodea@vet.com.au> Computer Associates Pty Ltd
Webmaster Vet - Anti-Virus Software
http://www.vet.com.au/
"If you only knew the power of the dark side." - Darth Vader
--//IivP0gvsAy3Can
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="gnupg_m_debug.patch"
Content-Transfer-Encoding: quoted-printable
*** util/memory.c.orig Wed Aug 25 20:28:02 1999
--- util/memory.c Wed Aug 25 22:24:39 1999
***************
*** 268,274 ****
e2->next =3D e;
}
memset(p,'f', e->user_n+5);
! free(p);
}
=20
static void
--- 268,277 ----
e2->next =3D e;
}
memset(p,'f', e->user_n+5);
! if ( m_is_secure(p) )
! secmem_free(p);
! else
! free(p);
}
=20
static void
***************
*** 591,593 ****
--- 594,614 ----
return p;
}
=20
+=20
+ #ifdef M_DEBUG
+=20
+ /****************
+ * Free all objects allocated from secure memory.
+ */
+ void
+ m_debug_freeall_secure( const char *info )
+ {
+ unsigned n;
+ struct memtbl_entry *e;
+=20
+ for( e =3D memtbl, n =3D 0; n < memtbl_len; n++, e++ )
+ if ( e->inuse && m_is_secure( e->user_p ) )
+ m_debug_free( e->user_p, info );
+ }
+=20
+ #endif /* M_DEBUG */
*** util/secmem.c.orig Wed Aug 25 22:16:31 1999
--- util/secmem.c Wed Aug 25 22:22:37 1999
***************
*** 376,381 ****
--- 376,385 ----
if( !pool_okay )
return;
=20
+ #ifdef M_DEBUG
+ m_debug_freeall_secure("secmem_term");
+ #endif
+=20
memset( pool, 0xff, poolsize);
memset( pool, 0xaa, poolsize);
memset( pool, 0x55, poolsize);
*** mpi/mpiutil.c.orig Tue Jun 29 06:50:29 1999
--- mpi/mpiutil.c Tue Aug 24 21:08:58 1999
***************
*** 383,389 ****
--- 383,393 ----
* with the same flags as A.
*/
MPI
+ #ifdef M_DEBUG
+ mpi_debug_alloc_like( MPI a, const char *info )
+ #else
mpi_alloc_like( MPI a )
+ #endif
{
MPI b;
=20
***************
*** 394,401 ****
--- 398,410 ----
b =3D mpi_set_opaque( NULL, p, a->nbits );
}
else if( a ) {
+ #ifdef M_DEBUG
+ b =3D mpi_is_secure(a)? mpi_debug_alloc_secure( a->nlimbs, info )
+ : mpi_debug_alloc( a->nlimbs, info );
+ #else
b =3D mpi_is_secure(a)? mpi_alloc_secure( a->nlimbs )
: mpi_alloc( a->nlimbs );
+ #endif
b->nlimbs =3D 0;
b->sign =3D 0;
b->flags =3D a->flags;
--- include/memory.h.orig Tue Aug 24 21:00:49 1999
+++ include/memory.h Wed Aug 25 22:11:02 1999
@@ -28,8 +28,8 @@
#define M_DBGINFO(a) __FUNCTION__ "["__FILE__ ":" STR(a) "]"
#define m_alloc(n) m_debug_alloc((n), M_DBGINFO( __LINE__ ) )
#define m_alloc_clear(n) m_debug_alloc_clear((n), M_DBGINFO(__LINE__) )
-#define m_alloc_secure(n) m_debug_alloc((n), M_DBGINFO(__LINE__) )
-#define m_alloc_secure_clear(n) m_debug_alloc((n), M_DBGINFO(__LINE__) )
+#define m_alloc_secure(n) m_debug_alloc_secure((n), M_DBGINFO(__LINE__) )
+#define m_alloc_secure_clear(n) m_debug_alloc_secure_clear((n), 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_check(n) m_debug_check((n), M_DBGINFO(__LINE__) )
@@ -45,6 +45,7 @@
void m_debug_check( 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 );
+void m_debug_freeall_secure( const char *info );
=20
#else
void *m_alloc( size_t n );
*** include/mpi.h.orig Wed Jul 7 01:23:38 1999
--- include/mpi.h Tue Aug 24 21:08:58 1999
***************
*** 71,87 ****
--- 71,90 ----
#define mpi_free(a) mpi_debug_free((a), M_DBGINFO(__LINE__) )
#define mpi_resize(a,b) mpi_debug_resize((a),(b), M_DBGINFO(__LINE__) )
#define mpi_copy(a) mpi_debug_copy((a), M_DBGINFO(__LINE__) )
+ #define mpi_alloc_like(a) mpi_debug_alloc_like((a), M_DBGINFO(__LINE__)=
)
MPI mpi_debug_alloc( unsigned nlimbs, const char *info );
MPI mpi_debug_alloc_secure( unsigned nlimbs, const char *info );
void mpi_debug_free( MPI a, const char *info );
void mpi_debug_resize( MPI a, unsigned nlimbs, const char *info );
MPI mpi_debug_copy( MPI a, const char *info );
+ MPI mpi_debug_alloc_like( MPI a, const char *info );
#else
MPI mpi_alloc( unsigned nlimbs );
MPI mpi_alloc_secure( unsigned nlimbs );
void mpi_free( MPI a );
void mpi_resize( MPI a, unsigned nlimbs );
MPI mpi_copy( MPI a );
+ MPI mpi_alloc_like( MPI a );
#endif
#define mpi_is_opaque(a) ((a) && ((a)->flags&4))
MPI mpi_set_opaque( MPI a, void *p, int len );
***************
*** 92,98 ****
#define mpi_is_secure(a) ((a) && ((a)->flags&1))
void mpi_set_secure( MPI a );
void mpi_clear( MPI a );
- MPI mpi_alloc_like( MPI a );
void mpi_set( MPI w, MPI u);
void mpi_set_ui( MPI w, ulong u);
MPI mpi_alloc_set_ui( unsigned long u);
--- 95,100 ----
--//IivP0gvsAy3Can--
--CXFpZVxO6m2Ol4tQ
Content-Type: application/pgp-signature
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v0.9.10 (FreeBSD)
Comment: For info see http://www.gnupg.org
iD8DBQE3w/1hoBZahcUBONoRAUlDAKCwdX/Ocisp+8tGBy3v6Tf8H3YxSQCgls/A
q88TPiLJ5wwP3vmbB2q4QHg=
=arqr
-----END PGP SIGNATURE-----
--CXFpZVxO6m2Ol4tQ--