aboutsummaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
Diffstat (limited to 'g10')
-rw-r--r--g10/ChangeLog4
-rw-r--r--g10/armor.c8
-rw-r--r--g10/build-packet.c6
-rw-r--r--g10/card-util.c2
-rw-r--r--g10/compress-bz2.c16
-rw-r--r--g10/compress.c20
-rw-r--r--g10/decrypt.c4
-rw-r--r--g10/encode.c62
-rw-r--r--g10/exec.c40
-rw-r--r--g10/export.c11
-rw-r--r--g10/free-packet.c52
-rw-r--r--g10/g10.c118
-rw-r--r--g10/getkey.c66
-rw-r--r--g10/import.c54
-rw-r--r--g10/kbnode.c10
-rw-r--r--g10/keydb.c10
-rw-r--r--g10/keyedit.c128
-rw-r--r--g10/keygen.c226
-rw-r--r--g10/keyid.c26
-rw-r--r--g10/keylist.c14
-rw-r--r--g10/keyring.c64
-rw-r--r--g10/keyserver.c114
-rw-r--r--g10/mainproc.c64
-rw-r--r--g10/misc.c10
-rw-r--r--g10/openfile.c36
-rw-r--r--g10/parse-packet.c54
-rw-r--r--g10/passphrase.c68
-rw-r--r--g10/photoid.c22
-rw-r--r--g10/pkclist.c44
-rw-r--r--g10/plaintext.c30
-rw-r--r--g10/progress.c4
-rw-r--r--g10/pubkey-enc.c8
-rw-r--r--g10/revoke.c32
-rw-r--r--g10/seckey-cert.c18
-rw-r--r--g10/seskey.c12
-rw-r--r--g10/sig-check.c10
-rw-r--r--g10/sign.c42
-rw-r--r--g10/skclist.c10
-rw-r--r--g10/status.c24
-rw-r--r--g10/tdbio.c18
-rw-r--r--g10/textfilter.c2
-rw-r--r--g10/trustdb.c40
-rw-r--r--g10/verify.c4
43 files changed, 805 insertions, 802 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 85aff8786..9c1acbca6 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,7 @@
+2005-07-27 Werner Koch <[email protected]>
+
+ * export.c (do_export_stream): Make two strings translatable.
+
2005-07-26 David Shaw <[email protected]>
* keyserver.c (keyserver_typemap): Special-case LDAP since curl
diff --git a/g10/armor.c b/g10/armor.c
index 162997df7..c61aacbdd 100644
--- a/g10/armor.c
+++ b/g10/armor.c
@@ -1146,7 +1146,7 @@ armor_filter( void *opaque, int control,
if( afx->qp_detected )
log_error(_("quoted printable character in armor - "
"probably a buggy MTA has been used\n") );
- m_free( afx->buffer );
+ xfree( afx->buffer );
afx->buffer = NULL;
}
else if( control == IOBUFCTRL_DESC )
@@ -1163,7 +1163,7 @@ make_radix64_string( const byte *data, size_t len )
{
char *buffer, *p;
- buffer = p = m_alloc( (len+2)/3*4 + 1 );
+ buffer = p = xmalloc( (len+2)/3*4 + 1 );
for( ; len >= 3 ; len -= 3, data += 3 ) {
*p++ = bintoasc[(data[0] >> 2) & 077];
*p++ = bintoasc[(((data[0] <<4)&060)|((data[1] >> 4)&017))&077];
@@ -1223,14 +1223,14 @@ unarmor_pump_new (void)
if( !is_initialized )
initialize();
- x = m_alloc_clear (sizeof *x);
+ x = xmalloc_clear (sizeof *x);
return x;
}
void
unarmor_pump_release (UnarmorPump x)
{
- m_free (x);
+ xfree (x);
}
/*
diff --git a/g10/build-packet.c b/g10/build-packet.c
index 88b683546..f81ae8875 100644
--- a/g10/build-packet.c
+++ b/g10/build-packet.c
@@ -749,12 +749,12 @@ build_sig_subpkt (PKT_signature *sig, sigsubpkttype_t type,
/*log_debug ("updating area for type %d\n", type );*/
}
else if (oldarea) {
- newarea = m_realloc (oldarea, sizeof (*newarea) + n - 1);
+ newarea = xrealloc (oldarea, sizeof (*newarea) + n - 1);
newarea->size = n;
/*log_debug ("reallocating area for type %d\n", type );*/
}
else {
- newarea = m_alloc (sizeof (*newarea) + n - 1);
+ newarea = xmalloc (sizeof (*newarea) + n - 1);
newarea->size = n;
/*log_debug ("allocating area for type %d\n", type );*/
}
@@ -855,7 +855,7 @@ build_attribute_subpkt(PKT_user_id *uid,byte type,
/* realloc uid->attrib_data to the right size */
- uid->attrib_data=m_realloc(uid->attrib_data,
+ uid->attrib_data=xrealloc(uid->attrib_data,
uid->attrib_len+idx+1+headerlen+buflen);
attrib=&uid->attrib_data[uid->attrib_len];
diff --git a/g10/card-util.c b/g10/card-util.c
index 7077cd996..3517a74f3 100644
--- a/g10/card-util.c
+++ b/g10/card-util.c
@@ -1052,7 +1052,7 @@ generate_card_keys (const char *serialno)
want_backup=answer_is_yes_no_default(answer,1);
cpr_kill_prompt();
- m_free(answer);
+ xfree(answer);
}
#else
want_backup = cpr_get_answer_is_yes
diff --git a/g10/compress-bz2.c b/g10/compress-bz2.c
index 0454143b1..7a8075ae4 100644
--- a/g10/compress-bz2.c
+++ b/g10/compress-bz2.c
@@ -57,7 +57,7 @@ init_compress( compress_filter_context_t *zfx, bz_stream *bzs )
log_fatal("bz2lib problem: %d\n",rc);
zfx->outbufsize = 8192;
- zfx->outbuf = m_alloc( zfx->outbufsize );
+ zfx->outbuf = xmalloc( zfx->outbufsize );
}
static int
@@ -106,7 +106,7 @@ init_uncompress( compress_filter_context_t *zfx, bz_stream *bzs )
log_fatal("bz2lib problem: %d\n",rc);
zfx->inbufsize = 2048;
- zfx->inbuf = m_alloc( zfx->inbufsize );
+ zfx->inbuf = xmalloc( zfx->inbufsize );
bzs->avail_in = 0;
}
@@ -178,7 +178,7 @@ compress_filter_bz2( void *opaque, int control,
{
if( !zfx->status )
{
- bzs = zfx->opaque = m_alloc_clear( sizeof *bzs );
+ bzs = zfx->opaque = xmalloc_clear( sizeof *bzs );
init_uncompress( zfx, bzs );
zfx->status = 1;
}
@@ -205,7 +205,7 @@ compress_filter_bz2( void *opaque, int control,
pkt.pkt.compressed = &cd;
if( build_packet( a, &pkt ))
log_bug("build_packet(PKT_COMPRESSED) failed\n");
- bzs = zfx->opaque = m_alloc_clear( sizeof *bzs );
+ bzs = zfx->opaque = xmalloc_clear( sizeof *bzs );
init_compress( zfx, bzs );
zfx->status = 2;
}
@@ -219,9 +219,9 @@ compress_filter_bz2( void *opaque, int control,
if( zfx->status == 1 )
{
BZ2_bzDecompressEnd(bzs);
- m_free(bzs);
+ xfree(bzs);
zfx->opaque = NULL;
- m_free(zfx->outbuf); zfx->outbuf = NULL;
+ xfree(zfx->outbuf); zfx->outbuf = NULL;
}
else if( zfx->status == 2 )
{
@@ -229,9 +229,9 @@ compress_filter_bz2( void *opaque, int control,
bzs->avail_in = 0;
do_compress( zfx, bzs, BZ_FINISH, a );
BZ2_bzCompressEnd(bzs);
- m_free(bzs);
+ xfree(bzs);
zfx->opaque = NULL;
- m_free(zfx->outbuf); zfx->outbuf = NULL;
+ xfree(zfx->outbuf); zfx->outbuf = NULL;
}
if (zfx->release)
zfx->release (zfx);
diff --git a/g10/compress.c b/g10/compress.c
index 5c74255b9..0cee5ae54 100644
--- a/g10/compress.c
+++ b/g10/compress.c
@@ -81,7 +81,7 @@ init_compress( compress_filter_context_t *zfx, z_stream *zs )
}
zfx->outbufsize = 8192;
- zfx->outbuf = m_alloc( zfx->outbufsize );
+ zfx->outbuf = xmalloc( zfx->outbufsize );
}
static int
@@ -148,7 +148,7 @@ init_uncompress( compress_filter_context_t *zfx, z_stream *zs )
}
zfx->inbufsize = 2048;
- zfx->inbuf = m_alloc( zfx->inbufsize );
+ zfx->inbuf = xmalloc( zfx->inbufsize );
zs->avail_in = 0;
}
@@ -227,7 +227,7 @@ compress_filter( void *opaque, int control,
if( control == IOBUFCTRL_UNDERFLOW ) {
if( !zfx->status ) {
- zs = zfx->opaque = m_alloc_clear( sizeof *zs );
+ zs = zfx->opaque = xmalloc_clear( sizeof *zs );
init_uncompress( zfx, zs );
zfx->status = 1;
}
@@ -256,7 +256,7 @@ compress_filter( void *opaque, int control,
pkt.pkt.compressed = &cd;
if( build_packet( a, &pkt ))
log_bug("build_packet(PKT_COMPRESSED) failed\n");
- zs = zfx->opaque = m_alloc_clear( sizeof *zs );
+ zs = zfx->opaque = xmalloc_clear( sizeof *zs );
init_compress( zfx, zs );
zfx->status = 2;
}
@@ -272,9 +272,9 @@ compress_filter( void *opaque, int control,
else if( control == IOBUFCTRL_FREE ) {
if( zfx->status == 1 ) {
inflateEnd(zs);
- m_free(zs);
+ xfree(zs);
zfx->opaque = NULL;
- m_free(zfx->outbuf); zfx->outbuf = NULL;
+ xfree(zfx->outbuf); zfx->outbuf = NULL;
}
else if( zfx->status == 2 ) {
#ifndef __riscos__
@@ -285,9 +285,9 @@ compress_filter( void *opaque, int control,
zs->avail_in = 0;
do_compress( zfx, zs, Z_FINISH, a );
deflateEnd(zs);
- m_free(zs);
+ xfree(zs);
zfx->opaque = NULL;
- m_free(zfx->outbuf); zfx->outbuf = NULL;
+ xfree(zfx->outbuf); zfx->outbuf = NULL;
}
if (zfx->release)
zfx->release (zfx);
@@ -301,7 +301,7 @@ compress_filter( void *opaque, int control,
static void
release_context (compress_filter_context_t *ctx)
{
- m_free (ctx);
+ xfree (ctx);
}
/****************
@@ -316,7 +316,7 @@ handle_compressed( void *procctx, PKT_compressed *cd,
if(check_compress_algo(cd->algorithm))
return G10ERR_COMPR_ALGO;
- cfx = m_alloc_clear (sizeof *cfx);
+ cfx = xmalloc_clear (sizeof *cfx);
cfx->release = release_context;
cfx->algo = cd->algorithm;
push_compress_filter(cd->buf,cfx,cd->algorithm);
diff --git a/g10/decrypt.c b/g10/decrypt.c
index e6894adbe..3482e3915 100644
--- a/g10/decrypt.c
+++ b/g10/decrypt.c
@@ -178,12 +178,12 @@ decrypt_messages(int nfiles, char *files[])
g10_errstr(rc));
p = get_last_passphrase();
set_next_passphrase(p);
- m_free (p);
+ xfree (p);
next_file:
/* Note that we emit file_done even after an error. */
write_status( STATUS_FILE_DONE );
- m_free(output);
+ xfree(output);
}
set_next_passphrase(NULL);
diff --git a/g10/encode.c b/g10/encode.c
index 24b7f009e..a4906d62d 100644
--- a/g10/encode.c
+++ b/g10/encode.c
@@ -72,7 +72,7 @@ encode_seskey( DEK *dek, DEK **seskey, byte *enckey )
assert ( dek->keylen <= 32 );
if(!*seskey)
{
- *seskey=m_alloc_clear(sizeof(DEK));
+ *seskey=xmalloc_clear(sizeof(DEK));
(*seskey)->keylen=dek->keylen;
(*seskey)->algo=dek->algo;
make_session_key(*seskey);
@@ -199,7 +199,7 @@ encode_simple( const char *filename, int mode, int use_seskey )
cfx.dek = NULL;
if( mode ) {
- s2k = m_alloc_clear( sizeof *s2k );
+ s2k = xmalloc_clear( sizeof *s2k );
s2k->mode = RFC1991? 0:opt.s2k_mode;
s2k->hash_algo=S2K_DIGEST_ALGO;
cfx.dek = passphrase_to_dek( NULL, 0,
@@ -207,8 +207,8 @@ encode_simple( const char *filename, int mode, int use_seskey )
NULL, NULL);
if( !cfx.dek || !cfx.dek->keylen ) {
rc = G10ERR_PASSPHRASE;
- m_free(cfx.dek);
- m_free(s2k);
+ xfree(cfx.dek);
+ xfree(s2k);
iobuf_close(inp);
log_error(_("error creating passphrase: %s\n"), g10_errstr(rc) );
return rc;
@@ -224,7 +224,7 @@ encode_simple( const char *filename, int mode, int use_seskey )
DEK *dek = NULL;
seskeylen = cipher_get_keylen( default_cipher_algo() ) / 8;
encode_seskey( cfx.dek, &dek, enckey );
- m_free( cfx.dek ); cfx.dek = dek;
+ xfree( cfx.dek ); cfx.dek = dek;
}
if(opt.verbose)
@@ -244,8 +244,8 @@ encode_simple( const char *filename, int mode, int use_seskey )
if( rc || (rc = open_outfile( filename, opt.armor? 1:0, &out )) ) {
iobuf_cancel(inp);
- m_free(cfx.dek);
- m_free(s2k);
+ xfree(cfx.dek);
+ xfree(s2k);
return rc;
}
@@ -253,7 +253,7 @@ encode_simple( const char *filename, int mode, int use_seskey )
iobuf_push_filter( out, armor_filter, &afx );
if( s2k && !RFC1991 ) {
- PKT_symkey_enc *enc = m_alloc_clear( sizeof *enc + seskeylen + 1 );
+ PKT_symkey_enc *enc = xmalloc_clear( sizeof *enc + seskeylen + 1 );
enc->version = 4;
enc->cipher_algo = cfx.dek->algo;
enc->s2k = *s2k;
@@ -265,7 +265,7 @@ encode_simple( const char *filename, int mode, int use_seskey )
pkt.pkt.symkey_enc = enc;
if( (rc = build_packet( out, &pkt )) )
log_error("build symkey packet failed: %s\n", g10_errstr(rc) );
- m_free(enc);
+ xfree(enc);
}
if (!opt.no_literal) {
@@ -274,13 +274,13 @@ encode_simple( const char *filename, int mode, int use_seskey )
char *s = make_basename( opt.set_filename ? opt.set_filename
: filename,
iobuf_get_real_fname( inp ) );
- pt = m_alloc( sizeof *pt + strlen(s) - 1 );
+ pt = xmalloc( sizeof *pt + strlen(s) - 1 );
pt->namelen = strlen(s);
memcpy(pt->name, s, pt->namelen );
- m_free(s);
+ xfree(s);
}
else { /* no filename */
- pt = m_alloc( sizeof *pt - 1 );
+ pt = xmalloc( sizeof *pt - 1 );
pt->namelen = 0;
}
}
@@ -373,15 +373,15 @@ encode_simple( const char *filename, int mode, int use_seskey )
if (pt)
pt->buf = NULL;
free_packet(&pkt);
- m_free(cfx.dek);
- m_free(s2k);
+ xfree(cfx.dek);
+ xfree(s2k);
return rc;
}
int
setup_symkey(STRING2KEY **symkey_s2k,DEK **symkey_dek)
{
- *symkey_s2k=m_alloc_clear(sizeof(STRING2KEY));
+ *symkey_s2k=xmalloc_clear(sizeof(STRING2KEY));
(*symkey_s2k)->mode = opt.s2k_mode;
(*symkey_s2k)->hash_algo = S2K_DIGEST_ALGO;
@@ -389,8 +389,8 @@ setup_symkey(STRING2KEY **symkey_s2k,DEK **symkey_dek)
*symkey_s2k,2,NULL,NULL);
if(!*symkey_dek || !(*symkey_dek)->keylen)
{
- m_free(*symkey_dek);
- m_free(*symkey_s2k);
+ xfree(*symkey_dek);
+ xfree(*symkey_s2k);
return G10ERR_PASSPHRASE;
}
@@ -406,7 +406,7 @@ write_symkey_enc(STRING2KEY *symkey_s2k,DEK *symkey_dek,DEK *dek,IOBUF out)
byte enckey[33];
PACKET pkt;
- enc=m_alloc_clear(sizeof(PKT_symkey_enc)+seskeylen+1);
+ enc=xmalloc_clear(sizeof(PKT_symkey_enc)+seskeylen+1);
encode_seskey(symkey_dek,&dek,enckey);
enc->version = 4;
@@ -421,7 +421,7 @@ write_symkey_enc(STRING2KEY *symkey_s2k,DEK *symkey_dek,DEK *dek,IOBUF out)
if((rc=build_packet(out,&pkt)))
log_error("build symkey_enc packet failed: %s\n",g10_errstr(rc));
- m_free(enc);
+ xfree(enc);
return rc;
}
@@ -503,7 +503,7 @@ encode_crypt( const char *filename, STRLIST remusr, int use_symkey )
iobuf_push_filter( out, armor_filter, &afx );
/* create a session key */
- cfx.dek = m_alloc_secure_clear (sizeof *cfx.dek);
+ cfx.dek = xmalloc_secure_clear (sizeof *cfx.dek);
if( !opt.def_cipher_algo ) { /* try to get it from the prefs */
cfx.dek->algo = select_algo_from_prefs(pk_list,PREFTYPE_SYM,-1,NULL);
/* The only way select_algo_from_prefs can fail here is when
@@ -575,13 +575,13 @@ encode_crypt( const char *filename, STRLIST remusr, int use_symkey )
char *s = make_basename( opt.set_filename ? opt.set_filename
: filename,
iobuf_get_real_fname( inp ) );
- pt = m_alloc( sizeof *pt + strlen(s) - 1 );
+ pt = xmalloc( sizeof *pt + strlen(s) - 1 );
pt->namelen = strlen(s);
memcpy(pt->name, s, pt->namelen );
- m_free(s);
+ xfree(s);
}
else { /* no filename */
- pt = m_alloc( sizeof *pt - 1 );
+ pt = xmalloc( sizeof *pt - 1 );
pt->namelen = 0;
}
}
@@ -680,9 +680,9 @@ encode_crypt( const char *filename, STRLIST remusr, int use_symkey )
if( pt )
pt->buf = NULL;
free_packet(&pkt);
- m_free(cfx.dek);
- m_free(symkey_dek);
- m_free(symkey_s2k);
+ xfree(cfx.dek);
+ xfree(symkey_dek);
+ xfree(symkey_s2k);
release_pk_list( pk_list );
return rc;
}
@@ -706,7 +706,7 @@ encrypt_filter( void *opaque, int control,
}
else if( control == IOBUFCTRL_FLUSH ) { /* encrypt */
if( !efx->header_okay ) {
- efx->cfx.dek = m_alloc_secure_clear( sizeof *efx->cfx.dek );
+ efx->cfx.dek = xmalloc_secure_clear( sizeof *efx->cfx.dek );
if( !opt.def_cipher_algo ) { /* try to get it from the prefs */
efx->cfx.dek->algo =
@@ -758,8 +758,8 @@ encrypt_filter( void *opaque, int control,
}
else if( control == IOBUFCTRL_FREE )
{
- m_free(efx->symkey_dek);
- m_free(efx->symkey_s2k);
+ xfree(efx->symkey_dek);
+ xfree(efx->symkey_s2k);
}
else if( control == IOBUFCTRL_DESC ) {
*(char**)buf = "encrypt_filter";
@@ -785,7 +785,7 @@ write_pubkey_enc_from_list( PK_LIST pk_list, DEK *dek, IOBUF out )
pk = pk_list->pk;
print_pubkey_algo_note( pk->pubkey_algo );
- enc = m_alloc_clear( sizeof *enc );
+ enc = xmalloc_clear( sizeof *enc );
enc->pubkey_algo = pk->pubkey_algo;
keyid_from_pk( pk, enc->keyid );
enc->throw_keyid = (opt.throw_keyid || (pk_list->flags&1));
@@ -822,7 +822,7 @@ write_pubkey_enc_from_list( PK_LIST pk_list, DEK *dek, IOBUF out )
log_info(_("%s/%s encrypted for: \"%s\"\n"),
pubkey_algo_to_string(enc->pubkey_algo),
cipher_algo_to_string(dek->algo), ustr );
- m_free(ustr);
+ xfree(ustr);
}
/* and write it */
init_packet(&pkt);
diff --git a/g10/exec.c b/g10/exec.c
index 32f23b4b5..8e00a5ac6 100644
--- a/g10/exec.c
+++ b/g10/exec.c
@@ -72,7 +72,7 @@ static int win_system(const char *command)
/* We must use a copy of the command as CreateProcess modifies this
argument. */
- string=m_strdup(command);
+ string=xstrdup(command);
memset(&pi,0,sizeof(pi));
memset(&si,0,sizeof(si));
@@ -86,7 +86,7 @@ static int win_system(const char *command)
CloseHandle(pi.hProcess);
CloseHandle(pi.hThread);
- m_free(string);
+ xfree(string);
return 0;
}
@@ -97,7 +97,7 @@ int set_exec_path(const char *path)
{
char *p;
- p=m_alloc(5+strlen(path)+1);
+ p=xmalloc(5+strlen(path)+1);
strcpy(p,"PATH=");
strcat(p,path);
@@ -129,7 +129,7 @@ static int make_tempdir(struct exec_info *info)
if(tmp==NULL)
{
#if defined (_WIN32)
- tmp=m_alloc(256);
+ tmp=xmalloc(256);
if(GetTempPath(256,tmp)==0)
strcpy(tmp,"c:\\windows\\temp");
else
@@ -161,12 +161,12 @@ static int make_tempdir(struct exec_info *info)
#endif
}
- info->tempdir=m_alloc(strlen(tmp)+strlen(DIRSEP_S)+10+1);
+ info->tempdir=xmalloc(strlen(tmp)+strlen(DIRSEP_S)+10+1);
sprintf(info->tempdir,"%s" DIRSEP_S "gpg-XXXXXX",tmp);
#if defined (_WIN32)
- m_free(tmp);
+ xfree(tmp);
#endif
if(mkdtemp(info->tempdir)==NULL)
@@ -176,13 +176,13 @@ static int make_tempdir(struct exec_info *info)
{
info->madedir=1;
- info->tempfile_in=m_alloc(strlen(info->tempdir)+
+ info->tempfile_in=xmalloc(strlen(info->tempdir)+
strlen(DIRSEP_S)+strlen(namein)+1);
sprintf(info->tempfile_in,"%s" DIRSEP_S "%s",info->tempdir,namein);
if(!info->writeonly)
{
- info->tempfile_out=m_alloc(strlen(info->tempdir)+
+ info->tempfile_out=xmalloc(strlen(info->tempdir)+
strlen(DIRSEP_S)+strlen(nameout)+1);
sprintf(info->tempfile_out,"%s" DIRSEP_S "%s",info->tempdir,nameout);
}
@@ -205,7 +205,7 @@ static int expand_args(struct exec_info *info,const char *args_in)
log_debug("expanding string \"%s\"\n",args_in);
size=100;
- info->command=m_alloc(size);
+ info->command=xmalloc(size);
len=0;
info->command[0]='\0';
@@ -262,7 +262,7 @@ static int expand_args(struct exec_info *info,const char *args_in)
applen=100;
size+=applen;
- info->command=m_realloc(info->command,size);
+ info->command=xrealloc(info->command,size);
}
strcat(info->command,append);
@@ -274,7 +274,7 @@ static int expand_args(struct exec_info *info,const char *args_in)
if(len==size-1) /* leave room for the \0 */
{
size+=100;
- info->command=m_realloc(info->command,size);
+ info->command=xrealloc(info->command,size);
}
info->command[len++]=*ch;
@@ -292,7 +292,7 @@ static int expand_args(struct exec_info *info,const char *args_in)
fail:
- m_free(info->command);
+ xfree(info->command);
info->command=NULL;
return G10ERR_GENERAL;
@@ -327,10 +327,10 @@ int exec_write(struct exec_info **info,const char *program,
if(program==NULL && args_in==NULL)
BUG();
- *info=m_alloc_clear(sizeof(struct exec_info));
+ *info=xmalloc_clear(sizeof(struct exec_info));
if(name)
- (*info)->name=m_strdup(name);
+ (*info)->name=xstrdup(name);
(*info)->binary=binary;
(*info)->writeonly=writeonly;
@@ -611,12 +611,12 @@ int exec_finish(struct exec_info *info)
info->tempdir,strerror(errno));
}
- m_free(info->command);
- m_free(info->name);
- m_free(info->tempdir);
- m_free(info->tempfile_in);
- m_free(info->tempfile_out);
- m_free(info);
+ xfree(info->command);
+ xfree(info->name);
+ xfree(info->tempdir);
+ xfree(info->tempfile_in);
+ xfree(info->tempfile_out);
+ xfree(info);
return ret;
}
diff --git a/g10/export.c b/g10/export.c
index 3a6ebb505..cf1a3cc2b 100644
--- a/g10/export.c
+++ b/g10/export.c
@@ -163,13 +163,13 @@ do_export_stream( IOBUF out, STRLIST users, int secret,
if (!users) {
ndesc = 1;
- desc = m_alloc_clear ( ndesc * sizeof *desc);
+ desc = xmalloc_clear ( ndesc * sizeof *desc);
desc[0].mode = KEYDB_SEARCH_MODE_FIRST;
}
else {
for (ndesc=0, sl=users; sl; sl = sl->next, ndesc++)
;
- desc = m_alloc ( ndesc * sizeof *desc);
+ desc = xmalloc ( ndesc * sizeof *desc);
for (ndesc=0, sl=users; sl; sl = sl->next) {
if (classify_user_id (sl->d, desc+ndesc))
@@ -406,7 +406,7 @@ do_export_stream( IOBUF out, STRLIST users, int secret,
sk = copy_secret_key (NULL, sk_save);
node->pkt->pkt.secret_key = sk;
- log_info ("about to export an unprotected subkey\n");
+ log_info (_("about to export an unprotected subkey\n"));
switch (is_secret_key_protected (sk))
{
case -1:
@@ -429,8 +429,7 @@ do_export_stream( IOBUF out, STRLIST users, int secret,
{
node->pkt->pkt.secret_key = sk_save;
free_secret_key (sk);
- /* FIXME: Make translatable after releasing 1.4.2 */
- log_error ("failed to unprotect the subkey: %s\n",
+ log_error (_("failed to unprotect the subkey: %s\n"),
g10_errstr (rc));
goto leave;
}
@@ -478,7 +477,7 @@ do_export_stream( IOBUF out, STRLIST users, int secret,
rc = 0;
leave:
- m_free(desc);
+ xfree(desc);
keydb_release (kdbhd);
if(rc || keyblock_out==NULL)
release_kbnode( keyblock );
diff --git a/g10/free-packet.c b/g10/free-packet.c
index a4dadb417..3ede4db9f 100644
--- a/g10/free-packet.c
+++ b/g10/free-packet.c
@@ -37,7 +37,7 @@
void
free_symkey_enc( PKT_symkey_enc *enc )
{
- m_free(enc);
+ xfree(enc);
}
void
@@ -49,7 +49,7 @@ free_pubkey_enc( PKT_pubkey_enc *enc )
mpi_free(enc->data[0]);
for(i=0; i < n; i++ )
mpi_free( enc->data[i] );
- m_free(enc);
+ xfree(enc);
}
void
@@ -63,10 +63,10 @@ free_seckey_enc( PKT_signature *sig )
for(i=0; i < n; i++ )
mpi_free( sig->data[i] );
- m_free(sig->revkey);
- m_free(sig->hashed);
- m_free(sig->unhashed);
- m_free(sig);
+ xfree(sig->revkey);
+ xfree(sig->hashed);
+ xfree(sig->unhashed);
+ xfree(sig);
}
@@ -82,7 +82,7 @@ release_public_key_parts( PKT_public_key *pk )
pk->pkey[i] = NULL;
}
if (pk->prefs) {
- m_free (pk->prefs);
+ xfree (pk->prefs);
pk->prefs = NULL;
}
if (pk->user_id) {
@@ -90,7 +90,7 @@ release_public_key_parts( PKT_public_key *pk )
pk->user_id = NULL;
}
if (pk->revkey) {
- m_free(pk->revkey);
+ xfree(pk->revkey);
pk->revkey=NULL;
pk->numrevkeys=0;
}
@@ -101,7 +101,7 @@ void
free_public_key( PKT_public_key *pk )
{
release_public_key_parts( pk );
- m_free(pk);
+ xfree(pk);
}
@@ -112,7 +112,7 @@ cp_subpktarea (subpktarea_t *s )
if( !s )
return NULL;
- d = m_alloc (sizeof (*d) + s->size - 1 );
+ d = xmalloc (sizeof (*d) + s->size - 1 );
d->size = s->size;
d->len = s->len;
memcpy (d->data, s->data, s->len);
@@ -133,7 +133,7 @@ copy_prefs (const prefitem_t *prefs)
for (n=0; prefs[n].type; n++)
;
- new = m_alloc ( sizeof (*new) * (n+1));
+ new = xmalloc ( sizeof (*new) * (n+1));
for (n=0; prefs[n].type; n++) {
new[n].type = prefs[n].type;
new[n].value = prefs[n].value;
@@ -151,7 +151,7 @@ copy_public_key ( PKT_public_key *d, PKT_public_key *s)
int n, i;
if( !d )
- d = m_alloc(sizeof *d);
+ d = xmalloc(sizeof *d);
memcpy( d, s, sizeof *d );
d->user_id = scopy_user_id (s->user_id);
d->prefs = copy_prefs (s->prefs);
@@ -165,7 +165,7 @@ copy_public_key ( PKT_public_key *d, PKT_public_key *s)
if( !s->revkey && s->numrevkeys )
BUG();
if( s->numrevkeys ) {
- d->revkey = m_alloc(sizeof(struct revocation_key)*s->numrevkeys);
+ d->revkey = xmalloc(sizeof(struct revocation_key)*s->numrevkeys);
memcpy(d->revkey,s->revkey,sizeof(struct revocation_key)*s->numrevkeys);
}
else
@@ -201,7 +201,7 @@ copy_signature( PKT_signature *d, PKT_signature *s )
int n, i;
if( !d )
- d = m_alloc(sizeof *d);
+ d = xmalloc(sizeof *d);
memcpy( d, s, sizeof *d );
n = pubkey_get_nsig( s->pubkey_algo );
if( !n )
@@ -253,7 +253,7 @@ void
free_secret_key( PKT_secret_key *sk )
{
release_secret_key_parts( sk );
- m_free(sk);
+ xfree(sk);
}
PKT_secret_key *
@@ -262,7 +262,7 @@ copy_secret_key( PKT_secret_key *d, PKT_secret_key *s )
int n, i;
if( !d )
- d = m_alloc(sizeof *d);
+ d = xmalloc(sizeof *d);
else
release_secret_key_parts (d);
memcpy( d, s, sizeof *d );
@@ -280,14 +280,14 @@ copy_secret_key( PKT_secret_key *d, PKT_secret_key *s )
void
free_comment( PKT_comment *rem )
{
- m_free(rem);
+ xfree(rem);
}
void
free_attributes(PKT_user_id *uid)
{
- m_free(uid->attribs);
- m_free(uid->attrib_data);
+ xfree(uid->attribs);
+ xfree(uid->attrib_data);
uid->attribs=NULL;
uid->attrib_data=NULL;
@@ -302,9 +302,9 @@ free_user_id (PKT_user_id *uid)
return;
free_attributes(uid);
- m_free (uid->prefs);
- m_free (uid->namehash);
- m_free (uid);
+ xfree (uid->prefs);
+ xfree (uid->namehash);
+ xfree (uid);
}
void
@@ -316,7 +316,7 @@ free_compressed( PKT_compressed *zd )
while( iobuf_read( zd->buf, NULL, 1<<30 ) != -1 )
;
}
- m_free(zd);
+ xfree(zd);
}
void
@@ -337,7 +337,7 @@ free_encrypted( PKT_encrypted *ed )
}
}
}
- m_free(ed);
+ xfree(ed);
}
@@ -359,7 +359,7 @@ free_plaintext( PKT_plaintext *pt )
}
}
}
- m_free(pt);
+ xfree(pt);
}
/****************
@@ -409,7 +409,7 @@ free_packet( PACKET *pkt )
free_plaintext( pkt->pkt.plaintext );
break;
default:
- m_free( pkt->pkt.generic );
+ xfree( pkt->pkt.generic );
break;
}
pkt->pkt.generic = NULL;
diff --git a/g10/g10.c b/g10/g10.c
index eea79da4c..fce9f3ad1 100644
--- a/g10/g10.c
+++ b/g10/g10.c
@@ -802,7 +802,7 @@ build_list( const char *text, char letter,
for(i=0; i <= 110; i++ )
if( !chkf(i) && (s=mapf(i)) )
n += strlen(s) + 7 + 2;
- list = m_alloc( 21 + n ); *list = 0;
+ list = xmalloc( 21 + n ); *list = 0;
for(p=NULL, i=0; i <= 110; i++ ) {
if( !chkf(i) && (s=mapf(i)) ) {
if( !p ) {
@@ -815,7 +815,7 @@ build_list( const char *text, char letter,
if(strlen(line)>60) {
int spaces=strlen(text);
- list=m_realloc(list,n+spaces+1);
+ list=xrealloc(list,n+spaces+1);
/* realloc could move the block, so find the end again */
p=list;
while(*p)
@@ -871,7 +871,7 @@ make_username( const char *string )
{
char *p;
if( utf8_strings )
- p = m_strdup(string);
+ p = xstrdup(string);
else
p = native_to_utf8( string );
return p;
@@ -1038,7 +1038,7 @@ add_group(char *string)
if(!item)
{
- item=m_alloc(sizeof(struct groupitem));
+ item=xmalloc(sizeof(struct groupitem));
item->name=name;
item->next=opt.grouplist;
item->values=NULL;
@@ -1071,7 +1071,7 @@ rm_group(char *name)
opt.grouplist=item->next;
free_strlist(item->values);
- m_free(item);
+ xfree(item);
break;
}
}
@@ -1114,7 +1114,7 @@ check_permissions(const char *path,int item)
tmppath=make_filename(GNUPG_LIBDIR,path,NULL);
}
else
- tmppath=m_strdup(path);
+ tmppath=xstrdup(path);
/* If the item is located in the homedir, but isn't the homedir,
don't continue if we already checked the homedir itself. This is
@@ -1147,7 +1147,7 @@ check_permissions(const char *path,int item)
goto end;
}
- m_free(dir);
+ xfree(dir);
/* Assume failure */
ret=1;
@@ -1270,7 +1270,7 @@ check_permissions(const char *path,int item)
}
end:
- m_free(tmppath);
+ xfree(tmppath);
if(homedir)
homedir_cache=ret;
@@ -1479,8 +1479,8 @@ parse_subpacket_list(char *list)
}
}
- m_free(opt.show_subpackets);
- opt.show_subpackets=m_alloc(count+1);
+ xfree(opt.show_subpackets);
+ opt.show_subpackets=xmalloc(count+1);
opt.show_subpackets[count--]=0;
for(i=1;i<128 && count>=0;i++)
@@ -1531,7 +1531,7 @@ parse_list_options(char *str)
else if(subpackets==NULL && opt.show_subpackets)
{
/* User did 'no-show-subpackets' */
- m_free(opt.show_subpackets);
+ xfree(opt.show_subpackets);
opt.show_subpackets=NULL;
}
@@ -1552,7 +1552,7 @@ collapse_args(int argc,char *argv[])
for(i=0;i<argc;i++)
{
len+=strlen(argv[i])+2;
- str=m_realloc(str,len);
+ str=xrealloc(str,len);
if(first)
{
str[0]='\0';
@@ -1641,7 +1641,7 @@ main (int argc, char **argv )
* secmem_init() somewhere after the option parsing
*/
log_set_name("gpg");
- secure_random_alloc(); /* put random number into secure memory */
+ secure_randoxmalloc(); /* put random number into secure memory */
may_coredump = disable_core_dumps();
init_signals();
create_dotlock(NULL); /* register locking cleanup */
@@ -1740,7 +1740,7 @@ main (int argc, char **argv )
#ifdef HAVE_DOSISH_SYSTEM
if ( strchr (opt.homedir,'\\') ) {
- char *d, *buf = m_alloc (strlen (opt.homedir)+1);
+ char *d, *buf = xmalloc (strlen (opt.homedir)+1);
const char *s = opt.homedir;
for (d=buf,s=opt.homedir; *s; s++)
*d++ = *s == '\\'? '/': *s;
@@ -1770,7 +1770,7 @@ main (int argc, char **argv )
/* Try for a version specific config file first */
if( default_config )
{
- char *name=m_strdup("gpg" EXTSEP_S "conf-" SAFE_VERSION);
+ char *name=xstrdup("gpg" EXTSEP_S "conf-" SAFE_VERSION);
char *ver=&name[strlen("gpg" EXTSEP_S "conf-")];
do
@@ -1779,7 +1779,7 @@ main (int argc, char **argv )
{
char *tok;
- m_free(configname);
+ xfree(configname);
configname=NULL;
if((tok=strrchr(ver,SAFE_VERSION_DASH)))
@@ -1794,7 +1794,7 @@ main (int argc, char **argv )
}
while(access(configname,R_OK));
- m_free(name);
+ xfree(name);
if(!configname)
configname=make_filename(opt.homedir, "gpg" EXTSEP_S "conf", NULL );
@@ -1803,11 +1803,11 @@ main (int argc, char **argv )
char *p = make_filename(opt.homedir, "options", NULL );
if (!access (p, R_OK))
log_info (_("NOTE: old default options file `%s' ignored\n"), p);
- m_free (p);
+ xfree (p);
}
else
{ /* Keep on using the old default one. */
- m_free (configname);
+ xfree (configname);
configname = make_filename(opt.homedir, "options", NULL );
}
}
@@ -1852,7 +1852,7 @@ main (int argc, char **argv )
configname, strerror(errno) );
g10_exit(2);
}
- m_free(configname); configname = NULL;
+ xfree(configname); configname = NULL;
}
if( parse_debug && configname )
log_info(_("reading options from `%s'\n"), configname );
@@ -2022,8 +2022,8 @@ main (int argc, char **argv )
case oOptions:
/* config files may not be nested (silently ignore them) */
if( !configfp ) {
- m_free(configname);
- configname = m_strdup(pargs.r.ret_str);
+ xfree(configname);
+ configname = xstrdup(pargs.r.ret_str);
goto next_pass;
}
break;
@@ -2045,11 +2045,11 @@ main (int argc, char **argv )
opt.def_recipient = make_username(pargs.r.ret_str);
break;
case oDefRecipientSelf:
- m_free(opt.def_recipient); opt.def_recipient = NULL;
+ xfree(opt.def_recipient); opt.def_recipient = NULL;
opt.def_recipient_self = 1;
break;
case oNoDefRecipient:
- m_free(opt.def_recipient); opt.def_recipient = NULL;
+ xfree(opt.def_recipient); opt.def_recipient = NULL;
opt.def_recipient_self = 0;
break;
case oNoOptions: opt.no_homedir_creation = 1; break; /* no-options */
@@ -2206,8 +2206,8 @@ main (int argc, char **argv )
case oDisableMDC: opt.disable_mdc = 1; break;
case oNoDisableMDC: opt.disable_mdc = 0; break;
case oS2KMode: opt.s2k_mode = pargs.r.ret_int; break;
- case oS2KDigest: s2k_digest_string = m_strdup(pargs.r.ret_str); break;
- case oS2KCipher: s2k_cipher_string = m_strdup(pargs.r.ret_str); break;
+ case oS2KDigest: s2k_digest_string = xstrdup(pargs.r.ret_str); break;
+ case oS2KCipher: s2k_cipher_string = xstrdup(pargs.r.ret_str); break;
case oSimpleSKChecksum: opt.simple_sk_checksum = 1; break;
case oNoEncryptTo: opt.no_encrypt_to = 1; break;
case oEncryptTo: /* store the recipient in the second list */
@@ -2284,10 +2284,10 @@ main (int argc, char **argv )
opt.command_fd = open_info_file (pargs.r.ret_str, 0);
break;
case oCipherAlgo:
- def_cipher_string = m_strdup(pargs.r.ret_str);
+ def_cipher_string = xstrdup(pargs.r.ret_str);
break;
case oDigestAlgo:
- def_digest_string = m_strdup(pargs.r.ret_str);
+ def_digest_string = xstrdup(pargs.r.ret_str);
break;
case oCompressAlgo:
/* If it is all digits, stick a Z in front of it for
@@ -2305,15 +2305,15 @@ main (int argc, char **argv )
if(*pt=='\0')
{
- compress_algo_string=m_alloc(strlen(pargs.r.ret_str)+2);
+ compress_algo_string=xmalloc(strlen(pargs.r.ret_str)+2);
strcpy(compress_algo_string,"Z");
strcat(compress_algo_string,pargs.r.ret_str);
}
else
- compress_algo_string = m_strdup(pargs.r.ret_str);
+ compress_algo_string = xstrdup(pargs.r.ret_str);
}
break;
- case oCertDigestAlgo: cert_digest_string = m_strdup(pargs.r.ret_str); break;
+ case oCertDigestAlgo: cert_digest_string = xstrdup(pargs.r.ret_str); break;
case oNoSecmemWarn: secmem_set_flags( secmem_get_flags() | 1 ); break;
case oRequireSecmem: require_secmem=1; break;
case oNoRequireSecmem: require_secmem=0; break;
@@ -2524,7 +2524,7 @@ main (int argc, char **argv )
struct groupitem *iter=opt.grouplist;
free_strlist(iter->values);
opt.grouplist=opt.grouplist->next;
- m_free(iter);
+ xfree(iter);
}
break;
case oStrict: opt.strict=1; log_set_strict(1); break;
@@ -2569,11 +2569,11 @@ main (int argc, char **argv )
if (!save_configname)
save_configname = configname;
else
- m_free(configname);
+ xfree(configname);
configname = NULL;
goto next_pass;
}
- m_free( configname ); configname = NULL;
+ xfree( configname ); configname = NULL;
if( log_get_errorcount(0) )
g10_exit(2);
@@ -2584,7 +2584,7 @@ main (int argc, char **argv )
gpgconf_list (save_configname);
g10_exit (0);
}
- m_free (save_configname);
+ xfree (save_configname);
if( nogreeting )
greeting = 0;
@@ -2699,8 +2699,8 @@ main (int argc, char **argv )
/* This only sets IDEA for symmetric encryption
since it is set via select_algo_from_prefs for
pk encryption. */
- m_free(def_cipher_string);
- def_cipher_string = m_strdup("idea");
+ xfree(def_cipher_string);
+ def_cipher_string = xstrdup("idea");
}
/* PGP2 can't handle the output from the textmode
@@ -2722,10 +2722,10 @@ main (int argc, char **argv )
opt.pgp2_workarounds = 1;
opt.ask_sig_expire = 0;
opt.ask_cert_expire = 0;
- m_free(def_digest_string);
- def_digest_string = m_strdup("md5");
- m_free(s2k_digest_string);
- s2k_digest_string = m_strdup("md5");
+ xfree(def_digest_string);
+ def_digest_string = xstrdup("md5");
+ xfree(s2k_digest_string);
+ s2k_digest_string = xstrdup("md5");
opt.compress_algo = COMPRESS_ALGO_ZIP;
}
}
@@ -2754,37 +2754,37 @@ main (int argc, char **argv )
(ascii_strcasecmp(def_cipher_string,"idea")==0
|| ascii_strcasecmp(def_cipher_string,"s1")==0))
idea_cipher_warn(1);
- m_free(def_cipher_string); def_cipher_string = NULL;
+ xfree(def_cipher_string); def_cipher_string = NULL;
if( check_cipher_algo(opt.def_cipher_algo) )
log_error(_("selected cipher algorithm is invalid\n"));
}
if( def_digest_string ) {
opt.def_digest_algo = string_to_digest_algo(def_digest_string);
- m_free(def_digest_string); def_digest_string = NULL;
+ xfree(def_digest_string); def_digest_string = NULL;
if( check_digest_algo(opt.def_digest_algo) )
log_error(_("selected digest algorithm is invalid\n"));
}
if( compress_algo_string ) {
opt.compress_algo = string_to_compress_algo(compress_algo_string);
- m_free(compress_algo_string); compress_algo_string = NULL;
+ xfree(compress_algo_string); compress_algo_string = NULL;
if( check_compress_algo(opt.compress_algo) )
log_error(_("selected compression algorithm is invalid\n"));
}
if( cert_digest_string ) {
opt.cert_digest_algo = string_to_digest_algo(cert_digest_string);
- m_free(cert_digest_string); cert_digest_string = NULL;
+ xfree(cert_digest_string); cert_digest_string = NULL;
if( check_digest_algo(opt.cert_digest_algo) )
log_error(_("selected certification digest algorithm is invalid\n"));
}
if( s2k_cipher_string ) {
opt.s2k_cipher_algo = string_to_cipher_algo(s2k_cipher_string);
- m_free(s2k_cipher_string); s2k_cipher_string = NULL;
+ xfree(s2k_cipher_string); s2k_cipher_string = NULL;
if( check_cipher_algo(opt.s2k_cipher_algo) )
log_error(_("selected cipher algorithm is invalid\n"));
}
if( s2k_digest_string ) {
opt.s2k_digest_algo = string_to_digest_algo(s2k_digest_string);
- m_free(s2k_digest_string); s2k_digest_string = NULL;
+ xfree(s2k_digest_string); s2k_digest_string = NULL;
if( check_digest_algo(opt.s2k_digest_algo) )
log_error(_("selected digest algorithm is invalid\n"));
}
@@ -2936,7 +2936,7 @@ main (int argc, char **argv )
set_random_seed_file(p);
if (!access (p, F_OK))
register_secured_file (p);
- m_free(p);
+ xfree(p);
}
if( !cmd && opt.fingerprint && !with_fpr ) {
@@ -3093,7 +3093,7 @@ main (int argc, char **argv )
if( argc > 1 )
wrong_args(_("--sign [filename]"));
if( argc ) {
- sl = m_alloc_clear( sizeof *sl + strlen(fname));
+ sl = xmalloc_clear( sizeof *sl + strlen(fname));
strcpy(sl->d, fname);
}
}
@@ -3106,7 +3106,7 @@ main (int argc, char **argv )
if( argc > 1 )
wrong_args(_("--sign --encrypt [filename]"));
if( argc ) {
- sl = m_alloc_clear( sizeof *sl + strlen(fname));
+ sl = xmalloc_clear( sizeof *sl + strlen(fname));
strcpy(sl->d, fname);
}
else
@@ -3130,7 +3130,7 @@ main (int argc, char **argv )
{
if( argc )
{
- sl = m_alloc_clear( sizeof *sl + strlen(fname));
+ sl = xmalloc_clear( sizeof *sl + strlen(fname));
strcpy(sl->d, fname);
}
else
@@ -3205,7 +3205,7 @@ main (int argc, char **argv )
append_to_strlist( &sl, "save" );
username = make_username( fname );
keyedit_menu(fname, locusr, sl, 0, 0 );
- m_free(username);
+ xfree(username);
free_strlist(sl);
break;
@@ -3222,7 +3222,7 @@ main (int argc, char **argv )
}
else
keyedit_menu(username, locusr, NULL, 0, 1 );
- m_free(username);
+ xfree(username);
break;
case aDeleteKeys:
@@ -3369,7 +3369,7 @@ main (int argc, char **argv )
wrong_args("--gen-revoke user-id");
username = make_username(*argv);
gen_revoke( username );
- m_free( username );
+ xfree( username );
break;
case aDesigRevoke:
@@ -3377,7 +3377,7 @@ main (int argc, char **argv )
wrong_args("--desig-revoke user-id");
username = make_username(*argv);
gen_desig_revoke( username );
- m_free( username );
+ xfree( username );
break;
case aDeArmor:
@@ -3455,7 +3455,7 @@ main (int argc, char **argv )
if (opt.armor) {
char *tmp = make_radix64_string (p, n);
fputs (tmp, stdout);
- m_free (tmp);
+ xfree (tmp);
if (n%3 == 1)
putchar ('=');
if (n%3)
@@ -3463,7 +3463,7 @@ main (int argc, char **argv )
} else {
fwrite( p, n, 1, stdout );
}
- m_free(p);
+ xfree(p);
if( !endless )
count -= n;
}
@@ -3534,7 +3534,7 @@ main (int argc, char **argv )
for( ; argc; argc--, argv++ ) {
username = make_username( *argv );
list_trust_path( username );
- m_free(username);
+ xfree(username);
}
break;
@@ -3595,7 +3595,7 @@ main (int argc, char **argv )
{
char *str=collapse_args(argc,argv);
list_config(str);
- m_free(str);
+ xfree(str);
}
break;
diff --git a/g10/getkey.c b/g10/getkey.c
index 5bd990765..7991b81af 100644
--- a/g10/getkey.c
+++ b/g10/getkey.c
@@ -152,7 +152,7 @@ cache_public_key( PKT_public_key *pk )
return;
}
pk_cache_entries++;
- ce = m_alloc( sizeof *ce );
+ ce = xmalloc( sizeof *ce );
ce->next = pk_cache;
pk_cache = ce;
ce->pk = copy_public_key( NULL, pk );
@@ -195,7 +195,7 @@ release_keyid_list ( keyid_list_t k )
{
while ( k ) {
keyid_list_t k2 = k->next;
- m_free (k);
+ xfree (k);
k = k2;
}
}
@@ -216,7 +216,7 @@ cache_user_id( KBNODE keyblock )
for (k=keyblock; k; k = k->next ) {
if ( k->pkt->pkttype == PKT_PUBLIC_KEY
|| k->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
- keyid_list_t a = m_alloc_clear ( sizeof *a );
+ keyid_list_t a = xmalloc_clear ( sizeof *a );
/* Hmmm: For a long list of keyids it might be an advantage
* to append the keys */
keyid_from_pk( k->pkt->pkt.public_key, a->keyid );
@@ -229,7 +229,7 @@ cache_user_id( KBNODE keyblock )
if( DBG_CACHE )
log_debug("cache_user_id: already in cache\n");
release_keyid_list ( keyids );
- m_free ( a );
+ xfree ( a );
return;
}
}
@@ -250,10 +250,10 @@ cache_user_id( KBNODE keyblock )
r = user_id_db;
user_id_db = r->next;
release_keyid_list ( r->keyids );
- m_free(r);
+ xfree(r);
uid_cache_entries--;
}
- r = m_alloc( sizeof *r + uidlen-1 );
+ r = xmalloc( sizeof *r + uidlen-1 );
r->keyids = keyids;
r->len = uidlen;
memcpy(r->name, uid, r->len);
@@ -273,7 +273,7 @@ getkey_disable_caches()
for( ce = pk_cache; ce; ce = ce2 ) {
ce2 = ce->next;
free_public_key( ce->pk );
- m_free( ce );
+ xfree( ce );
}
pk_cache_disabled=1;
pk_cache_entries = 0;
@@ -338,7 +338,7 @@ get_pubkey( PKT_public_key *pk, u32 *keyid )
#endif
/* more init stuff */
if( !pk ) {
- pk = m_alloc_clear( sizeof *pk );
+ pk = xmalloc_clear( sizeof *pk );
internal++;
}
@@ -810,7 +810,7 @@ key_byname( GETKEY_CTX *retctx, STRLIST namelist,
if(!namelist)
{
- ctx = m_alloc_clear (sizeof *ctx);
+ ctx = xmalloc_clear (sizeof *ctx);
ctx->nitems = 1;
ctx->items[0].mode=KEYDB_SEARCH_MODE_FIRST;
if(!include_unusable)
@@ -822,7 +822,7 @@ key_byname( GETKEY_CTX *retctx, STRLIST namelist,
for(n=0, r=namelist; r; r = r->next )
n++;
- ctx = m_alloc_clear (sizeof *ctx + (n-1)*sizeof ctx->items );
+ ctx = xmalloc_clear (sizeof *ctx + (n-1)*sizeof ctx->items );
ctx->nitems = n;
for(n=0, r=namelist; r; r = r->next, n++ )
@@ -833,7 +833,7 @@ key_byname( GETKEY_CTX *retctx, STRLIST namelist,
ctx->exact = 1;
if (!ctx->items[n].mode)
{
- m_free (ctx);
+ xfree (ctx);
return G10ERR_INV_USER_ID;
}
if(!include_unusable
@@ -932,7 +932,7 @@ get_pubkey_end( GETKEY_CTX ctx )
memset (&ctx->kbpos, 0, sizeof ctx->kbpos);
keydb_release (ctx->kr_handle);
if( !ctx->not_allocated )
- m_free( ctx );
+ xfree( ctx );
}
}
@@ -1392,12 +1392,12 @@ fixup_uidnode ( KBNODE uidnode, KBNODE signode, u32 keycreated )
p = parse_sig_subpkt ( sig->hashed, SIGSUBPKT_PREF_COMPR, &n );
zip = p; nzip = p?n:0;
if (uid->prefs)
- m_free (uid->prefs);
+ xfree (uid->prefs);
n = nsym + nhash + nzip;
if (!n)
uid->prefs = NULL;
else {
- uid->prefs = m_alloc (sizeof (*uid->prefs) * (n+1));
+ uid->prefs = xmalloc (sizeof (*uid->prefs) * (n+1));
n = 0;
for (; nsym; nsym--, n++) {
uid->prefs[n].type = PREFTYPE_SYM;
@@ -1477,7 +1477,7 @@ merge_selfsigs_main(KBNODE keyblock, int *r_revoked, struct revoke_info *rinfo)
*/
/* In case this key was already merged */
- m_free(pk->revkey);
+ xfree(pk->revkey);
pk->revkey=NULL;
pk->numrevkeys=0;
@@ -1514,7 +1514,7 @@ merge_selfsigs_main(KBNODE keyblock, int *r_revoked, struct revoke_info *rinfo)
int i;
pk->revkey=
- m_realloc(pk->revkey,sizeof(struct revocation_key)*
+ xrealloc(pk->revkey,sizeof(struct revocation_key)*
(pk->numrevkeys+sig->numrevkeys));
for(i=0;i<sig->numrevkeys;i++)
@@ -1565,7 +1565,7 @@ merge_selfsigs_main(KBNODE keyblock, int *r_revoked, struct revoke_info *rinfo)
}
if(changed)
- pk->revkey=m_realloc(pk->revkey,
+ pk->revkey=xrealloc(pk->revkey,
pk->numrevkeys*sizeof(struct revocation_key));
}
@@ -1703,7 +1703,7 @@ merge_selfsigs_main(KBNODE keyblock, int *r_revoked, struct revoke_info *rinfo)
{
PKT_public_key *ultimate_pk;
- ultimate_pk=m_alloc_clear(sizeof(*ultimate_pk));
+ ultimate_pk=xmalloc_clear(sizeof(*ultimate_pk));
/* We don't want to use the full get_pubkey to
avoid infinite recursion in certain cases.
@@ -2023,7 +2023,7 @@ merge_selfsigs_subkey( KBNODE keyblock, KBNODE subnode )
if(p)
{
- PKT_signature *backsig=m_alloc_clear(sizeof(PKT_signature));
+ PKT_signature *backsig=xmalloc_clear(sizeof(PKT_signature));
IOBUF backsig_buf=iobuf_temp_with_content(p,n);
if(parse_signature(backsig_buf,PKT_SIGNATURE,n,backsig)==0)
@@ -2133,7 +2133,7 @@ merge_selfsigs( KBNODE keyblock )
|| k->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
PKT_public_key *pk = k->pkt->pkt.public_key;
if (pk->prefs)
- m_free (pk->prefs);
+ xfree (pk->prefs);
pk->prefs = copy_prefs (prefs);
pk->mdc_feature = mdc_feature;
}
@@ -2464,10 +2464,10 @@ finish_lookup (GETKEY_CTX ctx)
if (latest_key != keyblock && opt.verbose)
{
char *tempkeystr=
- m_strdup(keystr_from_pk(latest_key->pkt->pkt.public_key));
+ xstrdup(keystr_from_pk(latest_key->pkt->pkt.public_key));
log_info(_("using subkey %s instead of primary key %s\n"),
tempkeystr, keystr_from_pk(keyblock->pkt->pkt.public_key));
- m_free(tempkeystr);
+ xfree(tempkeystr);
}
cache_user_id( keyblock );
@@ -2610,7 +2610,7 @@ enum_secret_keys( void **context, PKT_secret_key *sk,
if( !c ) { /* make a new context */
- c = m_alloc_clear( sizeof *c );
+ c = xmalloc_clear( sizeof *c );
*context = c;
c->hd = keydb_new (1);
c->first = 1;
@@ -2621,7 +2621,7 @@ enum_secret_keys( void **context, PKT_secret_key *sk,
if( !sk ) { /* free the context */
keydb_release (c->hd);
release_kbnode (c->keyblock);
- m_free( c );
+ xfree( c );
*context = NULL;
return 0;
}
@@ -2668,7 +2668,7 @@ enum_secret_keys( void **context, PKT_secret_key *sk,
/****************
* Return a string with a printable representation of the user_id.
- * this string must be freed by m_free.
+ * this string must be freed by xfree.
*/
char*
get_user_id_string( u32 *keyid )
@@ -2686,14 +2686,14 @@ get_user_id_string( u32 *keyid )
{
if( a->keyid[0] == keyid[0] && a->keyid[1] == keyid[1] )
{
- p = m_alloc( keystrlen() + 1 + r->len + 1 );
+ p = xmalloc( keystrlen() + 1 + r->len + 1 );
sprintf(p, "%s %.*s", keystr(keyid), r->len, r->name );
return p;
}
}
}
} while( ++pass < 2 && !get_pubkey( NULL, keyid ) );
- p = m_alloc( keystrlen() + 5 );
+ p = xmalloc( keystrlen() + 5 );
sprintf(p, "%s [?]", keystr(keyid));
return p;
}
@@ -2704,7 +2704,7 @@ get_user_id_string_native ( u32 *keyid )
{
char *p = get_user_id_string( keyid );
char *p2 = utf8_to_native( p, strlen(p), 0 );
- m_free(p);
+ xfree(p);
return p2;
}
@@ -2721,7 +2721,7 @@ get_long_user_id_string( u32 *keyid )
keyid_list_t a;
for (a=r->keyids; a; a= a->next ) {
if( a->keyid[0] == keyid[0] && a->keyid[1] == keyid[1] ) {
- p = m_alloc( r->len + 20 );
+ p = xmalloc( r->len + 20 );
sprintf(p, "%08lX%08lX %.*s",
(ulong)keyid[0], (ulong)keyid[1],
r->len, r->name );
@@ -2730,7 +2730,7 @@ get_long_user_id_string( u32 *keyid )
}
}
} while( ++pass < 2 && !get_pubkey( NULL, keyid ) );
- p = m_alloc( 25 );
+ p = xmalloc( 25 );
sprintf(p, "%08lX%08lX [?]", (ulong)keyid[0], (ulong)keyid[1] );
return p;
}
@@ -2748,7 +2748,7 @@ get_user_id( u32 *keyid, size_t *rn )
keyid_list_t a;
for (a=r->keyids; a; a= a->next ) {
if( a->keyid[0] == keyid[0] && a->keyid[1] == keyid[1] ) {
- p = m_alloc( r->len );
+ p = xmalloc( r->len );
memcpy(p, r->name, r->len );
*rn = r->len;
return p;
@@ -2756,7 +2756,7 @@ get_user_id( u32 *keyid, size_t *rn )
}
}
} while( ++pass < 2 && !get_pubkey( NULL, keyid ) );
- p = m_strdup( _("[User ID not found]") );
+ p = xstrdup( _("[User ID not found]") );
*rn = strlen(p);
return p;
}
@@ -2767,7 +2767,7 @@ get_user_id_native( u32 *keyid )
size_t rn;
char *p = get_user_id( keyid, &rn );
char *p2 = utf8_to_native( p, rn, 0 );
- m_free(p);
+ xfree(p);
return p2;
}
diff --git a/g10/import.c b/g10/import.c
index 8c96e5a6a..63e64b923 100644
--- a/g10/import.c
+++ b/g10/import.c
@@ -113,13 +113,13 @@ parse_import_options(char *str,unsigned int *options,int noisy)
void *
import_new_stats_handle (void)
{
- return m_alloc_clear ( sizeof (struct stats_s) );
+ return xmalloc_clear ( sizeof (struct stats_s) );
}
void
import_release_stats_handle (void *p)
{
- m_free (p);
+ xfree (p);
}
/****************
@@ -237,7 +237,7 @@ import( IOBUF inp, const char* fname,
getkey_disable_caches();
if( !opt.no_armor ) { /* armored reading is not disabled */
- armor_filter_context_t *afx = m_alloc_clear( sizeof *afx );
+ armor_filter_context_t *afx = xmalloc_clear( sizeof *afx );
afx->only_keyblocks = 1;
iobuf_push_filter2( inp, armor_filter, afx, 1 );
}
@@ -356,7 +356,7 @@ read_block( IOBUF a, PACKET **pending_pkt, KBNODE *ret_root )
}
else
in_cert = 0;
- pkt = m_alloc( sizeof *pkt );
+ pkt = xmalloc( sizeof *pkt );
init_packet(pkt);
while( (rc=parse_packet(a, pkt)) != -1 ) {
if( rc ) { /* ignore errors */
@@ -389,7 +389,7 @@ read_block( IOBUF a, PACKET **pending_pkt, KBNODE *ret_root )
}
else
{
- compress_filter_context_t *cfx = m_alloc_clear( sizeof *cfx );
+ compress_filter_context_t *cfx = xmalloc_clear( sizeof *cfx );
pkt->pkt.compressed->buf = NULL;
push_compress_filter2(a,cfx,pkt->pkt.compressed->algorithm,1);
}
@@ -417,7 +417,7 @@ read_block( IOBUF a, PACKET **pending_pkt, KBNODE *ret_root )
root = new_kbnode( pkt );
else
add_kbnode( root, new_kbnode( pkt ) );
- pkt = m_alloc( sizeof *pkt );
+ pkt = xmalloc( sizeof *pkt );
}
init_packet(pkt);
break;
@@ -432,7 +432,7 @@ read_block( IOBUF a, PACKET **pending_pkt, KBNODE *ret_root )
else
*ret_root = root;
free_packet( pkt );
- m_free( pkt );
+ xfree( pkt );
return rc;
}
@@ -534,7 +534,7 @@ print_import_check (PKT_public_key * pk, PKT_user_id * id)
u32 keyid[2];
size_t i, pos = 0, n;
- buf = m_alloc (17+41+id->len+32);
+ buf = xmalloc (17+41+id->len+32);
keyid_from_pk (pk, keyid);
sprintf (buf, "%08X%08X ", keyid[0], keyid[1]);
pos = 17;
@@ -545,7 +545,7 @@ print_import_check (PKT_public_key * pk, PKT_user_id * id)
pos += 1;
strcat (buf, id->name);
write_status_text (STATUS_IMPORT_CHECK, buf);
- m_free (buf);
+ xfree (buf);
}
static void
@@ -621,7 +621,7 @@ check_prefs(KBNODE keyblock)
}
}
- m_free(user);
+ xfree(user);
}
}
@@ -762,7 +762,7 @@ import_one( const char *fname, KBNODE keyblock,
node->flag |= 1;
log_info( _("key %s: accepted non self-signed user ID \"%s\"\n"),
keystr_from_pk(pk),user);
- m_free(user);
+ xfree(user);
}
if( !delete_inv_parts( fname, keyblock, keyid, options ) ) {
@@ -774,7 +774,7 @@ import_one( const char *fname, KBNODE keyblock,
}
/* do we have this key already in one of our pubrings ? */
- pk_orig = m_alloc_clear( sizeof *pk_orig );
+ pk_orig = xmalloc_clear( sizeof *pk_orig );
rc = get_pubkey_fast ( pk_orig, keyid );
if( rc && rc != G10ERR_NO_PUBKEY && rc != G10ERR_UNU_PUBKEY )
{
@@ -825,13 +825,13 @@ import_one( const char *fname, KBNODE keyblock,
char *p=get_user_id_native (keyid);
log_info( _("key %s: public key \"%s\" imported\n"),
keystr(keyid),p);
- m_free(p);
+ xfree(p);
}
if( is_status_enabled() )
{
char *us = get_long_user_id_string( keyid );
write_status_text( STATUS_IMPORTED, us );
- m_free(us);
+ xfree(us);
print_import_ok (pk,NULL, 1);
}
stats->imported++;
@@ -941,7 +941,7 @@ import_one( const char *fname, KBNODE keyblock,
else if(n_uids_cleaned)
log_info(_("key %s: \"%s\" %d user IDs cleaned\n"),
keystr(keyid),p,n_uids_cleaned);
- m_free(p);
+ xfree(p);
}
stats->n_uids +=n_uids;
@@ -963,7 +963,7 @@ import_one( const char *fname, KBNODE keyblock,
{
char *p=get_user_id_native(keyid);
log_info( _("key %s: \"%s\" not changed\n"),keystr(keyid),p);
- m_free(p);
+ xfree(p);
}
stats->unchanged++;
@@ -1014,8 +1014,8 @@ sec_to_pub_keyblock(KBNODE sec_keyblock)
write the keyblock out. */
PKT_secret_key *sk=secnode->pkt->pkt.secret_key;
- PACKET *pkt=m_alloc_clear(sizeof(PACKET));
- PKT_public_key *pk=m_alloc_clear(sizeof(PKT_public_key));
+ PACKET *pkt=xmalloc_clear(sizeof(PACKET));
+ PKT_public_key *pk=xmalloc_clear(sizeof(PKT_public_key));
int n;
if(secnode->pkt->pkttype==PKT_SECRET_KEY)
@@ -1211,7 +1211,7 @@ import_revoke_cert( const char *fname, KBNODE node, struct stats_s *stats )
keyid[0] = node->pkt->pkt.signature->keyid[0];
keyid[1] = node->pkt->pkt.signature->keyid[1];
- pk = m_alloc_clear( sizeof *pk );
+ pk = xmalloc_clear( sizeof *pk );
rc = get_pubkey( pk, keyid );
if( rc == G10ERR_NO_PUBKEY )
{
@@ -1292,7 +1292,7 @@ import_revoke_cert( const char *fname, KBNODE node, struct stats_s *stats )
char *p=get_user_id_native (keyid);
log_info( _("key %s: \"%s\" revocation certificate imported\n"),
keystr(keyid),p);
- m_free(p);
+ xfree(p);
}
stats->n_revoc++;
@@ -1376,7 +1376,7 @@ chk_self_sigs( const char *fname, KBNODE keyblock,
_("key %s: invalid self-signature "
"on user ID \"%s\"\n"),
keystr(keyid),p);
- m_free(p);
+ xfree(p);
}
}
else
@@ -1513,7 +1513,7 @@ delete_inv_parts( const char *fname, KBNODE keyblock,
node->pkt->pkt.user_id->len,0);
log_info( _("key %s: skipped user ID \"%s\"\n"),
keystr(keyid),p);
- m_free(p);
+ xfree(p);
}
delete_kbnode( node ); /* the user-id */
/* and all following packets up to the next user-id */
@@ -1763,7 +1763,7 @@ revocation_present(KBNODE keyblock)
MAX_FINGERPRINT_LEN);
if(rc==G10ERR_NO_PUBKEY || rc==G10ERR_UNU_PUBKEY)
{
- char *tempkeystr=m_strdup(keystr_from_pk(pk));
+ char *tempkeystr=xstrdup(keystr_from_pk(pk));
/* No, so try and get it */
if(opt.keyserver
@@ -1788,7 +1788,7 @@ revocation_present(KBNODE keyblock)
" revocation key %s not present.\n"),
tempkeystr,keystr(keyid));
- m_free(tempkeystr);
+ xfree(tempkeystr);
}
}
}
@@ -1845,7 +1845,7 @@ merge_blocks( const char *fname, KBNODE keyblock_orig, KBNODE keyblock,
char *p=get_user_id_native (keyid);
log_info(_("key %s: \"%s\" revocation"
" certificate added\n"), keystr(keyid),p);
- m_free(p);
+ xfree(p);
}
}
}
@@ -2170,8 +2170,8 @@ pub_to_sec_keyblock (KBNODE pub_keyblock)
/* Make a secret key. We only need to convert enough to
write the keyblock out. */
PKT_public_key *pk = pubnode->pkt->pkt.public_key;
- PACKET *pkt = m_alloc_clear (sizeof *pkt);
- PKT_secret_key *sk = m_alloc_clear (sizeof *sk);
+ PACKET *pkt = xmalloc_clear (sizeof *pkt);
+ PKT_secret_key *sk = xmalloc_clear (sizeof *sk);
int i, n;
if (pubnode->pkt->pkttype == PKT_PUBLIC_KEY)
diff --git a/g10/kbnode.c b/g10/kbnode.c
index f273c8005..9038f5b44 100644
--- a/g10/kbnode.c
+++ b/g10/kbnode.c
@@ -43,7 +43,7 @@ alloc_node(void)
if( n )
unused_nodes = n->next;
else
- n = m_alloc( sizeof *n );
+ n = xmalloc( sizeof *n );
n->next = NULL;
n->pkt = NULL;
n->flag = 0;
@@ -60,7 +60,7 @@ free_node( KBNODE n )
n->next = unused_nodes;
unused_nodes = n;
#else
- m_free( n );
+ xfree( n );
#endif
}
}
@@ -96,7 +96,7 @@ release_kbnode( KBNODE n )
n2 = n->next;
if( !is_cloned_kbnode(n) ) {
free_packet( n->pkt );
- m_free( n->pkt );
+ xfree( n->pkt );
}
free_node( n );
n = n2;
@@ -267,7 +267,7 @@ commit_kbnode( KBNODE *root )
nl->next = n->next;
if( !is_cloned_kbnode(n) ) {
free_packet( n->pkt );
- m_free( n->pkt );
+ xfree( n->pkt );
}
free_node( n );
changed = 1;
@@ -291,7 +291,7 @@ remove_kbnode( KBNODE *root, KBNODE node )
nl->next = n->next;
if( !is_cloned_kbnode(n) ) {
free_packet( n->pkt );
- m_free( n->pkt );
+ xfree( n->pkt );
}
free_node( n );
}
diff --git a/g10/keydb.c b/g10/keydb.c
index 5c7e2ed9d..b1a726858 100644
--- a/g10/keydb.c
+++ b/g10/keydb.c
@@ -235,7 +235,7 @@ keydb_add_resource (const char *url, int flags, int secret)
filename = make_filename (opt.homedir, resname, NULL);
}
else
- filename = m_strdup (resname);
+ filename = xstrdup (resname);
if (!force)
force = secret? !any_secret : !any_public;
@@ -323,7 +323,7 @@ keydb_add_resource (const char *url, int flags, int secret)
any_secret = 1;
else
any_public = 1;
- m_free (filename);
+ xfree (filename);
return rc;
}
@@ -336,7 +336,7 @@ keydb_new (int secret)
KEYDB_HANDLE hd;
int i, j;
- hd = m_alloc_clear (sizeof *hd);
+ hd = xmalloc_clear (sizeof *hd);
hd->found = -1;
assert (used_resources <= MAX_KEYDB_RESOURCES);
@@ -354,7 +354,7 @@ keydb_new (int secret)
hd->active[j].secret = all_resources[i].secret;
hd->active[j].u.kr = keyring_new (all_resources[i].token, secret);
if (!hd->active[j].u.kr) {
- m_free (hd);
+ xfree (hd);
return NULL; /* fixme: release all previously allocated handles*/
}
j++;
@@ -388,7 +388,7 @@ keydb_release (KEYDB_HANDLE hd)
}
}
- m_free (hd);
+ xfree (hd);
}
diff --git a/g10/keyedit.c b/g10/keyedit.c
index c62e2e378..2b8bede46 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -267,7 +267,7 @@ print_and_check_one_sig( KBNODE keyblock, KBNODE node,
char *p = get_user_id( sig->keyid, &n );
tty_print_utf8_string2(p, n, opt.screen_columns-keystrlen()-26-
((opt.list_options&LIST_SHOW_SIG_EXPIRE)?11:0));
- m_free(p);
+ xfree(p);
}
tty_printf("\n");
@@ -425,7 +425,7 @@ trustsig_prompt(byte *trust_value,byte *trust_depth,char **regexp)
*trust_value=60;
else if(p[0]=='2' && !p[1])
*trust_value=120;
- m_free(p);
+ xfree(p);
}
tty_printf("\n");
@@ -442,7 +442,7 @@ trustsig_prompt(byte *trust_value,byte *trust_depth,char **regexp)
trim_spaces(p);
cpr_kill_prompt();
*trust_depth=atoi(p);
- m_free(p);
+ xfree(p);
}
tty_printf("\n");
@@ -461,7 +461,7 @@ trustsig_prompt(byte *trust_value,byte *trust_depth,char **regexp)
char *q=p;
int regexplen=100,ind;
- *regexp=m_alloc(regexplen);
+ *regexp=xmalloc(regexplen);
/* Now mangle the domain the user entered into a regexp. To do
this, \-escape everything that isn't alphanumeric, and attach
@@ -481,7 +481,7 @@ trustsig_prompt(byte *trust_value,byte *trust_depth,char **regexp)
if((regexplen-ind)<3)
{
regexplen+=100;
- *regexp=m_realloc(*regexp,regexplen);
+ *regexp=xrealloc(*regexp,regexplen);
}
q++;
@@ -491,7 +491,7 @@ trustsig_prompt(byte *trust_value,byte *trust_depth,char **regexp)
strcat(*regexp,">$");
}
- m_free(p);
+ xfree(p);
tty_printf("\n");
}
@@ -684,7 +684,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified,
}
}
- m_free(user);
+ xfree(user);
}
}
else if( uidnode && node->pkt->pkttype == PKT_SIGNATURE
@@ -714,7 +714,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified,
{
force_v4=1;
node->flag|=NODFLG_DELSIG;
- m_free(user);
+ xfree(user);
continue;
}
}
@@ -738,7 +738,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified,
in place. */
node->flag|=NODFLG_DELSIG;
- m_free(user);
+ xfree(user);
continue;
}
}
@@ -763,7 +763,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified,
in place. */
node->flag|=NODFLG_DELSIG;
- m_free(user);
+ xfree(user);
continue;
}
}
@@ -785,7 +785,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified,
{
/* Don't delete the old sig here since this is
an --expert thing. */
- m_free(user);
+ xfree(user);
continue;
}
@@ -794,7 +794,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified,
write_status_text (STATUS_ALREADY_SIGNED, buf);
uidnode->flag &= ~NODFLG_MARK_A; /* remove mark */
- m_free(user);
+ xfree(user);
}
}
}
@@ -857,7 +857,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified,
}
cpr_kill_prompt();
- m_free(answer);
+ xfree(answer);
}
}
}
@@ -940,7 +940,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified,
else
tty_printf(_("Invalid selection.\n"));
- m_free(answer);
+ xfree(answer);
}
}
@@ -951,7 +951,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified,
p=get_user_id_native(sk_keyid);
tty_printf(_("Are you sure that you want to sign this key with your\n"
"key \"%s\" (%s)\n"),p,keystr_from_sk(sk));
- m_free(p);
+ xfree(p);
if(selfsig)
{
@@ -1066,7 +1066,7 @@ sign_uids( KBNODE keyblock, STRLIST locusr, int *ret_modified,
*ret_modified = 1; /* we changed the keyblock */
update_trust = 1;
- pkt = m_alloc_clear( sizeof *pkt );
+ pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_SIGNATURE;
pkt->pkt.signature = sig;
insert_kbnode( node, new_kbnode(pkt), PKT_SIGNATURE );
@@ -1174,7 +1174,7 @@ change_passphrase( KBNODE keyblock )
tty_printf(_("Can't edit this key: %s\n"), g10_errstr(rc));
else {
DEK *dek = NULL;
- STRING2KEY *s2k = m_alloc_secure( sizeof *s2k );
+ STRING2KEY *s2k = xmalloc_secure( sizeof *s2k );
const char *errtext = NULL;
tty_printf(_("Enter the new passphrase for this secret key.\n\n") );
@@ -1227,12 +1227,12 @@ change_passphrase( KBNODE keyblock )
break;
}
}
- m_free(s2k);
- m_free(dek);
+ xfree(s2k);
+ xfree(dek);
}
leave:
- m_free( passphrase );
+ xfree( passphrase );
set_next_passphrase( NULL );
return changed && !rc;
}
@@ -1594,14 +1594,14 @@ keyedit_menu( const char *username, STRLIST locusr,
redisplay = 0;
}
do {
- m_free(answer);
+ xfree(answer);
if( have_commands ) {
if( commands ) {
- answer = m_strdup( commands->d );
+ answer = xstrdup( commands->d );
commands = commands->next;
}
else if( opt.batch ) {
- answer = m_strdup("quit");
+ answer = xstrdup("quit");
}
else
have_commands = 0;
@@ -2225,7 +2225,7 @@ keyedit_menu( const char *username, STRLIST locusr,
release_kbnode( keyblock );
release_kbnode( sec_keyblock );
keydb_release (kdbhd);
- m_free(answer);
+ xfree(answer);
}
@@ -2589,7 +2589,7 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
const char *algo=pubkey_algo_to_string(pk->revoked.algo);
tty_printf(_("This key was revoked on %s by %s key %s\n"),
revokestr_from_pk(pk),algo?algo:"?",user);
- m_free(user);
+ xfree(user);
}
if(with_revoker)
@@ -2618,7 +2618,7 @@ show_key_with_all_names( KBNODE keyblock, int only_marked, int with_revoker,
}
tty_printf ("\n");
- m_free(user);
+ xfree(user);
}
}
@@ -2993,7 +2993,7 @@ menu_adduid( KBNODE pub_keyblock, KBNODE sec_keyblock, int photo)
}
/* insert/append to secret keyblock */
- pkt = m_alloc_clear( sizeof *pkt );
+ pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_USER_ID;
pkt->pkt.user_id = scopy_user_id(uid);
node = new_kbnode(pkt);
@@ -3001,7 +3001,7 @@ menu_adduid( KBNODE pub_keyblock, KBNODE sec_keyblock, int photo)
insert_kbnode( sec_where, node, 0 );
else
add_kbnode( sec_keyblock, node );
- pkt = m_alloc_clear( sizeof *pkt );
+ pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_SIGNATURE;
pkt->pkt.signature = copy_signature(NULL, sig);
if( sec_where )
@@ -3009,7 +3009,7 @@ menu_adduid( KBNODE pub_keyblock, KBNODE sec_keyblock, int photo)
else
add_kbnode( sec_keyblock, new_kbnode(pkt) );
/* insert/append to public keyblock */
- pkt = m_alloc_clear( sizeof *pkt );
+ pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_USER_ID;
pkt->pkt.user_id = uid;
node = new_kbnode(pkt);
@@ -3017,7 +3017,7 @@ menu_adduid( KBNODE pub_keyblock, KBNODE sec_keyblock, int photo)
insert_kbnode( pub_where, node, 0 );
else
add_kbnode( pub_keyblock, node );
- pkt = m_alloc_clear( sizeof *pkt );
+ pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_SIGNATURE;
pkt->pkt.signature = copy_signature(NULL, sig);
if( pub_where )
@@ -3182,7 +3182,7 @@ menu_clean_sigs_from_uids(KBNODE keyblock)
else
tty_printf(_("User ID \"%s\": already clean.\n"),user);
- m_free(user);
+ xfree(user);
}
}
@@ -3220,7 +3220,7 @@ menu_clean_uids_from_key(KBNODE keyblock)
uidnode=NULL;
- m_free(user);
+ xfree(user);
}
}
}
@@ -3339,7 +3339,7 @@ menu_addrevoker( KBNODE pub_keyblock, KBNODE sec_keyblock, int sensitive )
if(revoker_pk)
free_public_key(revoker_pk);
- revoker_pk=m_alloc_clear(sizeof(*revoker_pk));
+ revoker_pk=xmalloc_clear(sizeof(*revoker_pk));
tty_printf("\n");
@@ -3347,7 +3347,7 @@ menu_addrevoker( KBNODE pub_keyblock, KBNODE sec_keyblock, int sensitive )
_("Enter the user ID of the designated revoker: "));
if(answer[0]=='\0' || answer[0]=='\004')
{
- m_free(answer);
+ xfree(answer);
goto fail;
}
@@ -3358,11 +3358,11 @@ menu_addrevoker( KBNODE pub_keyblock, KBNODE sec_keyblock, int sensitive )
if(rc)
{
log_error (_("key \"%s\" not found: %s\n"),answer,g10_errstr(rc));
- m_free(answer);
+ xfree(answer);
continue;
}
- m_free(answer);
+ xfree(answer);
fingerprint_from_pk(revoker_pk,revkey.fpr,&fprlen);
if(fprlen!=20)
@@ -3452,13 +3452,13 @@ menu_addrevoker( KBNODE pub_keyblock, KBNODE sec_keyblock, int sensitive )
sk=NULL;
/* insert into secret keyblock */
- pkt = m_alloc_clear( sizeof *pkt );
+ pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_SIGNATURE;
pkt->pkt.signature = copy_signature(NULL, sig);
insert_kbnode( sec_keyblock, new_kbnode(pkt), PKT_SIGNATURE );
/* insert into public keyblock */
- pkt = m_alloc_clear( sizeof *pkt );
+ pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_SIGNATURE;
pkt->pkt.signature = sig;
insert_kbnode( pub_keyblock, new_kbnode(pkt), PKT_SIGNATURE );
@@ -3580,18 +3580,18 @@ menu_expire( KBNODE pub_keyblock, KBNODE sec_keyblock )
return 0;
}
/* replace the packet */
- newpkt = m_alloc_clear( sizeof *newpkt );
+ newpkt = xmalloc_clear( sizeof *newpkt );
newpkt->pkttype = PKT_SIGNATURE;
newpkt->pkt.signature = newsig;
free_packet( node->pkt );
- m_free( node->pkt );
+ xfree( node->pkt );
node->pkt = newpkt;
if( sn ) {
- newpkt = m_alloc_clear( sizeof *newpkt );
+ newpkt = xmalloc_clear( sizeof *newpkt );
newpkt->pkttype = PKT_SIGNATURE;
newpkt->pkt.signature = copy_signature( NULL, newsig );
free_packet( sn->pkt );
- m_free( sn->pkt );
+ xfree( sn->pkt );
sn->pkt = newpkt;
}
sub_pk = NULL;
@@ -3686,7 +3686,7 @@ menu_set_primary_uid ( KBNODE pub_keyblock, KBNODE sec_keyblock )
log_info(_("skipping v3 self-signature on user ID \"%s\"\n"),
user);
- m_free(user);
+ xfree(user);
}
else {
/* This is a selfsignature which is to be replaced.
@@ -3730,11 +3730,11 @@ menu_set_primary_uid ( KBNODE pub_keyblock, KBNODE sec_keyblock )
return 0;
}
/* replace the packet */
- newpkt = m_alloc_clear( sizeof *newpkt );
+ newpkt = xmalloc_clear( sizeof *newpkt );
newpkt->pkttype = PKT_SIGNATURE;
newpkt->pkt.signature = newsig;
free_packet( node->pkt );
- m_free( node->pkt );
+ xfree( node->pkt );
node->pkt = newpkt;
modified = 1;
}
@@ -3796,7 +3796,7 @@ menu_set_preferences (KBNODE pub_keyblock, KBNODE sec_keyblock )
log_info(_("skipping v3 self-signature on user ID \"%s\"\n"),
user);
- m_free(user);
+ xfree(user);
}
else {
/* This is a selfsignature which is to be replaced
@@ -3818,11 +3818,11 @@ menu_set_preferences (KBNODE pub_keyblock, KBNODE sec_keyblock )
return 0;
}
/* replace the packet */
- newpkt = m_alloc_clear( sizeof *newpkt );
+ newpkt = xmalloc_clear( sizeof *newpkt );
newpkt->pkttype = PKT_SIGNATURE;
newpkt->pkt.signature = newsig;
free_packet( node->pkt );
- m_free( node->pkt );
+ xfree( node->pkt );
node->pkt = newpkt;
modified = 1;
}
@@ -3851,14 +3851,14 @@ menu_set_keyserver_url (const char *url,
no_primary_warning(pub_keyblock);
if(url)
- answer=m_strdup(url);
+ answer=xstrdup(url);
else
{
answer=cpr_get_utf8("keyedit.add_keyserver",
_("Enter your preferred keyserver URL: "));
if(answer[0]=='\0' || answer[0]=='\004')
{
- m_free(answer);
+ xfree(answer);
return 0;
}
}
@@ -3870,13 +3870,13 @@ menu_set_keyserver_url (const char *url,
struct keyserver_spec *keyserver=NULL;
/* Sanity check the format */
keyserver=parse_keyserver_uri(answer,1,NULL,0);
- m_free(answer);
+ xfree(answer);
if(!keyserver)
{
log_info(_("could not parse keyserver URL\n"));
return 0;
}
- uri=m_strdup(keyserver->uri);
+ uri=xstrdup(keyserver->uri);
free_keyserver_spec(keyserver);
}
@@ -3955,25 +3955,25 @@ menu_set_keyserver_url (const char *url,
log_error ("update_keysig_packet failed: %s\n",
g10_errstr(rc));
free_secret_key( sk );
- m_free(uri);
+ xfree(uri);
return 0;
}
/* replace the packet */
- newpkt = m_alloc_clear( sizeof *newpkt );
+ newpkt = xmalloc_clear( sizeof *newpkt );
newpkt->pkttype = PKT_SIGNATURE;
newpkt->pkt.signature = newsig;
free_packet( node->pkt );
- m_free( node->pkt );
+ xfree( node->pkt );
node->pkt = newpkt;
modified = 1;
}
- m_free(user);
+ xfree(user);
}
}
}
- m_free(uri);
+ xfree(uri);
free_secret_key( sk );
return modified;
}
@@ -4201,7 +4201,7 @@ ask_revoke_sig( KBNODE keyblock, KBNODE node )
p=utf8_to_native(unode->pkt->pkt.user_id->name,
unode->pkt->pkt.user_id->len,0);
tty_printf(_("user ID: \"%s\"\n"),p);
- m_free(p);
+ xfree(p);
tty_printf(_("signed by your key %s on %s%s%s\n"),
keystr(sig->keyid),datestr_from_sig(sig),
@@ -4347,7 +4347,7 @@ menu_revsig( KBNODE keyblock )
attrib.non_exportable=!node->pkt->pkt.signature->flags.exportable;
node->flag &= ~NODFLG_MARK_A;
- sk = m_alloc_secure_clear( sizeof *sk );
+ sk = xmalloc_secure_clear( sizeof *sk );
if( get_seckey( sk, node->pkt->pkt.signature->keyid ) ) {
log_info(_("no secret key\n"));
continue;
@@ -4371,7 +4371,7 @@ menu_revsig( KBNODE keyblock )
if(primary_pk->keyid[0]==sig->keyid[0] &&
primary_pk->keyid[1]==sig->keyid[1])
unode->pkt->pkt.user_id->is_revoked=1;
- pkt = m_alloc_clear( sizeof *pkt );
+ pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_SIGNATURE;
pkt->pkt.signature = sig;
insert_kbnode( unode, new_kbnode(pkt), 0 );
@@ -4420,7 +4420,7 @@ menu_revuid( KBNODE pub_keyblock, KBNODE sec_keyblock )
{
char *user=utf8_to_native(uid->name,uid->len,0);
log_info(_("user ID \"%s\" is already revoked\n"),user);
- m_free(user);
+ xfree(user);
}
else
{
@@ -4457,7 +4457,7 @@ menu_revuid( KBNODE pub_keyblock, KBNODE sec_keyblock )
}
else
{
- pkt = m_alloc_clear( sizeof *pkt );
+ pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_SIGNATURE;
pkt->pkt.signature = sig;
insert_kbnode( node, new_kbnode(pkt), 0 );
@@ -4522,7 +4522,7 @@ menu_revkey( KBNODE pub_keyblock, KBNODE sec_keyblock )
changed = 1; /* we changed the keyblock */
- pkt = m_alloc_clear( sizeof *pkt );
+ pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_SIGNATURE;
pkt->pkt.signature = sig;
insert_kbnode( pub_keyblock, new_kbnode(pkt), 0 );
@@ -4583,7 +4583,7 @@ menu_revsubkey( KBNODE pub_keyblock, KBNODE sec_keyblock )
}
changed = 1; /* we changed the keyblock */
- pkt = m_alloc_clear( sizeof *pkt );
+ pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_SIGNATURE;
pkt->pkt.signature = sig;
insert_kbnode( node, new_kbnode(pkt), 0 );
diff --git a/g10/keygen.c b/g10/keygen.c
index c78a0dbbd..ca20ed8e8 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -174,11 +174,11 @@ print_status_key_not_created (const char *handle)
static void
write_uid( KBNODE root, const char *s )
{
- PACKET *pkt = m_alloc_clear(sizeof *pkt );
+ PACKET *pkt = xmalloc_clear(sizeof *pkt );
size_t n = strlen(s);
pkt->pkttype = PKT_USER_ID;
- pkt->pkt.user_id = m_alloc_clear( sizeof *pkt->pkt.user_id + n - 1 );
+ pkt->pkt.user_id = xmalloc_clear( sizeof *pkt->pkt.user_id + n - 1 );
pkt->pkt.user_id->len = n;
pkt->pkt.user_id->ref = 1;
strcpy(pkt->pkt.user_id->name, s);
@@ -362,7 +362,7 @@ keygen_set_std_prefs (const char *string,int personal)
{
char *tok,*prefstring;
- prefstring=m_strdup(string); /* need a writable string! */
+ prefstring=xstrdup(string); /* need a writable string! */
while((tok=strsep(&prefstring," ,")))
{
@@ -402,7 +402,7 @@ keygen_set_std_prefs (const char *string,int personal)
}
}
- m_free(prefstring);
+ xfree(prefstring);
}
if(!rc)
@@ -411,7 +411,7 @@ keygen_set_std_prefs (const char *string,int personal)
{
if(personal==PREFTYPE_SYM)
{
- m_free(opt.personal_cipher_prefs);
+ xfree(opt.personal_cipher_prefs);
if(nsym==0)
opt.personal_cipher_prefs=NULL;
@@ -420,7 +420,7 @@ keygen_set_std_prefs (const char *string,int personal)
int i;
opt.personal_cipher_prefs=
- m_alloc(sizeof(prefitem_t *)*(nsym+1));
+ xmalloc(sizeof(prefitem_t *)*(nsym+1));
for (i=0; i<nsym; i++)
{
@@ -434,7 +434,7 @@ keygen_set_std_prefs (const char *string,int personal)
}
else if(personal==PREFTYPE_HASH)
{
- m_free(opt.personal_digest_prefs);
+ xfree(opt.personal_digest_prefs);
if(nhash==0)
opt.personal_digest_prefs=NULL;
@@ -443,7 +443,7 @@ keygen_set_std_prefs (const char *string,int personal)
int i;
opt.personal_digest_prefs=
- m_alloc(sizeof(prefitem_t *)*(nhash+1));
+ xmalloc(sizeof(prefitem_t *)*(nhash+1));
for (i=0; i<nhash; i++)
{
@@ -457,7 +457,7 @@ keygen_set_std_prefs (const char *string,int personal)
}
else if(personal==PREFTYPE_ZIP)
{
- m_free(opt.personal_compress_prefs);
+ xfree(opt.personal_compress_prefs);
if(nzip==0)
opt.personal_compress_prefs=NULL;
@@ -466,7 +466,7 @@ keygen_set_std_prefs (const char *string,int personal)
int i;
opt.personal_compress_prefs=
- m_alloc(sizeof(prefitem_t *)*(nzip+1));
+ xmalloc(sizeof(prefitem_t *)*(nzip+1));
for (i=0; i<nzip; i++)
{
@@ -498,14 +498,14 @@ keygen_set_std_prefs (const char *string,int personal)
PKT_user_id *keygen_get_std_prefs(void)
{
int i,j=0;
- PKT_user_id *uid=m_alloc_clear(sizeof(PKT_user_id));
+ PKT_user_id *uid=xmalloc_clear(sizeof(PKT_user_id));
if(!prefs_initialized)
keygen_set_std_prefs(NULL,0);
uid->ref=1;
- uid->prefs=m_alloc((sizeof(prefitem_t *)*
+ uid->prefs=xmalloc((sizeof(prefitem_t *)*
(nsym_prefs+nhash_prefs+nzip_prefs+1)));
for(i=0;i<nsym_prefs;i++,j++)
@@ -551,10 +551,10 @@ add_feature_mdc (PKT_signature *sig,int enabled)
if (!s || !n) { /* create a new one */
n = 1;
- buf = m_alloc_clear (n);
+ buf = xmalloc_clear (n);
}
else {
- buf = m_alloc (n);
+ buf = xmalloc (n);
memcpy (buf, s, n);
}
@@ -573,7 +573,7 @@ add_feature_mdc (PKT_signature *sig,int enabled)
else
build_sig_subpkt (sig, SIGSUBPKT_FEATURES, buf, n);
- m_free (buf);
+ xfree (buf);
}
static void
@@ -595,10 +595,10 @@ add_keyserver_modify (PKT_signature *sig,int enabled)
if (!s || !n) { /* create a new one */
n = 1;
- buf = m_alloc_clear (n);
+ buf = xmalloc_clear (n);
}
else {
- buf = m_alloc (n);
+ buf = xmalloc (n);
memcpy (buf, s, n);
}
@@ -617,7 +617,7 @@ add_keyserver_modify (PKT_signature *sig,int enabled)
else
build_sig_subpkt (sig, SIGSUBPKT_KS_FLAGS, buf, n);
- m_free (buf);
+ xfree (buf);
}
int
@@ -839,7 +839,7 @@ write_direct_sig( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
return rc;
}
- pkt = m_alloc_clear( sizeof *pkt );
+ pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_SIGNATURE;
pkt->pkt.signature = sig;
add_kbnode( root, new_kbnode( pkt ) );
@@ -883,12 +883,12 @@ write_selfsigs( KBNODE sec_root, KBNODE pub_root, PKT_secret_key *sk,
return rc;
}
- pkt = m_alloc_clear( sizeof *pkt );
+ pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_SIGNATURE;
pkt->pkt.signature = sig;
add_kbnode( sec_root, new_kbnode( pkt ) );
- pkt = m_alloc_clear( sizeof *pkt );
+ pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_SIGNATURE;
pkt->pkt.signature = copy_signature(NULL,sig);
add_kbnode( pub_root, new_kbnode( pkt ) );
@@ -947,7 +947,7 @@ write_keybinding( KBNODE root, KBNODE pub_root,
return rc;
}
- pkt = m_alloc_clear( sizeof *pkt );
+ pkt = xmalloc_clear( sizeof *pkt );
pkt->pkttype = PKT_SIGNATURE;
pkt->pkt.signature = sig;
add_kbnode( root, new_kbnode( pkt ) );
@@ -984,8 +984,8 @@ gen_elg(int algo, unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
return rc;
}
- sk = m_alloc_clear( sizeof *sk );
- pk = m_alloc_clear( sizeof *pk );
+ sk = xmalloc_clear( sizeof *sk );
+ pk = xmalloc_clear( sizeof *pk );
sk->timestamp = pk->timestamp = make_timestamp();
sk->version = pk->version = 4;
if( expireval ) {
@@ -1018,14 +1018,14 @@ gen_elg(int algo, unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
}
}
- pkt = m_alloc_clear(sizeof *pkt);
+ pkt = xmalloc_clear(sizeof *pkt);
pkt->pkttype = is_subkey ? PKT_PUBLIC_SUBKEY : PKT_PUBLIC_KEY;
pkt->pkt.public_key = pk;
add_kbnode(pub_root, new_kbnode( pkt ));
/* don't know whether it makes sense to have the factors, so for now
* we store them in the secret keyring (but they are not secret) */
- pkt = m_alloc_clear(sizeof *pkt);
+ pkt = xmalloc_clear(sizeof *pkt);
pkt->pkttype = is_subkey ? PKT_SECRET_SUBKEY : PKT_SECRET_KEY;
pkt->pkt.secret_key = sk;
add_kbnode(sec_root, new_kbnode( pkt ));
@@ -1064,8 +1064,8 @@ gen_dsa(unsigned int nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
return rc;
}
- sk = m_alloc_clear( sizeof *sk );
- pk = m_alloc_clear( sizeof *pk );
+ sk = xmalloc_clear( sizeof *sk );
+ pk = xmalloc_clear( sizeof *pk );
sk->timestamp = pk->timestamp = make_timestamp();
sk->version = pk->version = 4;
if( expireval ) {
@@ -1100,7 +1100,7 @@ gen_dsa(unsigned int nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
}
}
- pkt = m_alloc_clear(sizeof *pkt);
+ pkt = xmalloc_clear(sizeof *pkt);
pkt->pkttype = is_subkey ? PKT_PUBLIC_SUBKEY : PKT_PUBLIC_KEY;
pkt->pkt.public_key = pk;
add_kbnode(pub_root, new_kbnode( pkt ));
@@ -1111,7 +1111,7 @@ gen_dsa(unsigned int nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
* We store only f1 to f_n-1; fn can be calculated because p and q
* are known.
*/
- pkt = m_alloc_clear(sizeof *pkt);
+ pkt = xmalloc_clear(sizeof *pkt);
pkt->pkttype = is_subkey ? PKT_SECRET_SUBKEY : PKT_SECRET_KEY;
pkt->pkt.secret_key = sk;
add_kbnode(sec_root, new_kbnode( pkt ));
@@ -1152,8 +1152,8 @@ gen_rsa(int algo, unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
return rc;
}
- sk = m_alloc_clear( sizeof *sk );
- pk = m_alloc_clear( sizeof *pk );
+ sk = xmalloc_clear( sizeof *sk );
+ pk = xmalloc_clear( sizeof *pk );
sk->timestamp = pk->timestamp = make_timestamp();
sk->version = pk->version = 4;
if( expireval ) {
@@ -1190,12 +1190,12 @@ gen_rsa(int algo, unsigned nbits, KBNODE pub_root, KBNODE sec_root, DEK *dek,
}
}
- pkt = m_alloc_clear(sizeof *pkt);
+ pkt = xmalloc_clear(sizeof *pkt);
pkt->pkttype = is_subkey ? PKT_PUBLIC_SUBKEY : PKT_PUBLIC_KEY;
pkt->pkt.public_key = pk;
add_kbnode(pub_root, new_kbnode( pkt ));
- pkt = m_alloc_clear(sizeof *pkt);
+ pkt = xmalloc_clear(sizeof *pkt);
pkt->pkttype = is_subkey ? PKT_SECRET_SUBKEY : PKT_SECRET_KEY;
pkt->pkt.secret_key = sk;
add_kbnode(sec_root, new_kbnode( pkt ));
@@ -1286,7 +1286,7 @@ ask_key_flags(int algo)
tty_printf(_(" (%c) Finished\n"),togglers[6]);
tty_printf("\n");
- m_free(answer);
+ xfree(answer);
answer = cpr_get("keygen.flags",_("Your selection? "));
cpr_kill_prompt();
@@ -1320,7 +1320,7 @@ ask_key_flags(int algo)
}
}
- m_free(answer);
+ xfree(answer);
return current;
}
@@ -1355,7 +1355,7 @@ ask_algo (int addmode, unsigned int *r_usage)
answer = cpr_get("keygen.algo",_("Your selection? "));
cpr_kill_prompt();
algo = *answer? atoi(answer): 1;
- m_free(answer);
+ xfree(answer);
if( algo == 1 && !addmode ) {
algo = 0; /* create both keys */
break;
@@ -1437,7 +1437,7 @@ ask_keysize( int algo )
#define PROMPTSTRING _("What keysize do you want? (%u) ")
- prompt=m_alloc(strlen(PROMPTSTRING)+20);
+ prompt=xmalloc(strlen(PROMPTSTRING)+20);
sprintf(prompt,PROMPTSTRING,def);
#undef PROMPTSTRING
@@ -1445,8 +1445,8 @@ ask_keysize( int algo )
answer = cpr_get("keygen.size",prompt);
cpr_kill_prompt();
nbits = *answer? atoi(answer): def;
- m_free(prompt);
- m_free(answer);
+ xfree(prompt);
+ xfree(answer);
if(nbits<min || nbits>max)
tty_printf(_("%s keysizes must be in the range %u-%u\n"),
@@ -1544,7 +1544,7 @@ ask_expire_interval(int object,const char *def_expire)
{
u32 curtime=make_timestamp();
- m_free(answer);
+ xfree(answer);
if(object==0)
answer = cpr_get("keygen.valid",_("Key is valid for? (0) "));
else
@@ -1554,15 +1554,15 @@ ask_expire_interval(int object,const char *def_expire)
#define PROMPTSTRING _("Signature is valid for? (%s) ")
/* This will actually end up larger than necessary because
of the 2 bytes for '%s' */
- prompt=m_alloc(strlen(PROMPTSTRING)+strlen(def_expire)+1);
+ prompt=xmalloc(strlen(PROMPTSTRING)+strlen(def_expire)+1);
sprintf(prompt,PROMPTSTRING,def_expire);
#undef PROMPTSTRING
answer = cpr_get("siggen.valid",prompt);
- m_free(prompt);
+ xfree(prompt);
if(*answer=='\0')
- answer=m_strdup(def_expire);
+ answer=xstrdup(def_expire);
}
cpr_kill_prompt();
trim_spaces(answer);
@@ -1598,7 +1598,7 @@ ask_expire_interval(int object,const char *def_expire)
break;
}
- m_free(answer);
+ xfree(answer);
return interval;
}
@@ -1650,7 +1650,7 @@ ask_user_id( int mode )
if( !aname ) {
for(;;) {
- m_free(aname);
+ xfree(aname);
aname = cpr_get("keygen.name",_("Real name: "));
trim_spaces(aname);
cpr_kill_prompt();
@@ -1670,7 +1670,7 @@ ask_user_id( int mode )
}
if( !amail ) {
for(;;) {
- m_free(amail);
+ xfree(amail);
amail = cpr_get("keygen.email",_("Email address: "));
trim_spaces(amail);
cpr_kill_prompt();
@@ -1689,7 +1689,7 @@ ask_user_id( int mode )
}
if( !acomment ) {
for(;;) {
- m_free(acomment);
+ xfree(acomment);
acomment = cpr_get("keygen.comment",_("Comment: "));
trim_spaces(acomment);
cpr_kill_prompt();
@@ -1703,8 +1703,8 @@ ask_user_id( int mode )
}
- m_free(uid);
- uid = p = m_alloc(strlen(aname)+strlen(amail)+strlen(acomment)+12+10);
+ xfree(uid);
+ uid = p = xmalloc(strlen(aname)+strlen(amail)+strlen(acomment)+12+10);
p = stpcpy(p, aname );
if( *acomment )
p = stpcpy(stpcpy(stpcpy(p," ("), acomment),")");
@@ -1751,7 +1751,7 @@ ask_user_id( int mode )
if( strlen(ansstr) != 10 )
BUG();
if( cpr_enabled() ) {
- answer = m_strdup(ansstr+6);
+ answer = xstrdup(ansstr+6);
answer[1] = 0;
}
else {
@@ -1763,15 +1763,15 @@ ask_user_id( int mode )
if( strlen(answer) > 1 )
;
else if( *answer == ansstr[0] || *answer == ansstr[1] ) {
- m_free(aname); aname = NULL;
+ xfree(aname); aname = NULL;
break;
}
else if( *answer == ansstr[2] || *answer == ansstr[3] ) {
- m_free(acomment); acomment = NULL;
+ xfree(acomment); acomment = NULL;
break;
}
else if( *answer == ansstr[4] || *answer == ansstr[5] ) {
- m_free(amail); amail = NULL;
+ xfree(amail); amail = NULL;
break;
}
else if( *answer == ansstr[6] || *answer == ansstr[7] ) {
@@ -1779,29 +1779,29 @@ ask_user_id( int mode )
tty_printf(_("Please correct the error first\n"));
}
else {
- m_free(aname); aname = NULL;
- m_free(acomment); acomment = NULL;
- m_free(amail); amail = NULL;
+ xfree(aname); aname = NULL;
+ xfree(acomment); acomment = NULL;
+ xfree(amail); amail = NULL;
break;
}
}
else if( *answer == ansstr[8] || *answer == ansstr[9] ) {
- m_free(aname); aname = NULL;
- m_free(acomment); acomment = NULL;
- m_free(amail); amail = NULL;
- m_free(uid); uid = NULL;
+ xfree(aname); aname = NULL;
+ xfree(acomment); acomment = NULL;
+ xfree(amail); amail = NULL;
+ xfree(uid); uid = NULL;
break;
}
- m_free(answer);
+ xfree(answer);
}
- m_free(answer);
+ xfree(answer);
if( !amail && !acomment && !amail )
break;
- m_free(uid); uid = NULL;
+ xfree(uid); uid = NULL;
}
if( uid ) {
char *p = native_to_utf8( uid );
- m_free( uid );
+ xfree( uid );
uid = p;
}
return uid;
@@ -1818,7 +1818,7 @@ do_ask_passphrase( STRING2KEY **ret_s2k )
tty_printf(_("You need a Passphrase to protect your secret key.\n\n") );
- s2k = m_alloc_secure( sizeof *s2k );
+ s2k = xmalloc_secure( sizeof *s2k );
for(;;) {
s2k->mode = opt.s2k_mode;
s2k->hash_algo = S2K_DIGEST_ALGO;
@@ -1829,8 +1829,8 @@ do_ask_passphrase( STRING2KEY **ret_s2k )
tty_printf(_("%s.\n"), _(errtext));
}
else if( !dek->keylen ) {
- m_free(dek); dek = NULL;
- m_free(s2k); s2k = NULL;
+ xfree(dek); dek = NULL;
+ xfree(s2k); s2k = NULL;
tty_printf(_(
"You don't want a passphrase - this is probably a *bad* idea!\n"
"I will do it anyway. You can change your passphrase at any time,\n"
@@ -1889,7 +1889,7 @@ generate_user_id()
if( !p )
return NULL;
n = strlen(p);
- uid = m_alloc_clear( sizeof *uid + n - 1 );
+ uid = xmalloc_clear( sizeof *uid + n - 1 );
uid->len = n;
strcpy(uid->name, p);
uid->ref = 1;
@@ -1905,11 +1905,11 @@ release_parameter_list( struct para_data_s *r )
for( ; r ; r = r2 ) {
r2 = r->next;
if( r->key == pPASSPHRASE_DEK )
- m_free( r->u.dek );
+ xfree( r->u.dek );
else if( r->key == pPASSPHRASE_S2K )
- m_free( r->u.s2k );
+ xfree( r->u.s2k );
- m_free(r);
+ xfree(r);
}
}
@@ -2115,7 +2115,7 @@ proc_parameter_file( struct para_data_s *para, const char *fname,
s3 = get_parameter_value( para, pNAMEEMAIL );
if( s1 || s2 || s3 ) {
n = (s1?strlen(s1):0) + (s2?strlen(s2):0) + (s3?strlen(s3):0);
- r = m_alloc_clear( sizeof *r + n + 20 );
+ r = xmalloc_clear( sizeof *r + n + 20 );
r->key = pUSERID;
p = r->u.value;
if( s1 )
@@ -2145,7 +2145,7 @@ proc_parameter_file( struct para_data_s *para, const char *fname,
STRING2KEY *s2k;
DEK *dek;
- s2k = m_alloc_secure( sizeof *s2k );
+ s2k = xmalloc_secure( sizeof *s2k );
s2k->mode = opt.s2k_mode;
s2k->hash_algo = S2K_DIGEST_ALGO;
set_next_passphrase( r->u.value );
@@ -2155,12 +2155,12 @@ proc_parameter_file( struct para_data_s *para, const char *fname,
assert( dek );
memset( r->u.value, 0, strlen(r->u.value) );
- r = m_alloc_clear( sizeof *r );
+ r = xmalloc_clear( sizeof *r );
r->key = pPASSPHRASE_S2K;
r->u.s2k = s2k;
r->next = para;
para = r;
- r = m_alloc_clear( sizeof *r );
+ r = xmalloc_clear( sizeof *r );
r->key = pPASSPHRASE_DEK;
r->u.dek = dek;
r->next = para;
@@ -2182,7 +2182,7 @@ proc_parameter_file( struct para_data_s *para, const char *fname,
r->u.expire = seconds;
r->key = pKEYEXPIRE; /* change hat entry */
/* also set it for the subkey */
- r = m_alloc_clear( sizeof *r + 20 );
+ r = xmalloc_clear( sizeof *r + 20 );
r->key = pSUBKEYEXPIRE;
r->u.expire = seconds;
r->next = para;
@@ -2297,8 +2297,8 @@ read_parameter_file( const char *fname )
if( outctrl.pub.fname && !strcmp( outctrl.pub.fname, value ) )
; /* still the same file - ignore it */
else {
- m_free( outctrl.pub.newfname );
- outctrl.pub.newfname = m_strdup( value );
+ xfree( outctrl.pub.newfname );
+ outctrl.pub.newfname = xstrdup( value );
outctrl.use_files = 1;
}
}
@@ -2306,8 +2306,8 @@ read_parameter_file( const char *fname )
if( outctrl.sec.fname && !strcmp( outctrl.sec.fname, value ) )
; /* still the same file - ignore it */
else {
- m_free( outctrl.sec.newfname );
- outctrl.sec.newfname = m_strdup( value );
+ xfree( outctrl.sec.newfname );
+ outctrl.sec.newfname = xstrdup( value );
outctrl.use_files = 1;
}
}
@@ -2365,7 +2365,7 @@ read_parameter_file( const char *fname )
break;
}
}
- r = m_alloc_clear( sizeof *r + strlen( value ) );
+ r = xmalloc_clear( sizeof *r + strlen( value ) );
r->lnr = lnr;
r->key = keywords[i].key;
strcpy( r->u.value, value );
@@ -2393,10 +2393,10 @@ read_parameter_file( const char *fname )
if (outctrl.sec.fname)
iobuf_ioctl (NULL, 2, 0, (char*)outctrl.sec.fname);
- m_free( outctrl.pub.fname );
- m_free( outctrl.pub.newfname );
- m_free( outctrl.sec.fname );
- m_free( outctrl.sec.newfname );
+ xfree( outctrl.pub.fname );
+ xfree( outctrl.pub.newfname );
+ xfree( outctrl.sec.fname );
+ xfree( outctrl.sec.newfname );
}
release_parameter_list( para );
@@ -2498,30 +2498,30 @@ generate_keypair (const char *fname, const char *card_serialno,
if( !algo )
{ /* default: DSA with ElG subkey of the specified size */
both = 1;
- r = m_alloc_clear( sizeof *r + 20 );
+ r = xmalloc_clear( sizeof *r + 20 );
r->key = pKEYTYPE;
sprintf( r->u.value, "%d", PUBKEY_ALGO_DSA );
r->next = para;
para = r;
tty_printf(_("DSA keypair will have %u bits.\n"),1024);
- r = m_alloc_clear( sizeof *r + 20 );
+ r = xmalloc_clear( sizeof *r + 20 );
r->key = pKEYLENGTH;
strcpy( r->u.value, "1024" );
r->next = para;
para = r;
- r = m_alloc_clear( sizeof *r + 20 );
+ r = xmalloc_clear( sizeof *r + 20 );
r->key = pKEYUSAGE;
strcpy( r->u.value, "sign" );
r->next = para;
para = r;
algo = PUBKEY_ALGO_ELGAMAL_E;
- r = m_alloc_clear( sizeof *r + 20 );
+ r = xmalloc_clear( sizeof *r + 20 );
r->key = pSUBKEYTYPE;
sprintf( r->u.value, "%d", algo );
r->next = para;
para = r;
- r = m_alloc_clear( sizeof *r + 20 );
+ r = xmalloc_clear( sizeof *r + 20 );
r->key = pSUBKEYUSAGE;
strcpy( r->u.value, "encrypt" );
r->next = para;
@@ -2529,7 +2529,7 @@ generate_keypair (const char *fname, const char *card_serialno,
}
else
{
- r = m_alloc_clear( sizeof *r + 20 );
+ r = xmalloc_clear( sizeof *r + 20 );
r->key = pKEYTYPE;
sprintf( r->u.value, "%d", algo );
r->next = para;
@@ -2537,7 +2537,7 @@ generate_keypair (const char *fname, const char *card_serialno,
if (use)
{
- r = m_alloc_clear( sizeof *r + 25 );
+ r = xmalloc_clear( sizeof *r + 25 );
r->key = pKEYUSAGE;
sprintf( r->u.value, "%s%s%s",
(use & PUBKEY_USAGE_SIG)? "sign ":"",
@@ -2550,7 +2550,7 @@ generate_keypair (const char *fname, const char *card_serialno,
}
nbits = ask_keysize( algo );
- r = m_alloc_clear( sizeof *r + 20 );
+ r = xmalloc_clear( sizeof *r + 20 );
r->key = both? pSUBKEYLENGTH : pKEYLENGTH;
sprintf( r->u.value, "%u", nbits);
r->next = para;
@@ -2558,12 +2558,12 @@ generate_keypair (const char *fname, const char *card_serialno,
}
expire = ask_expire_interval(0,NULL);
- r = m_alloc_clear( sizeof *r + 20 );
+ r = xmalloc_clear( sizeof *r + 20 );
r->key = pKEYEXPIRE;
r->u.expire = expire;
r->next = para;
para = r;
- r = m_alloc_clear( sizeof *r + 20 );
+ r = xmalloc_clear( sizeof *r + 20 );
r->key = pSUBKEYEXPIRE;
r->u.expire = expire;
r->next = para;
@@ -2576,7 +2576,7 @@ generate_keypair (const char *fname, const char *card_serialno,
release_parameter_list( para );
return;
}
- r = m_alloc_clear( sizeof *r + strlen(uid) );
+ r = xmalloc_clear( sizeof *r + strlen(uid) );
r->key = pUSERID;
strcpy( r->u.value, uid );
r->next = para;
@@ -2585,12 +2585,12 @@ generate_keypair (const char *fname, const char *card_serialno,
dek = card_serialno? NULL : do_ask_passphrase( &s2k );
if( dek )
{
- r = m_alloc_clear( sizeof *r );
+ r = xmalloc_clear( sizeof *r );
r->key = pPASSPHRASE_DEK;
r->u.dek = dek;
r->next = para;
para = r;
- r = m_alloc_clear( sizeof *r );
+ r = xmalloc_clear( sizeof *r );
r->key = pPASSPHRASE_S2K;
r->u.s2k = s2k;
r->next = para;
@@ -2637,7 +2637,7 @@ generate_raw_key (int algo, unsigned int nbits, u32 created_at,
dek = do_ask_passphrase (&s2k);
- sk = m_alloc_clear (sizeof *sk);
+ sk = xmalloc_clear (sizeof *sk);
sk->timestamp = created_at;
sk->version = 4;
sk->pubkey_algo = algo;
@@ -2675,8 +2675,8 @@ generate_raw_key (int algo, unsigned int nbits, u32 created_at,
leave:
if (sk)
free_secret_key (sk);
- m_free (dek);
- m_free (s2k);
+ xfree (dek);
+ xfree (s2k);
return rc;
}
#endif /* ENABLE_CARD_SUPPORT */
@@ -2687,7 +2687,7 @@ start_tree(KBNODE *tree)
{
PACKET *pkt;
- pkt=m_alloc_clear(sizeof(*pkt));
+ pkt=xmalloc_clear(sizeof(*pkt));
pkt->pkttype=PKT_NONE;
*tree=new_kbnode(pkt);
delete_kbnode(*tree);
@@ -2717,7 +2717,7 @@ do_generate_keypair( struct para_data_s *para,
outctrl->pub.stream = NULL;
if (outctrl->pub.fname)
iobuf_ioctl (NULL, 2, 0, (char*)outctrl->pub.fname);
- m_free( outctrl->pub.fname );
+ xfree( outctrl->pub.fname );
outctrl->pub.fname = outctrl->pub.newfname;
outctrl->pub.newfname = NULL;
@@ -2745,7 +2745,7 @@ do_generate_keypair( struct para_data_s *para,
outctrl->sec.stream = NULL;
if (outctrl->sec.fname)
iobuf_ioctl (NULL, 2, 0, (char*)outctrl->sec.fname);
- m_free( outctrl->sec.fname );
+ xfree( outctrl->sec.fname );
outctrl->sec.fname = outctrl->sec.newfname;
outctrl->sec.newfname = NULL;
@@ -3089,7 +3089,7 @@ generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock )
if (ask_pass)
dek = do_ask_passphrase (&s2k);
else if (passphrase) {
- s2k = m_alloc_secure( sizeof *s2k );
+ s2k = xmalloc_secure( sizeof *s2k );
s2k->mode = opt.s2k_mode;
s2k->hash_algo = S2K_DIGEST_ALGO;
set_next_passphrase( passphrase );
@@ -3111,9 +3111,9 @@ generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock )
leave:
if( rc )
log_error(_("Key generation failed: %s\n"), g10_errstr(rc) );
- m_free( passphrase );
- m_free( dek );
- m_free( s2k );
+ xfree( passphrase );
+ xfree( dek );
+ xfree( s2k );
/* release the copy of the (now unprotected) secret keys */
if( pri_sk )
free_secret_key(pri_sk);
@@ -3226,7 +3226,7 @@ generate_card_subkeypair (KBNODE pub_keyblock, KBNODE sec_keyblock,
leave:
if (rc)
log_error (_("Key generation failed: %s\n"), g10_errstr(rc) );
- m_free (passphrase);
+ xfree (passphrase);
/* Release the copy of the (now unprotected) secret keys. */
if (pri_sk)
free_secret_key (pri_sk);
@@ -3409,7 +3409,7 @@ gen_card_key_with_backup (int algo, int keyno, int is_primary,
{
log_error (_("can't create backup file `%s': %s\n"),
fname, strerror(errno) );
- m_free (fname);
+ xfree (fname);
free_secret_key (sk_unprotected);
free_secret_key (sk_protected);
return G10ERR_OPEN_FILE;
@@ -3449,8 +3449,8 @@ gen_card_key_with_backup (int algo, int keyno, int is_primary,
xfree (fprbuf);
}
free_packet (pkt);
- m_free (pkt);
- m_free (fname);
+ xfree (pkt);
+ xfree (fname);
if (rc)
{
free_secret_key (sk_unprotected);
diff --git a/g10/keyid.c b/g10/keyid.c
index eeeaeedde..7d5b905a5 100644
--- a/g10/keyid.c
+++ b/g10/keyid.c
@@ -109,7 +109,7 @@ hash_public_key( MD_HANDLE md, PKT_public_key *pk )
md_putc( md, nb[i]>>8);
md_putc( md, nb[i] );
md_write( md, pp[i], nn[i] );
- m_free(pp[i]);
+ xfree(pp[i]);
}
}
@@ -412,7 +412,7 @@ namehash_from_uid(PKT_user_id *uid)
{
if(uid->namehash==NULL)
{
- uid->namehash=m_alloc(20);
+ uid->namehash=xmalloc(20);
if(uid->attrib_data)
rmd160_hash_buffer(uid->namehash,uid->attrib_data,uid->attrib_len);
@@ -650,14 +650,14 @@ fingerprint_from_pk( PKT_public_key *pk, byte *array, size_t *ret_len )
if( pubkey_get_npkey( pk->pubkey_algo ) > 1 ) {
p = buf = mpi_get_buffer( pk->pkey[0], &n, NULL );
md_write( md, p, n );
- m_free(buf);
+ xfree(buf);
p = buf = mpi_get_buffer( pk->pkey[1], &n, NULL );
md_write( md, p, n );
- m_free(buf);
+ xfree(buf);
}
md_final(md);
if( !array )
- array = m_alloc( 16 );
+ array = xmalloc( 16 );
len = 16;
memcpy(array, md_read(md, DIGEST_ALGO_MD5), 16 );
md_close(md);
@@ -665,7 +665,7 @@ fingerprint_from_pk( PKT_public_key *pk, byte *array, size_t *ret_len )
else
{
if(!array)
- array=m_alloc(16);
+ array=xmalloc(16);
len=16;
memset(array,0,16);
}
@@ -677,7 +677,7 @@ fingerprint_from_pk( PKT_public_key *pk, byte *array, size_t *ret_len )
len = md_digest_length( md_get_algo( md ) );
assert( len <= MAX_FINGERPRINT_LEN );
if( !array )
- array = m_alloc( len );
+ array = xmalloc( len );
memcpy(array, dp, len );
pk->keyid[0] = dp[12] << 24 | dp[13] << 16 | dp[14] << 8 | dp[15] ;
pk->keyid[1] = dp[16] << 24 | dp[17] << 16 | dp[18] << 8 | dp[19] ;
@@ -707,14 +707,14 @@ fingerprint_from_sk( PKT_secret_key *sk, byte *array, size_t *ret_len )
if( pubkey_get_npkey( sk->pubkey_algo ) > 1 ) {
p = buf = mpi_get_buffer( sk->skey[0], &n, NULL );
md_write( md, p, n );
- m_free(buf);
+ xfree(buf);
p = buf = mpi_get_buffer( sk->skey[1], &n, NULL );
md_write( md, p, n );
- m_free(buf);
+ xfree(buf);
}
md_final(md);
if( !array )
- array = m_alloc( 16 );
+ array = xmalloc( 16 );
len = 16;
memcpy(array, md_read(md, DIGEST_ALGO_MD5), 16 );
md_close(md);
@@ -722,7 +722,7 @@ fingerprint_from_sk( PKT_secret_key *sk, byte *array, size_t *ret_len )
else
{
if(!array)
- array=m_alloc(16);
+ array=xmalloc(16);
len=16;
memset(array,0,16);
}
@@ -736,7 +736,7 @@ fingerprint_from_sk( PKT_secret_key *sk, byte *array, size_t *ret_len )
len = md_digest_length( md_get_algo( md ) );
assert( len <= MAX_FINGERPRINT_LEN );
if( !array )
- array = m_alloc( len );
+ array = xmalloc( len );
memcpy(array, dp, len );
md_close(md);
}
@@ -744,7 +744,7 @@ fingerprint_from_sk( PKT_secret_key *sk, byte *array, size_t *ret_len )
{
len=MAX_FINGERPRINT_LEN;
if(!array)
- array=m_alloc(len);
+ array=xmalloc(len);
memset(array,0,len);
}
}
diff --git a/g10/keylist.c b/g10/keylist.c
index 4ea092fb9..b5ba537de 100644
--- a/g10/keylist.c
+++ b/g10/keylist.c
@@ -134,7 +134,7 @@ print_seckey_info (PKT_secret_key *sk)
pubkey_letter (sk->pubkey_algo),
keystr(keyid), datestr_from_sk (sk), p);
- m_free (p);
+ xfree (p);
}
/* Print information about the public key. With FP passed as NULL,
@@ -165,7 +165,7 @@ print_pubkey_info (FILE *fp, PKT_public_key *pk)
nbits_from_pk (pk), pubkey_letter (pk->pubkey_algo),
keystr(keyid), datestr_from_pk (pk), p);
- m_free (p);
+ xfree (p);
}
@@ -986,7 +986,7 @@ list_keyblock_print ( KBNODE keyblock, int secret, int fpr, void *opaque )
size_t n;
char *p = get_user_id( sig->keyid, &n );
print_utf8_string( stdout, p, n );
- m_free(p);
+ xfree(p);
}
putchar('\n');
@@ -1293,7 +1293,7 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr )
fflush(stdout);
if(opt.no_sig_cache)
- signer_pk=m_alloc_clear(sizeof(PKT_public_key));
+ signer_pk=xmalloc_clear(sizeof(PKT_public_key));
rc = check_key_signature2( keyblock, node, NULL, signer_pk,
NULL, NULL, NULL );
@@ -1345,7 +1345,7 @@ list_keyblock_colon( KBNODE keyblock, int secret, int fpr )
size_t n;
char *p = get_user_id( sig->keyid, &n );
print_string( stdout, p, n, ':' );
- m_free(p);
+ xfree(p);
}
printf(":%02x%c:", sig->sig_class,sig->flags.exportable?'x':'l');
@@ -1469,14 +1469,14 @@ print_fingerprint (PKT_public_key *pk, PKT_secret_key *sk, int mode )
{
if(sk)
{
- PKT_secret_key *primary_sk=m_alloc_clear(sizeof(*primary_sk));
+ PKT_secret_key *primary_sk=xmalloc_clear(sizeof(*primary_sk));
get_seckey(primary_sk,sk->main_keyid);
print_fingerprint(NULL,primary_sk,mode|0x80);
free_secret_key(primary_sk);
}
else
{
- PKT_public_key *primary_pk=m_alloc_clear(sizeof(*primary_pk));
+ PKT_public_key *primary_pk=xmalloc_clear(sizeof(*primary_pk));
get_pubkey(primary_pk,pk->main_keyid);
print_fingerprint(primary_pk,NULL,mode|0x80);
free_public_key(primary_pk);
diff --git a/g10/keyring.c b/g10/keyring.c
index 49e114e1d..9ef5b1bd4 100644
--- a/g10/keyring.c
+++ b/g10/keyring.c
@@ -102,7 +102,7 @@ new_offset_item (void)
{
struct off_item *k;
- k = m_alloc_clear (sizeof *k);
+ k = xmalloc_clear (sizeof *k);
return k;
}
@@ -115,7 +115,7 @@ release_offset_items (struct off_item *k)
for (; k; k = k2)
{
k2 = k->next;
- m_free (k);
+ xfree (k);
}
}
#endif
@@ -125,7 +125,7 @@ new_offset_hash_table (void)
{
struct off_item **tbl;
- tbl = m_alloc_clear (2048 * sizeof *tbl);
+ tbl = xmalloc_clear (2048 * sizeof *tbl);
return tbl;
}
@@ -139,7 +139,7 @@ release_offset_hash_table (OffsetHashTable tbl)
return;
for (i=0; i < 2048; i++)
release_offset_items (tbl[i]);
- m_free (tbl);
+ xfree (tbl);
}
#endif
@@ -217,7 +217,7 @@ keyring_register_filename (const char *fname, int secret, void **ptr)
if (secret)
register_secured_file (fname);
- kr = m_alloc (sizeof *kr + strlen (fname));
+ kr = xmalloc (sizeof *kr + strlen (fname));
strcpy (kr->fname, fname);
kr->secret = !!secret;
kr->lockhd = NULL;
@@ -258,7 +258,7 @@ keyring_new (void *token, int secret)
assert (resource && !resource->secret == !secret);
- hd = m_alloc_clear (sizeof *hd);
+ hd = xmalloc_clear (sizeof *hd);
hd->resource = resource;
hd->secret = !!secret;
active_handles++;
@@ -272,10 +272,10 @@ keyring_release (KEYRING_HANDLE hd)
return;
assert (active_handles > 0);
active_handles--;
- m_free (hd->word_match.name);
- m_free (hd->word_match.pattern);
+ xfree (hd->word_match.name);
+ xfree (hd->word_match.pattern);
iobuf_close (hd->current.iobuf);
- m_free (hd);
+ xfree (hd);
}
@@ -384,7 +384,7 @@ keyring_get_keyblock (KEYRING_HANDLE hd, KBNODE *ret_kb)
return G10ERR_KEYRING_OPEN;
}
- pkt = m_alloc (sizeof *pkt);
+ pkt = xmalloc (sizeof *pkt);
init_packet (pkt);
hd->found.n_packets = 0;;
lastnode = NULL;
@@ -453,7 +453,7 @@ keyring_get_keyblock (KEYRING_HANDLE hd, KBNODE *ret_kb)
}
}
- pkt = m_alloc (sizeof *pkt);
+ pkt = xmalloc (sizeof *pkt);
init_packet(pkt);
}
set_packet_list_mode(save_mode);
@@ -476,7 +476,7 @@ keyring_get_keyblock (KEYRING_HANDLE hd, KBNODE *ret_kb)
*ret_kb = keyblock;
}
free_packet (pkt);
- m_free (pkt);
+ xfree (pkt);
iobuf_close(a);
/* Make sure that future search operations fail immediately when
@@ -780,7 +780,7 @@ prepare_word_match (const byte *name)
int c;
/* the original length is always enough for the pattern */
- p = pattern = m_alloc(strlen(name)+1);
+ p = pattern = xmalloc(strlen(name)+1);
do {
/* skip leading delimiters */
while( *name && !word_match_chars[*name] )
@@ -957,9 +957,9 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc,
if ( !hd->word_match.name || strcmp (hd->word_match.name, name) )
{
/* name changed */
- m_free (hd->word_match.name);
- m_free (hd->word_match.pattern);
- hd->word_match.name = m_strdup (name);
+ xfree (hd->word_match.name);
+ xfree (hd->word_match.pattern);
+ hd->word_match.name = xstrdup (name);
hd->word_match.pattern = prepare_word_match (name);
}
name = hd->word_match.pattern;
@@ -1162,27 +1162,27 @@ create_tmp_file (const char *template,
if (strlen (template) > 4
&& !strcmp (template+strlen(template)-4, EXTSEP_S "gpg") )
{
- bakfname = m_alloc (strlen (template) + 1);
+ bakfname = xmalloc (strlen (template) + 1);
strcpy (bakfname, template);
strcpy (bakfname+strlen(template)-4, EXTSEP_S "bak");
- tmpfname = m_alloc (strlen( template ) + 1 );
+ tmpfname = xmalloc (strlen( template ) + 1 );
strcpy (tmpfname,template);
strcpy (tmpfname+strlen(template)-4, EXTSEP_S "tmp");
}
else
{ /* file does not end with gpg; hmmm */
- bakfname = m_alloc (strlen( template ) + 5);
+ bakfname = xmalloc (strlen( template ) + 5);
strcpy (stpcpy(bakfname, template), EXTSEP_S "bak");
- tmpfname = m_alloc (strlen( template ) + 5);
+ tmpfname = xmalloc (strlen( template ) + 5);
strcpy (stpcpy(tmpfname, template), EXTSEP_S "tmp");
}
# else /* Posix file names */
- bakfname = m_alloc (strlen( template ) + 2);
+ bakfname = xmalloc (strlen( template ) + 2);
strcpy (stpcpy (bakfname,template),"~");
- tmpfname = m_alloc (strlen( template ) + 5);
+ tmpfname = xmalloc (strlen( template ) + 5);
strcpy (stpcpy(tmpfname,template), EXTSEP_S "tmp");
# endif /* Posix filename */
@@ -1199,8 +1199,8 @@ create_tmp_file (const char *template,
if (!*r_fp)
{
log_error(_("can't create `%s': %s\n"), tmpfname, strerror(errno) );
- m_free (tmpfname);
- m_free (bakfname);
+ xfree (tmpfname);
+ xfree (bakfname);
return G10ERR_OPEN_FILE;
}
@@ -1367,8 +1367,8 @@ keyring_rebuild_cache (void *token,int noisy)
}
rc = lastresname? rename_tmp_file (bakfilename, tmpfilename,
lastresname, 0) : 0;
- m_free (tmpfilename); tmpfilename = NULL;
- m_free (bakfilename); bakfilename = NULL;
+ xfree (tmpfilename); tmpfilename = NULL;
+ xfree (bakfilename); bakfilename = NULL;
if (rc)
goto leave;
lastresname = resname;
@@ -1447,14 +1447,14 @@ keyring_rebuild_cache (void *token,int noisy)
}
rc = lastresname? rename_tmp_file (bakfilename, tmpfilename,
lastresname, 0) : 0;
- m_free (tmpfilename); tmpfilename = NULL;
- m_free (bakfilename); bakfilename = NULL;
+ xfree (tmpfilename); tmpfilename = NULL;
+ xfree (bakfilename); bakfilename = NULL;
leave:
if (tmpfp)
iobuf_cancel (tmpfp);
- m_free (tmpfilename);
- m_free (bakfilename);
+ xfree (tmpfilename);
+ xfree (bakfilename);
release_kbnode (keyblock);
keyring_lock (hd, 0);
keyring_release (hd);
@@ -1618,7 +1618,7 @@ do_copy (int mode, const char *fname, KBNODE root, int secret,
rc = rename_tmp_file (bakfname, tmpfname, fname, secret);
leave:
- m_free(bakfname);
- m_free(tmpfname);
+ xfree(bakfname);
+ xfree(tmpfname);
return rc;
}
diff --git a/g10/keyserver.c b/g10/keyserver.c
index 574a53414..807857eb4 100644
--- a/g10/keyserver.c
+++ b/g10/keyserver.c
@@ -128,14 +128,14 @@ parse_keyserver_options(char *options)
{
char *joined;
- joined=m_alloc(strlen(tok)+1+strlen(arg)+1);
+ joined=xmalloc(strlen(tok)+1+strlen(arg)+1);
/* Make a canonical name=value form with no
spaces */
strcpy(joined,tok);
strcat(joined,"=");
strcat(joined,arg);
add_to_strlist(&opt.keyserver_options.other,joined);
- m_free(joined);
+ xfree(joined);
}
else
add_to_strlist(&opt.keyserver_options.other,tok);
@@ -148,14 +148,14 @@ parse_keyserver_options(char *options)
void
free_keyserver_spec(struct keyserver_spec *keyserver)
{
- m_free(keyserver->uri);
- m_free(keyserver->scheme);
- m_free(keyserver->auth);
- m_free(keyserver->host);
- m_free(keyserver->port);
- m_free(keyserver->path);
- m_free(keyserver->opaque);
- m_free(keyserver);
+ xfree(keyserver->uri);
+ xfree(keyserver->scheme);
+ xfree(keyserver->auth);
+ xfree(keyserver->host);
+ xfree(keyserver->port);
+ xfree(keyserver->path);
+ xfree(keyserver->opaque);
+ xfree(keyserver);
}
/* TODO: once we cut over to an all-curl world, we don't need this
@@ -173,9 +173,9 @@ parse_keyserver_uri(const char *uri,int require_scheme,
assert(uri!=NULL);
- keyserver=m_alloc_clear(sizeof(struct keyserver_spec));
+ keyserver=xmalloc_clear(sizeof(struct keyserver_spec));
- keyserver->uri=m_strdup(uri);
+ keyserver->uri=xstrdup(uri);
/* Get the scheme */
@@ -206,13 +206,13 @@ parse_keyserver_uri(const char *uri,int require_scheme,
/* Assume HKP if there is no scheme */
assume_hkp=1;
- keyserver->scheme=m_strdup("hkp");
+ keyserver->scheme=xstrdup("hkp");
}
else
{
int i;
- keyserver->scheme=m_alloc(count+1);
+ keyserver->scheme=xmalloc(count+1);
/* Force to lowercase */
for(i=0;i<count;i++)
@@ -228,16 +228,16 @@ parse_keyserver_uri(const char *uri,int require_scheme,
{
deprecated_warning(configname,configlineno,"x-broken-hkp",
"--keyserver-options ","broken-http-proxy");
- m_free(keyserver->scheme);
- keyserver->scheme=m_strdup("hkp");
+ xfree(keyserver->scheme);
+ keyserver->scheme=xstrdup("hkp");
add_to_strlist(&opt.keyserver_options.other,"broken-http-proxy");
}
else if(ascii_strcasecmp(keyserver->scheme,"x-hkp")==0)
{
/* Canonicalize this to "hkp" so it works with both the internal
and external keyserver interface. */
- m_free(keyserver->scheme);
- keyserver->scheme=m_strdup("hkp");
+ xfree(keyserver->scheme);
+ keyserver->scheme=xstrdup("hkp");
}
if(assume_hkp || (uri[0]=='/' && uri[1]=='/'))
@@ -259,7 +259,7 @@ parse_keyserver_uri(const char *uri,int require_scheme,
if(count==0)
goto fail;
- keyserver->auth=m_alloc(count+1);
+ keyserver->auth=xmalloc(count+1);
strncpy(keyserver->auth,uri,count);
keyserver->auth[count]='\0';
uri+=count+1;
@@ -286,7 +286,7 @@ parse_keyserver_uri(const char *uri,int require_scheme,
if(count==0)
goto fail;
- keyserver->host=m_alloc(count+1);
+ keyserver->host=xmalloc(count+1);
strncpy(keyserver->host,uri,count);
keyserver->host[count]='\0';
@@ -309,7 +309,7 @@ parse_keyserver_uri(const char *uri,int require_scheme,
goto fail;
}
- keyserver->port=m_alloc(count+1);
+ keyserver->port=xmalloc(count+1);
strncpy(keyserver->port,uri+1,count);
keyserver->port[count]='\0';
@@ -319,15 +319,15 @@ parse_keyserver_uri(const char *uri,int require_scheme,
/* Everything else is the path */
if(*uri)
- keyserver->path=m_strdup(uri);
+ keyserver->path=xstrdup(uri);
else
- keyserver->path=m_strdup("/");
+ keyserver->path=xstrdup("/");
}
else if(uri[0]!='/')
{
/* No slash means opaque. Just record the opaque blob and get
out. */
- keyserver->opaque=m_strdup(uri);
+ keyserver->opaque=xstrdup(uri);
}
else
{
@@ -354,12 +354,12 @@ parse_preferred_keyserver(PKT_signature *sig)
p=parse_sig_subpkt(sig->hashed,SIGSUBPKT_PREF_KS,&plen);
if(p && plen)
{
- byte *dupe=m_alloc(plen+1);
+ byte *dupe=xmalloc(plen+1);
memcpy(dupe,p,plen);
dupe[plen]='\0';
spec=parse_keyserver_uri(dupe,1,NULL,0);
- m_free(dupe);
+ xfree(dupe);
}
return spec;
@@ -461,7 +461,7 @@ parse_keyrec(char *keystring)
return NULL;
else if(work->desc.mode==KEYDB_SEARCH_MODE_NONE)
{
- m_free(work);
+ xfree(work);
return NULL;
}
else
@@ -474,7 +474,7 @@ parse_keyrec(char *keystring)
if(work==NULL)
{
- work=m_alloc_clear(sizeof(struct keyrec));
+ work=xmalloc_clear(sizeof(struct keyrec));
work->uidbuf=iobuf_temp();
}
@@ -495,7 +495,7 @@ parse_keyrec(char *keystring)
if(work->desc.mode)
{
ret=work;
- work=m_alloc_clear(sizeof(struct keyrec));
+ work=xmalloc_clear(sizeof(struct keyrec));
work->uidbuf=iobuf_temp();
}
@@ -610,7 +610,7 @@ parse_keyrec(char *keystring)
if(strlen(decoded)>opt.screen_columns-10)
decoded[opt.screen_columns-10]='\0';
iobuf_writestr(work->uidbuf,decoded);
- m_free(decoded);
+ xfree(decoded);
iobuf_writestr(work->uidbuf,"\n\t");
work->lines++;
}
@@ -648,7 +648,7 @@ show_prompt(KEYDB_SEARCH_DESC *desc,int numdesc,int count,const char *search)
if(answer[0]=='q' || answer[0]=='Q')
{
- m_free(answer);
+ xfree(answer);
return 1;
}
else if(atoi(answer)>=1 && atoi(answer)<=numdesc)
@@ -659,7 +659,7 @@ show_prompt(KEYDB_SEARCH_DESC *desc,int numdesc,int count,const char *search)
if(atoi(num)>=1 && atoi(num)<=numdesc)
keyserver_work(GET,NULL,&desc[atoi(num)-1],1,opt.keyserver);
- m_free(answer);
+ xfree(answer);
return 1;
}
@@ -681,7 +681,7 @@ keyserver_search_prompt(IOBUF buffer,const char *searchstr)
if(searchstr)
localstr=utf8_to_native(searchstr,strlen(searchstr),0);
- desc=m_alloc(count*sizeof(KEYDB_SEARCH_DESC));
+ desc=xmalloc(count*sizeof(KEYDB_SEARCH_DESC));
for(;;)
{
@@ -736,7 +736,7 @@ keyserver_search_prompt(IOBUF buffer,const char *searchstr)
else
validcount=1;
- desc=m_realloc(desc,count*sizeof(KEYDB_SEARCH_DESC));
+ desc=xrealloc(desc,count*sizeof(KEYDB_SEARCH_DESC));
}
started=1;
@@ -776,7 +776,7 @@ keyserver_search_prompt(IOBUF buffer,const char *searchstr)
/* keyserver helper sent more keys than they claimed in the
info: line. */
count+=10;
- desc=m_realloc(desc,count*sizeof(KEYDB_SEARCH_DESC));
+ desc=xrealloc(desc,count*sizeof(KEYDB_SEARCH_DESC));
validcount=0;
}
@@ -800,7 +800,7 @@ keyserver_search_prompt(IOBUF buffer,const char *searchstr)
numlines+=keyrec->lines;
iobuf_close(keyrec->uidbuf);
- m_free(keyrec);
+ xfree(keyrec);
started=1;
i++;
@@ -824,9 +824,9 @@ keyserver_search_prompt(IOBUF buffer,const char *searchstr)
log_info(_("key not found on keyserver\n"));
}
- m_free(localstr);
- m_free(desc);
- m_free(line);
+ xfree(localstr);
+ xfree(desc);
+ xfree(line);
}
static int
@@ -922,14 +922,14 @@ keyserver_spawn(int action,STRLIST list,KEYDB_SEARCH_DESC *desc,
/* If exec-path was set, and DISABLE_KEYSERVER_PATH is
undefined, then don't specify a full path to gpgkeys_foo, so
that the PATH can work. */
- command=m_alloc(strlen(GPGKEYS_PREFIX)+strlen(scheme)+1);
+ command=xmalloc(strlen(GPGKEYS_PREFIX)+strlen(scheme)+1);
command[0]='\0';
}
else
#endif
{
/* Specify a full path to gpgkeys_foo. */
- command=m_alloc(strlen(libexecdir)+strlen(DIRSEP_S)+
+ command=xmalloc(strlen(libexecdir)+strlen(DIRSEP_S)+
strlen(GPGKEYS_PREFIX)+strlen(scheme)+1);
strcpy(command,libexecdir);
strcat(command,DIRSEP_S);
@@ -942,13 +942,13 @@ keyserver_spawn(int action,STRLIST list,KEYDB_SEARCH_DESC *desc,
{
if(opt.keyserver_options.options&KEYSERVER_KEEP_TEMP_FILES)
{
- command=m_realloc(command,strlen(command)+
+ command=xrealloc(command,strlen(command)+
strlen(KEYSERVER_ARGS_KEEP)+1);
strcat(command,KEYSERVER_ARGS_KEEP);
}
else
{
- command=m_realloc(command,strlen(command)+
+ command=xrealloc(command,strlen(command)+
strlen(KEYSERVER_ARGS_NOKEEP)+1);
strcat(command,KEYSERVER_ARGS_NOKEEP);
}
@@ -958,7 +958,7 @@ keyserver_spawn(int action,STRLIST list,KEYDB_SEARCH_DESC *desc,
else
ret=exec_write(&spawn,command,NULL,NULL,0,0);
- m_free(command);
+ xfree(command);
if(ret)
return ret;
@@ -1227,13 +1227,13 @@ keyserver_spawn(int action,STRLIST list,KEYDB_SEARCH_DESC *desc,
fprintf(spawn->tochild,"%s\n",key->d);
if(key!=list)
{
- searchstr=m_realloc(searchstr,
+ searchstr=xrealloc(searchstr,
strlen(searchstr)+strlen(key->d)+2);
strcat(searchstr," ");
}
else
{
- searchstr=m_alloc(strlen(key->d)+1);
+ searchstr=xmalloc(strlen(key->d)+1);
searchstr[0]='\0';
}
@@ -1471,7 +1471,7 @@ keyserver_import(STRLIST users)
int rc=0;
/* Build a list of key ids */
- desc=m_alloc(sizeof(KEYDB_SEARCH_DESC)*num);
+ desc=xmalloc(sizeof(KEYDB_SEARCH_DESC)*num);
for(;users;users=users->next)
{
@@ -1489,14 +1489,14 @@ keyserver_import(STRLIST users)
if(count==num)
{
num+=100;
- desc=m_realloc(desc,sizeof(KEYDB_SEARCH_DESC)*num);
+ desc=xrealloc(desc,sizeof(KEYDB_SEARCH_DESC)*num);
}
}
if(count>0)
rc=keyserver_work(GET,NULL,desc,count,opt.keyserver);
- m_free(desc);
+ xfree(desc);
return rc;
}
@@ -1547,21 +1547,21 @@ keyidlist(STRLIST users,KEYDB_SEARCH_DESC **klist,int *count,int fakev3)
*count=0;
- *klist=m_alloc(sizeof(KEYDB_SEARCH_DESC)*num);
+ *klist=xmalloc(sizeof(KEYDB_SEARCH_DESC)*num);
kdbhd=keydb_new(0);
if(!users)
{
ndesc = 1;
- desc = m_alloc_clear ( ndesc * sizeof *desc);
+ desc = xmalloc_clear ( ndesc * sizeof *desc);
desc[0].mode = KEYDB_SEARCH_MODE_FIRST;
}
else
{
for (ndesc=0, sl=users; sl; sl = sl->next, ndesc++)
;
- desc = m_alloc ( ndesc * sizeof *desc);
+ desc = xmalloc ( ndesc * sizeof *desc);
for (ndesc=0, sl=users; sl; sl = sl->next)
{
@@ -1606,7 +1606,7 @@ keyidlist(STRLIST users,KEYDB_SEARCH_DESC **klist,int *count,int fakev3)
if(*count==num)
{
num+=100;
- *klist=m_realloc(*klist,sizeof(KEYDB_SEARCH_DESC)*num);
+ *klist=xrealloc(*klist,sizeof(KEYDB_SEARCH_DESC)*num);
}
}
@@ -1671,7 +1671,7 @@ keyidlist(STRLIST users,KEYDB_SEARCH_DESC **klist,int *count,int fakev3)
if(*count==num)
{
num+=100;
- *klist=m_realloc(*klist,sizeof(KEYDB_SEARCH_DESC)*num);
+ *klist=xrealloc(*klist,sizeof(KEYDB_SEARCH_DESC)*num);
}
}
}
@@ -1681,8 +1681,8 @@ keyidlist(STRLIST users,KEYDB_SEARCH_DESC **klist,int *count,int fakev3)
leave:
if(rc)
- m_free(*klist);
- m_free(desc);
+ xfree(*klist);
+ xfree(desc);
keydb_release(kdbhd);
release_kbnode(keyblock);
@@ -1769,7 +1769,7 @@ keyserver_refresh(STRLIST users)
rc=keyserver_work(GET,NULL,desc,numdesc,opt.keyserver);
}
- m_free(desc);
+ xfree(desc);
opt.keyserver_options.import_options=options;
diff --git a/g10/mainproc.c b/g10/mainproc.c
index 74d626543..5913f9304 100644
--- a/g10/mainproc.c
+++ b/g10/mainproc.c
@@ -95,7 +95,7 @@ release_list( CTX c )
release_kbnode( c->list );
while( c->pkenc_list ) {
struct kidlist_item *tmp = c->pkenc_list->next;
- m_free( c->pkenc_list );
+ xfree( c->pkenc_list );
c->pkenc_list = tmp;
}
c->pkenc_list = NULL;
@@ -104,7 +104,7 @@ release_list( CTX c )
c->last_was_session_key = 0;
c->pipemode.op = 0;
c->pipemode.stop_now = 0;
- m_free(c->dek); c->dek = NULL;
+ xfree(c->dek); c->dek = NULL;
}
@@ -318,10 +318,10 @@ proc_symkey_enc( CTX c, PACKET *pkt )
if(opt.override_session_key)
{
- c->dek = m_alloc_clear( sizeof *c->dek );
+ c->dek = xmalloc_clear( sizeof *c->dek );
if(get_override_session_key(c->dek, opt.override_session_key))
{
- m_free(c->dek);
+ xfree(c->dek);
c->dek = NULL;
}
}
@@ -345,7 +345,7 @@ proc_symkey_enc( CTX c, PACKET *pkt )
if(symkey_decrypt_seskey(c->dek, enc->seskey,
enc->seskeylen))
{
- m_free(c->dek);
+ xfree(c->dek);
c->dek=NULL;
}
}
@@ -386,10 +386,10 @@ proc_pubkey_enc( CTX c, PACKET *pkt )
/* It does not make much sense to store the session key in
* secure memory because it has already been passed on the
* command line and the GCHQ knows about it */
- c->dek = m_alloc_clear( sizeof *c->dek );
+ c->dek = xmalloc_clear( sizeof *c->dek );
result = get_override_session_key ( c->dek, opt.override_session_key );
if ( result ) {
- m_free(c->dek); c->dek = NULL;
+ xfree(c->dek); c->dek = NULL;
}
}
else if( is_ELGAMAL(enc->pubkey_algo)
@@ -401,10 +401,10 @@ proc_pubkey_enc( CTX c, PACKET *pkt )
if( opt.list_only )
result = -1;
else {
- c->dek = m_alloc_secure_clear( sizeof *c->dek );
+ c->dek = xmalloc_secure_clear( sizeof *c->dek );
if( (result = get_session_key( enc, c->dek )) ) {
/* error: delete the DEK */
- m_free(c->dek); c->dek = NULL;
+ xfree(c->dek); c->dek = NULL;
}
}
}
@@ -419,7 +419,7 @@ proc_pubkey_enc( CTX c, PACKET *pkt )
else
{
/* store it for later display */
- struct kidlist_item *x = m_alloc( sizeof *x );
+ struct kidlist_item *x = xmalloc( sizeof *x );
x->kid[0] = enc->keyid[0];
x->kid[1] = enc->keyid[1];
x->pubkey_algo = enc->pubkey_algo;
@@ -453,7 +453,7 @@ print_pkenc_list( struct kidlist_item *list, int failed )
continue;
algstr = pubkey_algo_to_string( list->pubkey_algo );
- pk = m_alloc_clear( sizeof *pk );
+ pk = xmalloc_clear( sizeof *pk );
if( !algstr )
algstr = "[?]";
@@ -466,7 +466,7 @@ print_pkenc_list( struct kidlist_item *list, int failed )
strtimestamp(pk->timestamp) );
p=get_user_id_native(list->kid);
fprintf(log_stream(),_(" \"%s\"\n"),p);
- m_free(p);
+ xfree(p);
}
else
log_info(_("encrypted with %s key, ID %s\n"),
@@ -515,11 +515,11 @@ proc_encrypted( CTX c, PACKET *pkt )
if(opt.override_session_key)
{
- c->dek = m_alloc_clear( sizeof *c->dek );
+ c->dek = xmalloc_clear( sizeof *c->dek );
result=get_override_session_key(c->dek, opt.override_session_key);
if(result)
{
- m_free(c->dek);
+ xfree(c->dek);
c->dek = NULL;
}
}
@@ -575,7 +575,7 @@ proc_encrypted( CTX c, PACKET *pkt )
if(opt.show_session_key)
{
int i;
- char *buf = m_alloc ( c->dek->keylen*2 + 20 );
+ char *buf = xmalloc ( c->dek->keylen*2 + 20 );
sprintf ( buf, "%d:", c->dek->algo );
for(i=0; i < c->dek->keylen; i++ )
sprintf(buf+strlen(buf), "%02X", c->dek->key[i] );
@@ -594,7 +594,7 @@ proc_encrypted( CTX c, PACKET *pkt )
/* Hmmm: does this work when we have encrypted using multiple
* ways to specify the session key (symmmetric and PK)*/
}
- m_free(c->dek); c->dek = NULL;
+ xfree(c->dek); c->dek = NULL;
free_packet(pkt);
c->last_was_session_key = 0;
write_status( STATUS_END_DECRYPTION );
@@ -1099,7 +1099,7 @@ list_node( CTX c, KBNODE node )
else if( !opt.fast_list_mode ) {
p = get_user_id( sig->keyid, &n );
print_string( stdout, p, n, opt.with_colons );
- m_free(p);
+ xfree(p);
}
if( opt.with_colons )
printf(":%02x%c:", sig->sig_class, sig->flags.exportable?'x':'l');
@@ -1115,11 +1115,11 @@ int
proc_packets( void *anchor, IOBUF a )
{
int rc;
- CTX c = m_alloc_clear( sizeof *c );
+ CTX c = xmalloc_clear( sizeof *c );
c->anchor = anchor;
rc = do_proc_packets( c, a );
- m_free( c );
+ xfree( c );
return rc;
}
@@ -1129,7 +1129,7 @@ int
proc_signature_packets( void *anchor, IOBUF a,
STRLIST signedfiles, const char *sigfilename )
{
- CTX c = m_alloc_clear( sizeof *c );
+ CTX c = xmalloc_clear( sizeof *c );
int rc;
c->anchor = anchor;
@@ -1137,20 +1137,20 @@ proc_signature_packets( void *anchor, IOBUF a,
c->signed_data = signedfiles;
c->sigfilename = sigfilename;
rc = do_proc_packets( c, a );
- m_free( c );
+ xfree( c );
return rc;
}
int
proc_encryption_packets( void *anchor, IOBUF a )
{
- CTX c = m_alloc_clear( sizeof *c );
+ CTX c = xmalloc_clear( sizeof *c );
int rc;
c->anchor = anchor;
c->encrypt_only = 1;
rc = do_proc_packets( c, a );
- m_free( c );
+ xfree( c );
return rc;
}
@@ -1158,7 +1158,7 @@ proc_encryption_packets( void *anchor, IOBUF a )
int
do_proc_packets( CTX c, IOBUF a )
{
- PACKET *pkt = m_alloc( sizeof *pkt );
+ PACKET *pkt = xmalloc( sizeof *pkt );
int rc=0;
int any_data=0;
int newpkt;
@@ -1266,7 +1266,7 @@ do_proc_packets( CTX c, IOBUF a )
if( newpkt == -1 )
;
else if( newpkt ) {
- pkt = m_alloc( sizeof *pkt );
+ pkt = xmalloc( sizeof *pkt );
init_packet(pkt);
}
else
@@ -1288,9 +1288,9 @@ do_proc_packets( CTX c, IOBUF a )
leave:
release_list( c );
- m_free(c->dek);
+ xfree(c->dek);
free_packet( pkt );
- m_free( pkt );
+ xfree( pkt );
free_md_filter_context( &c->mfx );
return rc;
}
@@ -1502,7 +1502,7 @@ check_sig_and_print( CTX c, KBNODE node )
else
log_info(_("Good signature from \"%s\""),p);
- m_free(p);
+ xfree(p);
if(opt.verify_options&VERIFY_SHOW_UID_VALIDITY)
fprintf(log_stream()," [%s]\n",trust_value_to_string(valid));
@@ -1541,7 +1541,7 @@ check_sig_and_print( CTX c, KBNODE node )
p=utf8_to_native(un->pkt->pkt.user_id->name,
un->pkt->pkt.user_id->len,0);
else
- p=m_strdup("[?]");
+ p=xstrdup("[?]");
if(rc)
log_info(_("BAD signature from \"%s\""),p);
@@ -1585,7 +1585,7 @@ check_sig_and_print( CTX c, KBNODE node )
p=utf8_to_native(un->pkt->pkt.user_id->name,
un->pkt->pkt.user_id->len,0);
log_info(_(" aka \"%s\""),p);
- m_free(p);
+ xfree(p);
if(opt.verify_options&VERIFY_SHOW_UID_VALIDITY)
{
@@ -1628,7 +1628,7 @@ check_sig_and_print( CTX c, KBNODE node )
if( !rc && is_status_enabled() ) {
/* print a status response with the fingerprint */
- PKT_public_key *vpk = m_alloc_clear( sizeof *vpk );
+ PKT_public_key *vpk = xmalloc_clear( sizeof *vpk );
if( !get_pubkey( vpk, sig->keyid ) ) {
byte array[MAX_FINGERPRINT_LEN], *p;
@@ -1656,7 +1656,7 @@ check_sig_and_print( CTX c, KBNODE node )
akid[0] = vpk->main_keyid[0];
akid[1] = vpk->main_keyid[1];
free_public_key (vpk);
- vpk = m_alloc_clear( sizeof *vpk );
+ vpk = xmalloc_clear( sizeof *vpk );
if (get_pubkey (vpk, akid)) {
/* impossible error, we simply return a zeroed out fpr */
n = MAX_FINGERPRINT_LEN < 20? MAX_FINGERPRINT_LEN : 20;
diff --git a/g10/misc.c b/g10/misc.c
index 9f412f3de..380172f09 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -289,7 +289,7 @@ checksum_mpi( MPI a )
nbits = mpi_get_nbits(a);
csum = checksum_u16( nbits );
csum += checksum( buffer, nbytes );
- m_free( buffer );
+ xfree( buffer );
return csum;
}
@@ -468,7 +468,7 @@ static unsigned long get_signature_count(PKT_secret_key *sk)
return 0;
}
-/* Expand %-strings. Returns a string which must be m_freed. Returns
+/* Expand %-strings. Returns a string which must be xfreed. Returns
NULL if the string cannot be expanded (too large). */
char *
pct_expando(const char *string,struct expando_args *args)
@@ -500,7 +500,7 @@ pct_expando(const char *string,struct expando_args *args)
goto fail;
maxlen+=1024;
- ret=m_realloc(ret,maxlen);
+ ret=xrealloc(ret,maxlen);
}
done=0;
@@ -571,7 +571,7 @@ pct_expando(const char *string,struct expando_args *args)
else if(args->sk->main_keyid[0] || args->sk->main_keyid[1])
{
PKT_public_key *pk=
- m_alloc_clear(sizeof(PKT_public_key));
+ xmalloc_clear(sizeof(PKT_public_key));
if(get_pubkey_fast(pk,args->sk->main_keyid)==0)
fingerprint_from_pk(pk,array,&len);
@@ -662,7 +662,7 @@ pct_expando(const char *string,struct expando_args *args)
return ret;
fail:
- m_free(ret);
+ xfree(ret);
return NULL;
}
diff --git a/g10/openfile.c b/g10/openfile.c
index be6585fbd..6970791b9 100644
--- a/g10/openfile.c
+++ b/g10/openfile.c
@@ -101,19 +101,19 @@ make_outfile_name( const char *iname )
size_t n;
if ( iobuf_is_pipe_filename (iname) )
- return m_strdup("-");
+ return xstrdup("-");
n = strlen(iname);
if( n > 4 && ( !CMP_FILENAME(iname+n-4, EXTSEP_S "gpg")
|| !CMP_FILENAME(iname+n-4, EXTSEP_S "pgp")
|| !CMP_FILENAME(iname+n-4, EXTSEP_S "sig")
|| !CMP_FILENAME(iname+n-4, EXTSEP_S "asc") ) ) {
- char *buf = m_strdup( iname );
+ char *buf = xstrdup( iname );
buf[n-4] = 0;
return buf;
}
else if( n > 5 && !CMP_FILENAME(iname+n-5, EXTSEP_S "sign") ) {
- char *buf = m_strdup( iname );
+ char *buf = xstrdup( iname );
buf[n-5] = 0;
return buf;
}
@@ -144,7 +144,7 @@ ask_outfile_name( const char *name, size_t namelen )
n = strlen(s) + namelen + 10;
defname = name && namelen? make_printable_string( name, namelen, 0): NULL;
- prompt = m_alloc(n);
+ prompt = xmalloc(n);
if( defname )
sprintf(prompt, "%s [%s]: ", s, defname );
else
@@ -153,12 +153,12 @@ ask_outfile_name( const char *name, size_t namelen )
fname = cpr_get("openfile.askoutname", prompt );
cpr_kill_prompt();
tty_disable_completion();
- m_free(prompt);
+ xfree(prompt);
if( !*fname ) {
- m_free( fname ); fname = NULL;
+ xfree( fname ); fname = NULL;
fname = defname; defname = NULL;
}
- m_free(defname);
+ xfree(defname);
if (fname)
trim_spaces (fname);
return fname;
@@ -210,7 +210,7 @@ open_outfile( const char *iname, int mode, IOBUF *a )
const char *newsfx = mode==1 ? ".asc" :
mode==2 ? ".sig" : ".gpg";
- buf = m_alloc(strlen(iname)+4+1);
+ buf = xmalloc(strlen(iname)+4+1);
strcpy(buf,iname);
dot = strchr(buf, '.' );
if ( dot && dot > buf && dot[1] && strlen(dot) <= 4
@@ -226,7 +226,7 @@ open_outfile( const char *iname, int mode, IOBUF *a )
if (!buf)
#endif /* USE_ONLY_8DOT3 */
{
- buf = m_alloc(strlen(iname)+4+1);
+ buf = xmalloc(strlen(iname)+4+1);
strcpy(stpcpy(buf,iname), mode==1 ? EXTSEP_S "asc" :
mode==2 ? EXTSEP_S "sig" : EXTSEP_S "gpg");
}
@@ -239,11 +239,11 @@ open_outfile( const char *iname, int mode, IOBUF *a )
char *tmp = ask_outfile_name (NULL, 0);
if ( !tmp || !*tmp )
{
- m_free (tmp);
+ xfree (tmp);
rc = G10ERR_FILE_EXISTS;
break;
}
- m_free (buf);
+ xfree (buf);
name = buf = tmp;
}
@@ -264,7 +264,7 @@ open_outfile( const char *iname, int mode, IOBUF *a )
else if( opt.verbose )
log_info(_("writing to `%s'\n"), name );
}
- m_free(buf);
+ xfree(buf);
}
if (*a)
@@ -290,7 +290,7 @@ open_sigfile( const char *iname, progress_filter_context_t *pfx )
|| ( len > 5 && !strcmp(iname + len - 5, EXTSEP_S "sign") )
|| !strcmp(iname + len - 4, EXTSEP_S "asc")) ) {
char *buf;
- buf = m_strdup(iname);
+ buf = xstrdup(iname);
buf[len-(buf[len-1]=='n'?5:4)] = 0 ;
a = iobuf_open( buf );
if (a && is_secured_file (iobuf_get_fd (a)))
@@ -303,7 +303,7 @@ open_sigfile( const char *iname, progress_filter_context_t *pfx )
log_info(_("assuming signed data in `%s'\n"), buf );
if (a && pfx)
handle_progress (pfx, a, buf);
- m_free(buf);
+ xfree(buf);
}
}
return a;
@@ -327,7 +327,7 @@ copy_options_file( const char *destdir )
if( opt.dry_run )
return;
- fname = m_alloc( strlen(datadir) + strlen(destdir) + 15 );
+ fname = xmalloc( strlen(datadir) + strlen(destdir) + 15 );
strcpy(stpcpy(fname, datadir), DIRSEP_S "options" SKELEXT );
src = fopen( fname, "r" );
if (src && is_secured_file (fileno (src)))
@@ -338,7 +338,7 @@ copy_options_file( const char *destdir )
}
if( !src ) {
log_error(_("can't open `%s': %s\n"), fname, strerror(errno) );
- m_free(fname);
+ xfree(fname);
return;
}
strcpy(stpcpy(fname, destdir), DIRSEP_S "gpg" EXTSEP_S "conf" );
@@ -354,7 +354,7 @@ copy_options_file( const char *destdir )
if( !dst ) {
log_error(_("can't create `%s': %s\n"), fname, strerror(errno) );
fclose( src );
- m_free(fname);
+ xfree(fname);
return;
}
@@ -384,7 +384,7 @@ copy_options_file( const char *destdir )
log_info (_("WARNING: options in `%s'"
" are not yet active during this run\n"),
fname);
- m_free(fname);
+ xfree(fname);
}
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index aa349a220..068ffbffe 100644
--- a/g10/parse-packet.c
+++ b/g10/parse-packet.c
@@ -473,12 +473,12 @@ parse( IOBUF inp, PACKET *pkt, int onlykeypkts, off_t *retpos,
switch( pkttype ) {
case PKT_PUBLIC_KEY:
case PKT_PUBLIC_SUBKEY:
- pkt->pkt.public_key = m_alloc_clear(sizeof *pkt->pkt.public_key );
+ pkt->pkt.public_key = xmalloc_clear(sizeof *pkt->pkt.public_key );
rc = parse_key(inp, pkttype, pktlen, hdr, hdrlen, pkt );
break;
case PKT_SECRET_KEY:
case PKT_SECRET_SUBKEY:
- pkt->pkt.secret_key = m_alloc_clear(sizeof *pkt->pkt.secret_key );
+ pkt->pkt.secret_key = xmalloc_clear(sizeof *pkt->pkt.secret_key );
rc = parse_key(inp, pkttype, pktlen, hdr, hdrlen, pkt );
break;
case PKT_SYMKEY_ENC:
@@ -488,11 +488,11 @@ parse( IOBUF inp, PACKET *pkt, int onlykeypkts, off_t *retpos,
rc = parse_pubkeyenc(inp, pkttype, pktlen, pkt );
break;
case PKT_SIGNATURE:
- pkt->pkt.signature = m_alloc_clear(sizeof *pkt->pkt.signature );
+ pkt->pkt.signature = xmalloc_clear(sizeof *pkt->pkt.signature );
rc = parse_signature(inp, pkttype, pktlen, pkt->pkt.signature );
break;
case PKT_ONEPASS_SIG:
- pkt->pkt.onepass_sig = m_alloc_clear(sizeof *pkt->pkt.onepass_sig );
+ pkt->pkt.onepass_sig = xmalloc_clear(sizeof *pkt->pkt.onepass_sig );
rc = parse_onepass_sig(inp, pkttype, pktlen, pkt->pkt.onepass_sig );
break;
case PKT_USER_ID:
@@ -627,7 +627,7 @@ read_rest( IOBUF inp, size_t pktlen, int partial )
p = NULL;
}
else {
- p = m_alloc( pktlen );
+ p = xmalloc( pktlen );
for(i=0; pktlen; pktlen--, i++ )
p[i] = iobuf_get(inp);
}
@@ -682,7 +682,7 @@ parse_symkeyenc( IOBUF inp, int pkttype, unsigned long pktlen, PACKET *packet )
goto leave;
}
seskeylen = pktlen - minlen;
- k = packet->pkt.symkey_enc = m_alloc_clear( sizeof *packet->pkt.symkey_enc
+ k = packet->pkt.symkey_enc = xmalloc_clear( sizeof *packet->pkt.symkey_enc
+ seskeylen - 1 );
k->version = version;
k->cipher_algo = cipher_algo;
@@ -739,7 +739,7 @@ parse_pubkeyenc( IOBUF inp, int pkttype, unsigned long pktlen, PACKET *packet )
int i, ndata;
PKT_pubkey_enc *k;
- k = packet->pkt.pubkey_enc = m_alloc_clear(sizeof *packet->pkt.pubkey_enc);
+ k = packet->pkt.pubkey_enc = xmalloc_clear(sizeof *packet->pkt.pubkey_enc);
if( pktlen < 12 ) {
log_error("packet(%d) too short\n", pkttype);
rc = G10ERR_INVALID_PACKET;
@@ -1228,7 +1228,7 @@ void parse_revkeys(PKT_signature *sig)
if(len==sizeof(struct revocation_key) &&
(revkey->class&0x80)) /* 0x80 bit must be set */
{
- sig->revkey=m_realloc(sig->revkey,
+ sig->revkey=xrealloc(sig->revkey,
sizeof(struct revocation_key *)*(sig->numrevkeys+1));
sig->revkey[sig->numrevkeys]=revkey;
sig->numrevkeys++;
@@ -1280,7 +1280,7 @@ parse_signature( IOBUF inp, int pkttype, unsigned long pktlen,
goto leave;
}
if( n ) {
- sig->hashed = m_alloc (sizeof (*sig->hashed) + n - 1 );
+ sig->hashed = xmalloc (sizeof (*sig->hashed) + n - 1 );
sig->hashed->size = n;
sig->hashed->len = n;
if( iobuf_read (inp, sig->hashed->data, n ) != n ) {
@@ -1298,7 +1298,7 @@ parse_signature( IOBUF inp, int pkttype, unsigned long pktlen,
goto leave;
}
if( n ) {
- sig->unhashed = m_alloc (sizeof(*sig->unhashed) + n - 1 );
+ sig->unhashed = xmalloc (sizeof(*sig->unhashed) + n - 1 );
sig->unhashed->size = n;
sig->unhashed->len = n;
if( iobuf_read(inp, sig->unhashed->data, n ) != n ) {
@@ -1514,7 +1514,7 @@ read_protected_v3_mpi (IOBUF inp, unsigned long *length)
return NULL;
}
nbytes = (nbits+7) / 8;
- buf = p = m_alloc (2 + nbytes);
+ buf = p = xmalloc (2 + nbytes);
*p++ = nbits >> 8;
*p++ = nbits;
for (; nbytes && length; nbytes--, --*length)
@@ -1522,7 +1522,7 @@ read_protected_v3_mpi (IOBUF inp, unsigned long *length)
if (nbytes)
{
log_error ("packet shorter tham mpi\n");
- m_free (buf);
+ xfree (buf);
return NULL;
}
@@ -1825,7 +1825,7 @@ parse_key( IOBUF inp, int pkttype, unsigned long pktlen,
if( sk->protect.s2k.mode == 1001
|| sk->protect.s2k.mode == 1002 ) {
/* better set some dummy stuff here */
- sk->skey[npkey] = mpi_set_opaque(NULL, m_strdup("dummydata"), 10);
+ sk->skey[npkey] = mpi_set_opaque(NULL, xstrdup("dummydata"), 10);
pktlen = 0;
}
else if( is_v4 && sk->is_protected ) {
@@ -1911,7 +1911,7 @@ parse_attribute_subpkts(PKT_user_id *uid)
int buflen=uid->attrib_len;
byte type;
- m_free(uid->attribs);
+ xfree(uid->attribs);
while(buflen)
{
@@ -1934,7 +1934,7 @@ parse_attribute_subpkts(PKT_user_id *uid)
if( buflen < n )
goto too_short;
- attribs=m_realloc(attribs,(count+1)*sizeof(struct user_attribute));
+ attribs=xrealloc(attribs,(count+1)*sizeof(struct user_attribute));
memset(&attribs[count],0,sizeof(struct user_attribute));
type=*buffer;
@@ -1983,7 +1983,7 @@ parse_user_id( IOBUF inp, int pkttype, unsigned long pktlen, PACKET *packet )
{
byte *p;
- packet->pkt.user_id = m_alloc(sizeof *packet->pkt.user_id + pktlen);
+ packet->pkt.user_id = xmalloc(sizeof *packet->pkt.user_id + pktlen);
packet->pkt.user_id->len = pktlen;
setup_user_id(packet);
@@ -2047,12 +2047,12 @@ parse_attribute( IOBUF inp, int pkttype, unsigned long pktlen, PACKET *packet )
byte *p;
#define EXTRA_UID_NAME_SPACE 71
- packet->pkt.user_id = m_alloc(sizeof *packet->pkt.user_id
+ packet->pkt.user_id = xmalloc(sizeof *packet->pkt.user_id
+ EXTRA_UID_NAME_SPACE);
setup_user_id(packet);
- packet->pkt.user_id->attrib_data = m_alloc(pktlen);
+ packet->pkt.user_id->attrib_data = xmalloc(pktlen);
packet->pkt.user_id->attrib_len = pktlen;
p = packet->pkt.user_id->attrib_data;
for( ; pktlen; pktlen--, p++ )
@@ -2077,7 +2077,7 @@ parse_comment( IOBUF inp, int pkttype, unsigned long pktlen, PACKET *packet )
{
byte *p;
- packet->pkt.comment = m_alloc(sizeof *packet->pkt.comment + pktlen - 1);
+ packet->pkt.comment = xmalloc(sizeof *packet->pkt.comment + pktlen - 1);
packet->pkt.comment->len = pktlen;
p = packet->pkt.comment->data;
for( ; pktlen; pktlen--, p++ )
@@ -2108,7 +2108,7 @@ parse_trust( IOBUF inp, int pkttype, unsigned long pktlen, PACKET *pkt )
{
c = iobuf_get_noeof(inp);
pktlen--;
- pkt->pkt.ring_trust = m_alloc( sizeof *pkt->pkt.ring_trust );
+ pkt->pkt.ring_trust = xmalloc( sizeof *pkt->pkt.ring_trust );
pkt->pkt.ring_trust->trustval = c;
pkt->pkt.ring_trust->sigcache = 0;
if (!c && pktlen==1)
@@ -2150,7 +2150,7 @@ parse_plaintext( IOBUF inp, int pkttype, unsigned long pktlen,
}
mode = iobuf_get_noeof(inp); if( pktlen ) pktlen--;
namelen = iobuf_get_noeof(inp); if( pktlen ) pktlen--;
- pt = pkt->pkt.plaintext = m_alloc(sizeof *pkt->pkt.plaintext + namelen -1);
+ pt = pkt->pkt.plaintext = xmalloc(sizeof *pkt->pkt.plaintext + namelen -1);
pt->new_ctb = new_ctb;
pt->mode = mode;
pt->namelen = namelen;
@@ -2204,7 +2204,7 @@ parse_compressed( IOBUF inp, int pkttype, unsigned long pktlen,
* (this should be the last object in a file or
* the compress algorithm should know the length)
*/
- zd = pkt->pkt.compressed = m_alloc(sizeof *pkt->pkt.compressed );
+ zd = pkt->pkt.compressed = xmalloc(sizeof *pkt->pkt.compressed );
zd->algorithm = iobuf_get_noeof(inp);
zd->len = 0; /* not used */
zd->new_ctb = new_ctb;
@@ -2223,7 +2223,7 @@ parse_encrypted( IOBUF inp, int pkttype, unsigned long pktlen,
PKT_encrypted *ed;
unsigned long orig_pktlen = pktlen;
- ed = pkt->pkt.encrypted = m_alloc(sizeof *pkt->pkt.encrypted );
+ ed = pkt->pkt.encrypted = xmalloc(sizeof *pkt->pkt.encrypted );
ed->len = pktlen;
/* we don't know the extralen which is (cipher_blocksize+2)
because the algorithm ist not specified in this packet.
@@ -2282,7 +2282,7 @@ parse_mdc( IOBUF inp, int pkttype, unsigned long pktlen,
PKT_mdc *mdc;
byte *p;
- mdc = pkt->pkt.mdc= m_alloc(sizeof *pkt->pkt.mdc );
+ mdc = pkt->pkt.mdc= xmalloc(sizeof *pkt->pkt.mdc );
if( list_mode )
fprintf (listfp, ":mdc packet: length=%lu\n", pktlen);
if( !new_ctb || pktlen != 20 ) {
@@ -2332,7 +2332,7 @@ parse_gpg_control( IOBUF inp, int pkttype,
if ( list_mode )
puts ("- gpg control packet");
- packet->pkt.gpg_control = m_alloc(sizeof *packet->pkt.gpg_control
+ packet->pkt.gpg_control = xmalloc(sizeof *packet->pkt.gpg_control
+ pktlen - 1);
packet->pkt.gpg_control->control = iobuf_get_noeof(inp); pktlen--;
packet->pkt.gpg_control->datalen = pktlen;
@@ -2369,10 +2369,10 @@ create_gpg_control( ctrlpkttype_t type, const byte *data, size_t datalen )
PACKET *packet;
byte *p;
- packet = m_alloc( sizeof *packet );
+ packet = xmalloc( sizeof *packet );
init_packet(packet);
packet->pkttype = PKT_GPG_CONTROL;
- packet->pkt.gpg_control = m_alloc(sizeof *packet->pkt.gpg_control
+ packet->pkt.gpg_control = xmalloc(sizeof *packet->pkt.gpg_control
+ datalen - 1);
packet->pkt.gpg_control->control = type;
packet->pkt.gpg_control->datalen = datalen;
diff --git a/g10/passphrase.c b/g10/passphrase.c
index 85b82ca4e..5f9c7915b 100644
--- a/g10/passphrase.c
+++ b/g10/passphrase.c
@@ -94,10 +94,10 @@ have_static_passphrase()
void
set_next_passphrase( const char *s )
{
- m_free(next_pw);
+ xfree(next_pw);
next_pw = NULL;
if( s ) {
- next_pw = m_alloc_secure( strlen(s)+1 );
+ next_pw = xmalloc_secure( strlen(s)+1 );
strcpy(next_pw, s );
}
}
@@ -142,11 +142,11 @@ read_passphrase_from_fd( int fd )
{
char *pw2 = pw;
len += 100;
- pw = m_alloc_secure( len );
+ pw = xmalloc_secure( len );
if( pw2 )
{
memcpy(pw, pw2, i );
- m_free (pw2);
+ xfree (pw2);
}
else
i=0;
@@ -158,7 +158,7 @@ read_passphrase_from_fd( int fd )
if (!opt.batch)
tty_printf("\b\b\b \n" );
- m_free( fd_passwd );
+ xfree( fd_passwd );
fd_passwd = pw;
}
@@ -229,7 +229,7 @@ agent_send_all_options (assuan_context_t ctx)
#if defined(HAVE_SETLOCALE) && defined(LC_CTYPE)
old_lc = setlocale (LC_CTYPE, NULL);
if (old_lc)
- old_lc = m_strdup (old_lc);
+ old_lc = xstrdup (old_lc);
dft_lc = setlocale (LC_CTYPE, "");
#endif
if (opt.lc_ctype || (dft_ttyname && dft_lc))
@@ -241,7 +241,7 @@ agent_send_all_options (assuan_context_t ctx)
if (old_lc)
{
setlocale (LC_CTYPE, old_lc);
- m_free (old_lc);
+ xfree (old_lc);
}
#endif
if (rc)
@@ -250,7 +250,7 @@ agent_send_all_options (assuan_context_t ctx)
#if defined(HAVE_SETLOCALE) && defined(LC_MESSAGES)
old_lc = setlocale (LC_MESSAGES, NULL);
if (old_lc)
- old_lc = m_strdup (old_lc);
+ old_lc = xstrdup (old_lc);
dft_lc = setlocale (LC_MESSAGES, "");
#endif
if (opt.lc_messages || (dft_ttyname && dft_lc))
@@ -262,7 +262,7 @@ agent_send_all_options (assuan_context_t ctx)
if (old_lc)
{
setlocale (LC_MESSAGES, old_lc);
- m_free (old_lc);
+ xfree (old_lc);
}
#endif
return rc;
@@ -472,7 +472,7 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *cacheid,
char *atext = NULL;
assuan_context_t ctx = NULL;
char *pw = NULL;
- PKT_public_key *pk = m_alloc_clear( sizeof *pk );
+ PKT_public_key *pk = xmalloc_clear( sizeof *pk );
byte fpr[MAX_FINGERPRINT_LEN];
int have_fpr = 0;
char *orig_codeset = NULL;
@@ -501,7 +501,7 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *cacheid,
#endif
if (orig_codeset)
{ /* We only switch when we are able to restore the codeset later. */
- orig_codeset = m_strdup (orig_codeset);
+ orig_codeset = xstrdup (orig_codeset);
if (!bind_textdomain_codeset (PACKAGE, "utf-8"))
orig_codeset = NULL;
}
@@ -525,7 +525,7 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *cacheid,
#define KEYIDSTRING _(" (main key ID %s)")
- maink = m_alloc ( strlen (KEYIDSTRING) + keystrlen() + 20 );
+ maink = xmalloc ( strlen (KEYIDSTRING) + keystrlen() + 20 );
if( keyid[2] && keyid[3] && keyid[0] != keyid[2]
&& keyid[1] != keyid[3] )
sprintf( maink, KEYIDSTRING, keystr(&keyid[2]) );
@@ -542,15 +542,15 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *cacheid,
"\"%.*s\"\n" \
"%u-bit %s key, ID %s, created %s%s\n" )
- atext = m_alloc ( 100 + strlen (PROMPTSTRING)
+ atext = xmalloc ( 100 + strlen (PROMPTSTRING)
+ uidlen + 15 + strlen(algo_name) + keystrlen()
+ strlen (timestr) + strlen (maink) );
sprintf (atext, PROMPTSTRING,
(int)uidlen, uid,
nbits_from_pk (pk), algo_name, keystr(&keyid[0]), timestr,
maink );
- m_free (uid);
- m_free (maink);
+ xfree (uid);
+ xfree (maink);
#undef PROMPTSTRING
@@ -562,9 +562,9 @@ agent_get_passphrase ( u32 *keyid, int mode, const char *cacheid,
}
else if (mode == 2 )
- atext = m_strdup ( _("Repeat passphrase\n") );
+ atext = xstrdup ( _("Repeat passphrase\n") );
else
- atext = m_strdup ( _("Enter passphrase\n") );
+ atext = xstrdup ( _("Enter passphrase\n") );
{
char *line, *p;
@@ -791,7 +791,7 @@ ask_passphrase (const char *description,
}
else if (fd_passwd)
{
- pw = m_alloc_secure (strlen(fd_passwd)+1);
+ pw = xmalloc_secure (strlen(fd_passwd)+1);
strcpy (pw, fd_passwd);
}
else if (opt.batch)
@@ -861,7 +861,7 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo,
us = get_long_user_id_string( keyid );
write_status_text( STATUS_USERID_HINT, us );
- m_free(us);
+ xfree(us);
sprintf( buf, "%08lX%08lX %08lX%08lX %d 0",
(ulong)keyid[0], (ulong)keyid[1],
@@ -881,14 +881,14 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo,
ignore the passphrase cache (mode!=1), print a prompt with
information on that key. */
if( keyid && !opt.batch && !next_pw && mode!=1 ) {
- PKT_public_key *pk = m_alloc_clear( sizeof *pk );
+ PKT_public_key *pk = xmalloc_clear( sizeof *pk );
char *p;
p=get_user_id_native(keyid);
tty_printf("\n");
tty_printf(_("You need a passphrase to unlock the secret key for\n"
"user: \"%s\"\n"),p);
- m_free(p);
+ xfree(p);
if( !get_pubkey( pk, keyid ) ) {
const char *s = pubkey_algo_to_string( pk->pubkey_algo );
@@ -929,7 +929,7 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo,
{
if (!opt.use_agent)
goto agent_died;
- pw = m_strdup ("");
+ pw = xstrdup ("");
}
if( *pw && mode == 2 ) {
char *pw2 = agent_get_passphrase ( keyid, 2, NULL, NULL, NULL,
@@ -938,29 +938,29 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo,
{
if (!opt.use_agent)
{
- m_free (pw);
+ xfree (pw);
pw = NULL;
goto agent_died;
}
- pw2 = m_strdup ("");
+ pw2 = xstrdup ("");
}
if( strcmp(pw, pw2) ) {
- m_free(pw2);
- m_free(pw);
+ xfree(pw2);
+ xfree(pw);
return NULL;
}
- m_free(pw2);
+ xfree(pw2);
}
}
else if( fd_passwd ) {
/* Return the passphrase we have store in FD_PASSWD. */
- pw = m_alloc_secure( strlen(fd_passwd)+1 );
+ pw = xmalloc_secure( strlen(fd_passwd)+1 );
strcpy( pw, fd_passwd );
}
else if( opt.batch )
{
log_error(_("can't query passphrase in batch mode\n"));
- pw = m_strdup( "" ); /* return an empty passphrase */
+ pw = xstrdup( "" ); /* return an empty passphrase */
}
else {
/* Read the passphrase from the tty or the command-fd. */
@@ -971,11 +971,11 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo,
_("Repeat passphrase: ") );
tty_kill_prompt();
if( strcmp(pw, pw2) ) {
- m_free(pw2);
- m_free(pw);
+ xfree(pw2);
+ xfree(pw);
return NULL;
}
- m_free(pw2);
+ xfree(pw2);
}
}
@@ -985,13 +985,13 @@ passphrase_to_dek( u32 *keyid, int pubkey_algo,
/* Hash the passphrase and store it in a newly allocated DEK
object. Keep a copy of the passphrase in LAST_PW for use by
get_last_passphrase(). */
- dek = m_alloc_secure_clear ( sizeof *dek );
+ dek = xmalloc_secure_clear ( sizeof *dek );
dek->algo = cipher_algo;
if( !*pw && mode == 2 )
dek->keylen = 0;
else
hash_passphrase( dek, pw, s2k, mode==2 );
- m_free(last_pw);
+ xfree(last_pw);
last_pw = pw;
return dek;
}
diff --git a/g10/photoid.c b/g10/photoid.c
index 6457a48e9..aae983fe0 100644
--- a/g10/photoid.c
+++ b/g10/photoid.c
@@ -62,7 +62,7 @@ PKT_user_id *generate_photo_id(PKT_public_key *pk)
header[i]=0;
#define EXTRA_UID_NAME_SPACE 71
- uid=m_alloc_clear(sizeof(*uid)+71);
+ uid=xmalloc_clear(sizeof(*uid)+71);
tty_printf(_("\nPick an image to use for your photo ID. "
"The image must be a JPEG file.\n"
@@ -75,7 +75,7 @@ PKT_user_id *generate_photo_id(PKT_public_key *pk)
{
tty_printf("\n");
- m_free(filename);
+ xfree(filename);
filename=cpr_get("photoid.jpeg.add",
_("Enter JPEG filename for photo ID: "));
@@ -109,7 +109,7 @@ PKT_user_id *generate_photo_id(PKT_public_key *pk)
}
}
- photo=m_alloc(len);
+ photo=xmalloc(len);
iobuf_read(file,photo,len);
iobuf_close(file);
@@ -118,7 +118,7 @@ PKT_user_id *generate_photo_id(PKT_public_key *pk)
photo[6]!='J' || photo[7]!='F' || photo[8]!='I' || photo[9]!='F')
{
log_error(_("`%s' is not a JPEG file\n"),filename);
- m_free(photo);
+ xfree(photo);
photo=NULL;
continue;
}
@@ -140,7 +140,7 @@ PKT_user_id *generate_photo_id(PKT_public_key *pk)
goto scram;
case 0:
free_attributes(uid);
- m_free(photo);
+ xfree(photo);
photo=NULL;
continue;
}
@@ -151,13 +151,13 @@ PKT_user_id *generate_photo_id(PKT_public_key *pk)
uid->ref=1;
scram:
- m_free(filename);
- m_free(photo);
+ xfree(filename);
+ xfree(photo);
if(error)
{
free_attributes(uid);
- m_free(uid);
+ xfree(uid);
return NULL;
}
@@ -291,7 +291,7 @@ void show_photos(const struct user_attribute *attrs,
if(!command)
goto fail;
- name=m_alloc(16+strlen(EXTSEP_S)+
+ name=xmalloc(16+strlen(EXTSEP_S)+
strlen(image_type_to_string(args.imagetype,0))+1);
/* Make the filename. Notice we are not using the image
@@ -310,7 +310,7 @@ void show_photos(const struct user_attribute *attrs,
if(exec_write(&spawn,NULL,command,name,1,1)!=0)
{
- m_free(name);
+ xfree(name);
goto fail;
}
@@ -319,7 +319,7 @@ void show_photos(const struct user_attribute *attrs,
image_type_to_string(args.imagetype,2));
#endif
- m_free(name);
+ xfree(name);
fwrite(&attrs[i].data[offset],attrs[i].len-offset,1,spawn->tochild);
diff --git a/g10/pkclist.c b/g10/pkclist.c
index 452abe6f6..3967b59ec 100644
--- a/g10/pkclist.c
+++ b/g10/pkclist.c
@@ -217,7 +217,7 @@ do_edit_ownertrust (PKT_public_key *pk, int mode,
keystr(keyid), datestr_from_pk( pk ) );
p=get_user_id_native(keyid);
tty_printf(_(" \"%s\"\n"),p);
- m_free(p);
+ xfree(p);
keyblock = get_pubkeyblock (keyid);
if (!keyblock)
@@ -349,9 +349,9 @@ do_edit_ownertrust (PKT_public_key *pk, int mode,
quit = 1;
break ; /* back to the menu */
}
- m_free(p); p = NULL;
+ xfree(p); p = NULL;
}
- m_free(p);
+ xfree(p);
return show? -2: quit? -1 : changed;
}
@@ -484,7 +484,7 @@ do_we_trust_pre( PKT_public_key *pk, unsigned int trustlevel )
int
check_signatures_trust( PKT_signature *sig )
{
- PKT_public_key *pk = m_alloc_clear( sizeof *pk );
+ PKT_public_key *pk = xmalloc_clear( sizeof *pk );
unsigned int trustlevel;
int rc=0;
@@ -599,7 +599,7 @@ release_pk_list( PK_LIST pk_list )
for( ; pk_list; pk_list = pk_rover ) {
pk_rover = pk_list->next;
free_public_key( pk_list->pk );
- m_free( pk_list );
+ xfree( pk_list );
}
}
@@ -628,10 +628,10 @@ default_recipient(void)
int i;
if( opt.def_recipient )
- return m_strdup( opt.def_recipient );
+ return xstrdup( opt.def_recipient );
if( !opt.def_recipient_self )
return NULL;
- sk = m_alloc_clear( sizeof *sk );
+ sk = xmalloc_clear( sizeof *sk );
i = get_seckey_byname( sk, NULL, 0 );
if( i ) {
free_secret_key( sk );
@@ -640,7 +640,7 @@ default_recipient(void)
n = MAX_FINGERPRINT_LEN;
fingerprint_from_sk( sk, fpr, &n );
free_secret_key( sk );
- p = m_alloc( 2*n+3 );
+ p = xmalloc( 2*n+3 );
*p++ = '0';
*p++ = 'x';
for(i=0; i < n; i++ )
@@ -727,7 +727,7 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
}
}
else if( (use & PUBKEY_USAGE_ENC) && !opt.no_encrypt_to ) {
- pk = m_alloc_clear( sizeof *pk );
+ pk = xmalloc_clear( sizeof *pk );
pk->req_usage = use;
/* We can encrypt-to a disabled key */
if( (rc = get_pubkey_byname( pk, rov->d, NULL, NULL, 1 )) ) {
@@ -747,7 +747,7 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
}
else {
PK_LIST r;
- r = m_alloc( sizeof *r );
+ r = xmalloc( sizeof *r );
r->pk = pk; pk = NULL;
r->next = pk_list;
r->flags = (rov->flags&2)?1:0;
@@ -787,7 +787,7 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
"You did not specify a user ID. (you may use \"-r\")\n"));
for(;;) {
rc = 0;
- m_free(answer);
+ xfree(answer);
if( have_def_rec ) {
answer = def_rec;
def_rec = NULL;
@@ -820,7 +820,7 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
size_t n;
char *p = get_user_id( keyid, &n );
tty_print_utf8_string( p, n );
- m_free(p);
+ xfree(p);
}
tty_printf("\"\n");
}
@@ -831,14 +831,14 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
cpr_kill_prompt();
}
if( !answer || !*answer ) {
- m_free(answer);
+ xfree(answer);
break;
}
if(expand_id(answer,&backlog,0))
continue;
if( pk )
free_public_key( pk );
- pk = m_alloc_clear( sizeof *pk );
+ pk = xmalloc_clear( sizeof *pk );
pk->req_usage = use;
rc = get_pubkey_byname( pk, answer, NULL, NULL, 0 );
if( rc )
@@ -851,7 +851,7 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
"already set as default recipient\n") );
}
else {
- PK_LIST r = m_alloc( sizeof *r );
+ PK_LIST r = xmalloc( sizeof *r );
r->pk = pk; pk = NULL;
r->next = pk_list;
r->flags = 0; /* no throwing default ids */
@@ -876,7 +876,7 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
}
else {
PK_LIST r;
- r = m_alloc( sizeof *r );
+ r = xmalloc( sizeof *r );
r->pk = pk; pk = NULL;
r->next = pk_list;
r->flags = 0; /* no throwing interactive ids */
@@ -887,7 +887,7 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
}
}
}
- m_free(def_rec); def_rec = NULL;
+ xfree(def_rec); def_rec = NULL;
have_def_rec = 0;
}
if( pk ) {
@@ -896,7 +896,7 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
}
}
else if( !any_recipients && (def_rec = default_recipient()) ) {
- pk = m_alloc_clear( sizeof *pk );
+ pk = xmalloc_clear( sizeof *pk );
pk->req_usage = use;
/* The default recipient may be disabled */
rc = get_pubkey_byname( pk, def_rec, NULL, NULL, 1 );
@@ -911,7 +911,7 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
if (key_present_in_pk_list(pk_list, pk) == 0)
log_info(_("skipped: public key already set as default recipient\n"));
else {
- PK_LIST r = m_alloc( sizeof *r );
+ PK_LIST r = xmalloc( sizeof *r );
r->pk = pk; pk = NULL;
r->next = pk_list;
r->flags = 0; /* no throwing default ids */
@@ -922,7 +922,7 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
free_public_key( pk );
pk = NULL;
}
- m_free(def_rec); def_rec = NULL;
+ xfree(def_rec); def_rec = NULL;
}
else {
any_recipients = 0;
@@ -930,7 +930,7 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
if( (remusr->flags & 1) )
continue; /* encrypt-to keys are already handled */
- pk = m_alloc_clear( sizeof *pk );
+ pk = xmalloc_clear( sizeof *pk );
pk->req_usage = use;
if( (rc = get_pubkey_byname( pk, remusr->d, NULL, NULL, 0 )) ) {
free_public_key( pk ); pk = NULL;
@@ -971,7 +971,7 @@ build_pk_list( STRLIST rcpts, PK_LIST *ret_pk_list, unsigned use )
}
else {
PK_LIST r;
- r = m_alloc( sizeof *r );
+ r = xmalloc( sizeof *r );
r->pk = pk; pk = NULL;
r->next = pk_list;
r->flags = (remusr->flags&2)?1:0;
diff --git a/g10/plaintext.c b/g10/plaintext.c
index 0b869e4c8..e3ea3695e 100644
--- a/g10/plaintext.c
+++ b/g10/plaintext.c
@@ -84,7 +84,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
if( nooutput )
;
else if( opt.outfile ) {
- fname = m_alloc( strlen( opt.outfile ) + 1);
+ fname = xmalloc( strlen( opt.outfile ) + 1);
strcpy(fname, opt.outfile );
}
else if( pt->namelen == 8 && !memcmp( pt->name, "_CONSOLE", 8 ) ) {
@@ -118,11 +118,11 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
while( !overwrite_filep (fname) ) {
char *tmp = ask_outfile_name (NULL, 0);
if ( !tmp || !*tmp ) {
- m_free (tmp);
+ xfree (tmp);
rc = G10ERR_CREATE_FILE;
goto leave;
}
- m_free (fname);
+ xfree (fname);
fname = tmp;
}
}
@@ -213,7 +213,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
}
}
else { /* binary mode */
- byte *buffer = m_alloc( 32768 );
+ byte *buffer = xmalloc( 32768 );
while( pt->len ) {
int len = pt->len > 32768 ? 32768 : pt->len;
len = iobuf_read( pt->buf, buffer, len );
@@ -221,7 +221,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
log_error("Problem reading source (%u bytes remaining)\n",
(unsigned)pt->len);
rc = G10ERR_READ_FILE;
- m_free( buffer );
+ xfree( buffer );
goto leave;
}
if( mfx->md )
@@ -233,7 +233,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
log_error("Error writing to `%s': %s\n",
fname,"exceeded --max-output limit\n");
rc = G10ERR_WRITE_FILE;
- m_free( buffer );
+ xfree( buffer );
goto leave;
}
else if( fwrite( buffer, 1, len, fp ) != len )
@@ -241,13 +241,13 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
log_error("Error writing to `%s': %s\n",
fname, strerror(errno) );
rc = G10ERR_WRITE_FILE;
- m_free( buffer );
+ xfree( buffer );
goto leave;
}
}
pt->len -= len;
}
- m_free( buffer );
+ xfree( buffer );
}
}
else if( !clearsig ) {
@@ -279,7 +279,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
}
}
else { /* binary mode */
- byte *buffer = m_alloc( 32768 );
+ byte *buffer = xmalloc( 32768 );
int eof;
for( eof=0; !eof; ) {
/* Why do we check for len < 32768:
@@ -302,19 +302,19 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
log_error("Error writing to `%s': %s\n",
fname,"exceeded --max-output limit\n");
rc = G10ERR_WRITE_FILE;
- m_free( buffer );
+ xfree( buffer );
goto leave;
}
else if( fwrite( buffer, 1, len, fp ) != len ) {
log_error("Error writing to `%s': %s\n",
fname, strerror(errno) );
rc = G10ERR_WRITE_FILE;
- m_free( buffer );
+ xfree( buffer );
goto leave;
}
}
}
- m_free( buffer );
+ xfree( buffer );
}
pt->buf = NULL;
}
@@ -382,7 +382,7 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
leave:
if( fp && fp != stdout )
fclose(fp);
- m_free(fname);
+ xfree(fname);
return rc;
}
@@ -446,7 +446,7 @@ ask_for_detached_datafile( MD_HANDLE md, MD_HANDLE md2,
int any=0;
tty_printf(_("Detached signature.\n"));
do {
- m_free(answer);
+ xfree(answer);
tty_enable_completion(NULL);
answer = cpr_get("detached_signature.filename",
_("Please enter name of data file: "));
@@ -486,7 +486,7 @@ ask_for_detached_datafile( MD_HANDLE md, MD_HANDLE md2,
iobuf_close(fp);
leave:
- m_free(answer);
+ xfree(answer);
return rc;
}
diff --git a/g10/progress.c b/g10/progress.c
index 0f42aae79..a2141e4cb 100644
--- a/g10/progress.c
+++ b/g10/progress.c
@@ -87,7 +87,7 @@ progress_filter (void *opaque, int control,
/* Note, that we must always dealloc resources of a filter
within the filter handler and not anywhere else. (We set it
to NULL and check all uses just in case.) */
- m_free (pfx->what);
+ xfree (pfx->what);
pfx->what = NULL;
}
else if (control == IOBUFCTRL_DESC)
@@ -112,7 +112,7 @@ handle_progress (progress_filter_context_t *pfx, IOBUF inp, const char *name)
filesize = opt.set_filesize;
/* register the progress filter */
- pfx->what = m_strdup (name ? name : "stdin");
+ pfx->what = xstrdup (name ? name : "stdin");
pfx->total = filesize;
iobuf_push_filter (inp, progress_filter, pfx);
}
diff --git a/g10/pubkey-enc.c b/g10/pubkey-enc.c
index a3a60e1e6..ad2bea64d 100644
--- a/g10/pubkey-enc.c
+++ b/g10/pubkey-enc.c
@@ -79,7 +79,7 @@ get_session_key( PKT_pubkey_enc *k, DEK *dek )
goto leave;
if( (k->keyid[0] || k->keyid[1]) && !opt.try_all_secrets ) {
- sk = m_alloc_clear( sizeof *sk );
+ sk = xmalloc_clear( sizeof *sk );
sk->pubkey_algo = k->pubkey_algo; /* we want a pubkey with this algo*/
if( !(rc = get_seckey( sk, k->keyid )) )
rc = get_it( k, dek, sk, k->keyid );
@@ -92,7 +92,7 @@ get_session_key( PKT_pubkey_enc *k, DEK *dek )
for(;;) {
if( sk )
free_secret_key( sk );
- sk = m_alloc_clear( sizeof *sk );
+ sk = xmalloc_clear( sizeof *sk );
rc=enum_secret_keys( &enum_context, sk, 1, 0);
if( rc ) {
rc = G10ERR_NO_SECKEY;
@@ -108,7 +108,7 @@ get_session_key( PKT_pubkey_enc *k, DEK *dek )
{
p=get_last_passphrase();
set_next_passphrase(p);
- m_free(p);
+ xfree(p);
}
rc = check_secret_key( sk, opt.try_all_secrets?1:-1 ); /* ask
@@ -302,7 +302,7 @@ get_it( PKT_pubkey_enc *enc, DEK *dek, PKT_secret_key *sk, u32 *keyid )
leave:
mpi_free(plain_dek);
- m_free(frame);
+ xfree(frame);
return rc;
}
diff --git a/g10/revoke.c b/g10/revoke.c
index 7ffb5c7e8..aadb1824e 100644
--- a/g10/revoke.c
+++ b/g10/revoke.c
@@ -61,15 +61,15 @@ revocation_reason_build_cb( PKT_signature *sig, void *opaque )
ud = native_to_utf8( reason->desc );
buflen += strlen(ud);
}
- buffer = m_alloc( buflen );
+ buffer = xmalloc( buflen );
*buffer = reason->code;
if( ud ) {
memcpy(buffer+1, ud, strlen(ud) );
- m_free( ud );
+ xfree( ud );
}
build_sig_subpkt( sig, SIGSUBPKT_REVOC_REASON, buffer, buflen );
- m_free( buffer );
+ xfree( buffer );
return 0;
}
@@ -256,7 +256,7 @@ gen_desig_revoke( const char *uname )
if(sk)
free_secret_key(sk);
- sk=m_alloc_clear(sizeof(*sk));
+ sk=xmalloc_clear(sizeof(*sk));
rc=get_seckey_byfprint(sk,pk->revkey[i].fpr,MAX_FINGERPRINT_LEN);
@@ -452,7 +452,7 @@ gen_revoke( const char *uname )
keyid_from_sk( sk, sk_keyid );
print_seckey_info (sk);
- pk = m_alloc_clear( sizeof *pk );
+ pk = xmalloc_clear( sizeof *pk );
/* FIXME: We should get the public key direct from the secret one */
@@ -587,7 +587,7 @@ ask_revocation_reason( int key_rev, int cert_rev, int hint )
do {
code=-1;
- m_free(description);
+ xfree(description);
description = NULL;
tty_printf(_("Please select the reason for the revocation:\n"));
@@ -618,7 +618,7 @@ ask_revocation_reason( int key_rev, int cert_rev, int hint )
n = -1;
else
n = atoi(answer);
- m_free(answer);
+ xfree(answer);
if( n == 0 ) {
code = 0x00; /* no particular reason */
code_text = text_0;
@@ -650,25 +650,25 @@ ask_revocation_reason( int key_rev, int cert_rev, int hint )
trim_trailing_ws( answer, strlen(answer) );
cpr_kill_prompt();
if( !*answer ) {
- m_free(answer);
+ xfree(answer);
break;
}
{
char *p = make_printable_string( answer, strlen(answer), 0 );
- m_free(answer);
+ xfree(answer);
answer = p;
}
if( !description )
- description = m_strdup(answer);
+ description = xstrdup(answer);
else {
- char *p = m_alloc( strlen(description) + strlen(answer) + 2 );
+ char *p = xmalloc( strlen(description) + strlen(answer) + 2 );
strcpy(stpcpy(stpcpy( p, description),"\n"),answer);
- m_free(description);
+ xfree(description);
description = p;
}
- m_free(answer);
+ xfree(answer);
}
tty_printf(_("Reason for revocation: %s\n"), code_text );
@@ -680,7 +680,7 @@ ask_revocation_reason( int key_rev, int cert_rev, int hint )
} while( !cpr_get_answer_is_yes("ask_revocation_reason.okay",
_("Is this okay? (y/N) ")) );
- reason = m_alloc( sizeof *reason );
+ reason = xmalloc( sizeof *reason );
reason->code = code;
reason->desc = description;
return reason;
@@ -690,7 +690,7 @@ void
release_revocation_reason_info( struct revocation_reason_info *reason )
{
if( reason ) {
- m_free( reason->desc );
- m_free( reason );
+ xfree( reason->desc );
+ xfree( reason );
}
}
diff --git a/g10/seckey-cert.c b/g10/seckey-cert.c
index aca29e348..afa071fdf 100644
--- a/g10/seckey-cert.c
+++ b/g10/seckey-cert.c
@@ -88,7 +88,7 @@ do_check( PKT_secret_key *sk, const char *tryagain_text, int mode,
cipher_hd = cipher_open( sk->protect.algo,
CIPHER_MODE_AUTO_CFB, 1);
cipher_setkey( cipher_hd, dek->key, dek->keylen );
- m_free(dek);
+ xfree(dek);
save_sk = copy_secret_key( NULL, sk );
cipher_setiv( cipher_hd, sk->protect.iv, sk->protect.ivlen );
csum = 0;
@@ -102,7 +102,7 @@ do_check( PKT_secret_key *sk, const char *tryagain_text, int mode,
p = mpi_get_opaque( sk->skey[i], &ndata );
if ( ndata > 1 )
csumc = p[ndata-2] << 8 | p[ndata-1];
- data = m_alloc_secure( ndata );
+ data = xmalloc_secure( ndata );
cipher_decrypt( cipher_hd, data, p, ndata );
mpi_free( sk->skey[i] ); sk->skey[i] = NULL ;
p = data;
@@ -168,7 +168,7 @@ do_check( PKT_secret_key *sk, const char *tryagain_text, int mode,
/* Note: at this point ndata should be 2 for a simple
checksum or 20 for the sha1 digest */
}
- m_free(data);
+ xfree(data);
}
else {
for(i=pubkey_get_npkey(sk->pubkey_algo);
@@ -180,7 +180,7 @@ do_check( PKT_secret_key *sk, const char *tryagain_text, int mode,
p = mpi_get_opaque (sk->skey[i], &ndata);
assert (ndata >= 2);
assert (ndata == ((p[0] << 8 | p[1]) + 7)/8 + 2);
- buffer = m_alloc_secure (ndata);
+ buffer = xmalloc_secure (ndata);
cipher_sync (cipher_hd);
buffer[0] = p[0];
buffer[1] = p[1];
@@ -188,7 +188,7 @@ do_check( PKT_secret_key *sk, const char *tryagain_text, int mode,
csum += checksum (buffer, ndata);
mpi_free (sk->skey[i]);
sk->skey[i] = mpi_read_from_buffer (buffer, &ndata, 1);
- m_free (buffer);
+ xfree (buffer);
if (!sk->skey[i])
{
/* Checksum was okay, but not correctly
@@ -350,7 +350,7 @@ protect_secret_key( PKT_secret_key *sk, DEK *dek )
bufarr[j] = NULL;
ndata += opt.simple_sk_checksum? 2 : 20; /* for checksum */
- data = m_alloc_secure( ndata );
+ data = xmalloc_secure( ndata );
p = data;
for(j=0; j < PUBKEY_MAX_NSKEY && bufarr[j]; j++ ) {
p[0] = nbits[j] >> 8 ;
@@ -358,7 +358,7 @@ protect_secret_key( PKT_secret_key *sk, DEK *dek )
p += 2;
memcpy(p, bufarr[j], narr[j] );
p += narr[j];
- m_free(bufarr[j]);
+ xfree(bufarr[j]);
}
if (opt.simple_sk_checksum) {
@@ -404,13 +404,13 @@ protect_secret_key( PKT_secret_key *sk, DEK *dek )
buffer = mpi_get_buffer( sk->skey[i], &nbytes, NULL );
cipher_sync (cipher_hd);
assert ( !mpi_is_opaque (sk->skey[i]) );
- data = m_alloc (nbytes+2);
+ data = xmalloc (nbytes+2);
nbits = mpi_get_nbits (sk->skey[i]);
assert (nbytes == (nbits + 7)/8);
data[0] = nbits >> 8;
data[1] = nbits;
cipher_encrypt (cipher_hd, data+2, buffer, nbytes);
- m_free( buffer );
+ xfree( buffer );
mpi_free (sk->skey[i]);
sk->skey[i] = mpi_set_opaque (NULL, data, nbytes+2);
diff --git a/g10/seskey.c b/g10/seskey.c
index 7ed20d92c..adf85c97f 100644
--- a/g10/seskey.c
+++ b/g10/seskey.c
@@ -100,7 +100,7 @@ encode_session_key( DEK *dek, unsigned nbits )
for( p = dek->key, i=0; i < dek->keylen; i++ )
csum += *p++;
- frame = m_alloc_secure( nframe );
+ frame = xmalloc_secure( nframe );
n = 0;
frame[n++] = 0;
frame[n++] = 2;
@@ -126,10 +126,10 @@ encode_session_key( DEK *dek, unsigned nbits )
if (p[j])
j++;
}
- m_free(pp);
+ xfree(pp);
}
memcpy( frame+n, p, i );
- m_free(p);
+ xfree(p);
n += i;
frame[n++] = 0;
frame[n++] = dek->algo;
@@ -139,7 +139,7 @@ encode_session_key( DEK *dek, unsigned nbits )
assert( n == nframe );
a = mpi_alloc_secure( (nframe+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB );
mpi_set_buffer( a, frame, nframe, 0 );
- m_free(frame);
+ xfree(frame);
return a;
}
@@ -163,7 +163,7 @@ do_encode_md( MD_HANDLE md, int algo, size_t len, unsigned nbits,
*
* PAD consists of FF bytes.
*/
- frame = md_is_secure(md)? m_alloc_secure( nframe ) : m_alloc( nframe );
+ frame = md_is_secure(md)? xmalloc_secure( nframe ) : xmalloc( nframe );
n = 0;
frame[n++] = 0;
frame[n++] = 1; /* block type */
@@ -178,7 +178,7 @@ do_encode_md( MD_HANDLE md, int algo, size_t len, unsigned nbits,
mpi_alloc_secure( (nframe+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB )
: mpi_alloc( (nframe+BYTES_PER_MPI_LIMB-1) / BYTES_PER_MPI_LIMB );
mpi_set_buffer( a, frame, nframe, 0 );
- m_free(frame);
+ xfree(frame);
/* Note that PGP before version 2.3 encoded the MD as:
*
diff --git a/g10/sig-check.c b/g10/sig-check.c
index 2f2199ad7..606c38d0b 100644
--- a/g10/sig-check.c
+++ b/g10/sig-check.c
@@ -59,7 +59,7 @@ int
signature_check2( PKT_signature *sig, MD_HANDLE digest, u32 *r_expiredate,
int *r_expired, int *r_revoked, PKT_public_key *ret_pk )
{
- PKT_public_key *pk = m_alloc_clear( sizeof *pk );
+ PKT_public_key *pk = xmalloc_clear( sizeof *pk );
int rc=0;
if( (rc=check_digest_algo(sig->digest_algo)) )
@@ -134,16 +134,16 @@ signature_check2( PKT_signature *sig, MD_HANDLE digest, u32 *r_expiredate,
md_putc( md, n );
p = mpi_get_buffer( sig->data[i], &n, NULL );
md_write( md, p, n );
- m_free(p);
+ xfree(p);
}
md_final( md );
p = make_radix64_string( md_read( md, 0 ), 20 );
- buffer = m_alloc( strlen(p) + 60 );
+ buffer = xmalloc( strlen(p) + 60 );
sprintf( buffer, "%s %s %lu",
p, strtimestamp( sig->timestamp ), (ulong)sig->timestamp );
write_status_text( STATUS_SIG_ID, buffer );
- m_free(buffer);
- m_free(p);
+ xfree(buffer);
+ xfree(p);
md_close(md);
}
diff --git a/g10/sign.c b/g10/sign.c
index e5c5cbfa0..0e8be714f 100644
--- a/g10/sign.c
+++ b/g10/sign.c
@@ -112,11 +112,11 @@ mk_notation_policy_etc( PKT_signature *sig,
{
log_error(_("WARNING: unable to %%-expand notation "
"(too large). Using unexpanded.\n"));
- expanded=m_strdup(s);
+ expanded=xstrdup(s);
}
n2 = strlen(expanded);
- buf = m_alloc( 8 + n1 + n2 );
+ buf = xmalloc( 8 + n1 + n2 );
buf[0] = 0x80; /* human readable */
buf[1] = buf[2] = buf[3] = 0;
buf[4] = n1 >> 8;
@@ -128,8 +128,8 @@ mk_notation_policy_etc( PKT_signature *sig,
build_sig_subpkt( sig, SIGSUBPKT_NOTATION
| ((nd->flags & 1)? SIGSUBPKT_FLAG_CRITICAL:0),
buf, 8+n1+n2 );
- m_free(expanded);
- m_free(buf);
+ xfree(expanded);
+ xfree(buf);
}
/* set policy URL */
@@ -159,14 +159,14 @@ mk_notation_policy_etc( PKT_signature *sig,
{
log_error(_("WARNING: unable to %%-expand policy URL "
"(too large). Using unexpanded.\n"));
- s=m_strdup(string);
+ s=xstrdup(string);
}
build_sig_subpkt(sig,SIGSUBPKT_POLICY|
((pu->flags & 1)?SIGSUBPKT_FLAG_CRITICAL:0),
s,strlen(s));
- m_free(s);
+ xfree(s);
}
/* preferred keyserver URL */
@@ -187,14 +187,14 @@ mk_notation_policy_etc( PKT_signature *sig,
{
log_error(_("WARNING: unable to %%-expand preferred keyserver URL"
" (too large). Using unexpanded.\n"));
- s=m_strdup(string);
+ s=xstrdup(string);
}
build_sig_subpkt(sig,SIGSUBPKT_PREF_KS|
((pu->flags & 1)?SIGSUBPKT_FLAG_CRITICAL:0),
s,strlen(s));
- m_free(s);
+ xfree(s);
}
}
@@ -346,7 +346,7 @@ do_sign( PKT_secret_key *sk, PKT_signature *sig,
/* check that the signature verification worked and nothing is
* fooling us e.g. by a bug in the signature create
* code or by deliberately introduced faults. */
- PKT_public_key *pk = m_alloc_clear (sizeof *pk);
+ PKT_public_key *pk = xmalloc_clear (sizeof *pk);
if( get_pubkey( pk, sig->keyid ) )
rc = G10ERR_NO_PUBKEY;
@@ -375,7 +375,7 @@ do_sign( PKT_secret_key *sk, PKT_signature *sig,
pubkey_algo_to_string(sk->pubkey_algo),
digest_algo_to_string(sig->digest_algo),
ustr );
- m_free(ustr);
+ xfree(ustr);
}
}
return rc;
@@ -509,7 +509,7 @@ write_onepass_sig_packets (SK_LIST sk_list, IOBUF out, int sigclass )
}
sk = sk_rover->sk;
- ops = m_alloc_clear (sizeof *ops);
+ ops = xmalloc_clear (sizeof *ops);
ops->sig_class = sigclass;
ops->digest_algo = hash_for (sk->pubkey_algo, sk->version);
ops->pubkey_algo = sk->pubkey_algo;
@@ -546,13 +546,13 @@ write_plaintext_packet (IOBUF out, IOBUF inp, const char *fname, int ptmode)
char *s = make_basename (opt.set_filename? opt.set_filename
: fname,
iobuf_get_real_fname(inp));
- pt = m_alloc (sizeof *pt + strlen(s) - 1);
+ pt = xmalloc (sizeof *pt + strlen(s) - 1);
pt->namelen = strlen (s);
memcpy (pt->name, s, pt->namelen);
- m_free (s);
+ xfree (s);
}
else { /* no filename */
- pt = m_alloc (sizeof *pt - 1);
+ pt = xmalloc (sizeof *pt - 1);
pt->namelen = 0;
}
}
@@ -640,7 +640,7 @@ write_signature_packets (SK_LIST sk_list, IOBUF out, MD_HANDLE hash,
sk = sk_rover->sk;
/* build the signature packet */
- sig = m_alloc_clear (sizeof *sig);
+ sig = xmalloc_clear (sizeof *sig);
if(opt.force_v3_sigs || RFC1991)
sig->version=3;
else if(duration || opt.sig_policy_url
@@ -1203,7 +1203,7 @@ sign_symencrypt_file (const char *fname, STRLIST locusr)
handle_progress (&pfx, inp, fname);
/* prepare key */
- s2k = m_alloc_clear( sizeof *s2k );
+ s2k = xmalloc_clear( sizeof *s2k );
s2k->mode = RFC1991? 0:opt.s2k_mode;
s2k->hash_algo = S2K_DIGEST_ALGO;
@@ -1252,7 +1252,7 @@ sign_symencrypt_file (const char *fname, STRLIST locusr)
/* Write the symmetric key packet */
/*(current filters: armor)*/
if (!RFC1991) {
- PKT_symkey_enc *enc = m_alloc_clear( sizeof *enc );
+ PKT_symkey_enc *enc = xmalloc_clear( sizeof *enc );
enc->version = 4;
enc->cipher_algo = cfx.dek->algo;
enc->s2k = *s2k;
@@ -1260,7 +1260,7 @@ sign_symencrypt_file (const char *fname, STRLIST locusr)
pkt.pkt.symkey_enc = enc;
if( (rc = build_packet( out, &pkt )) )
log_error("build symkey packet failed: %s\n", g10_errstr(rc) );
- m_free(enc);
+ xfree(enc);
}
/* Push the encryption filter */
@@ -1304,8 +1304,8 @@ sign_symencrypt_file (const char *fname, STRLIST locusr)
iobuf_close(inp);
release_sk_list( sk_list );
md_close( mfx.md );
- m_free(cfx.dek);
- m_free(s2k);
+ xfree(cfx.dek);
+ xfree(s2k);
return rc;
}
@@ -1386,7 +1386,7 @@ make_keysig_packet( PKT_signature **ret_sig, PKT_public_key *pk,
hash_uid (md, sigversion, uid);
}
/* and make the signature packet */
- sig = m_alloc_clear( sizeof *sig );
+ sig = xmalloc_clear( sizeof *sig );
sig->version = sigversion;
sig->flags.exportable=1;
sig->flags.revocable=1;
diff --git a/g10/skclist.c b/g10/skclist.c
index abe8fbc37..21db10c6e 100644
--- a/g10/skclist.c
+++ b/g10/skclist.c
@@ -44,7 +44,7 @@ release_sk_list( SK_LIST sk_list )
for( ; sk_list; sk_list = sk_rover ) {
sk_rover = sk_list->next;
free_secret_key( sk_list->sk );
- m_free( sk_list );
+ xfree( sk_list );
}
}
@@ -112,7 +112,7 @@ build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list,
{ /* use the default one */
PKT_secret_key *sk;
- sk = m_alloc_clear( sizeof *sk );
+ sk = xmalloc_clear( sizeof *sk );
sk->req_usage = use;
if( (rc = get_seckey_byname( sk, NULL, unlock )) ) {
free_secret_key( sk ); sk = NULL;
@@ -130,7 +130,7 @@ build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list,
}
else
{
- r = m_alloc( sizeof *r );
+ r = xmalloc( sizeof *r );
r->sk = sk; sk = NULL;
r->next = sk_list;
r->mark = 0;
@@ -158,7 +158,7 @@ build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list,
log_error(_("skipped \"%s\": duplicated\n"), locusr->d );
continue;
}
- sk = m_alloc_clear( sizeof *sk );
+ sk = xmalloc_clear( sizeof *sk );
sk->req_usage = use;
if( (rc = get_seckey_byname( sk, locusr->d, 0 )) )
{
@@ -193,7 +193,7 @@ build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list,
free_secret_key( sk ); sk = NULL;
}
else {
- r = m_alloc( sizeof *r );
+ r = xmalloc( sizeof *r );
r->sk = sk; sk = NULL;
r->next = sk_list;
r->mark = 0;
diff --git a/g10/status.c b/g10/status.c
index 6ef5e7eec..f7183ae42 100644
--- a/g10/status.c
+++ b/g10/status.c
@@ -501,7 +501,7 @@ do_shm_get( const char *keyword, int hidden, int bool )
if( bool )
return p[0]? "" : NULL;
- string = hidden? m_alloc_secure( n+1 ) : m_alloc( n+1 );
+ string = hidden? xmalloc_secure( n+1 ) : xmalloc( n+1 );
memcpy(string, p, n );
string[n] = 0; /* make sure it is a string */
if( hidden ) /* invalidate the memory */
@@ -559,7 +559,7 @@ do_get_from_fd( const char *keyword, int hidden, int bool )
if( i >= len-1 ) {
char *save = string;
len += 100;
- string = hidden? m_alloc_secure ( len ) : m_alloc ( len );
+ string = hidden? xmalloc_secure ( len ) : xmalloc ( len );
if( save )
memcpy(string, save, i );
else
@@ -630,7 +630,7 @@ cpr_get( const char *keyword, const char *prompt )
for(;;) {
p = tty_get( prompt );
if( *p=='?' && !p[1] && !(keyword && !*keyword)) {
- m_free(p);
+ xfree(p);
display_online_help( keyword );
}
else
@@ -646,7 +646,7 @@ cpr_get_utf8( const char *keyword, const char *prompt )
p = cpr_get( keyword, prompt );
if( p ) {
char *utf8 = native_to_utf8( p );
- m_free( p );
+ xfree( p );
p = utf8;
}
return p;
@@ -666,7 +666,7 @@ cpr_get_hidden( const char *keyword, const char *prompt )
for(;;) {
p = tty_get_hidden( prompt );
if( *p == '?' && !p[1] ) {
- m_free(p);
+ xfree(p);
display_online_help( keyword );
}
else
@@ -703,13 +703,13 @@ cpr_get_answer_is_yes( const char *keyword, const char *prompt )
p = tty_get( prompt );
trim_spaces(p); /* it is okay to do this here */
if( *p == '?' && !p[1] ) {
- m_free(p);
+ xfree(p);
display_online_help( keyword );
}
else {
tty_kill_prompt();
yes = answer_is_yes(p);
- m_free(p);
+ xfree(p);
return yes;
}
}
@@ -731,13 +731,13 @@ cpr_get_answer_yes_no_quit( const char *keyword, const char *prompt )
p = tty_get( prompt );
trim_spaces(p); /* it is okay to do this here */
if( *p == '?' && !p[1] ) {
- m_free(p);
+ xfree(p);
display_online_help( keyword );
}
else {
tty_kill_prompt();
yes = answer_is_yes_no_quit(p);
- m_free(p);
+ xfree(p);
return yes;
}
}
@@ -763,7 +763,7 @@ cpr_get_answer_okay_cancel (const char *keyword,
if (answer)
{
yes = answer_is_okay_cancel (answer, def_answer);
- m_free (answer);
+ xfree (answer);
return yes;
}
@@ -773,14 +773,14 @@ cpr_get_answer_okay_cancel (const char *keyword,
trim_spaces(p); /* it is okay to do this here */
if (*p == '?' && !p[1])
{
- m_free(p);
+ xfree(p);
display_online_help (keyword);
}
else
{
tty_kill_prompt();
yes = answer_is_okay_cancel (p, def_answer);
- m_free(p);
+ xfree(p);
return yes;
}
}
diff --git a/g10/tdbio.c b/g10/tdbio.c
index a5b30ead6..fbd569dd2 100644
--- a/g10/tdbio.c
+++ b/g10/tdbio.c
@@ -188,7 +188,7 @@ put_record_into_cache( ulong recno, const char *data )
}
/* see whether we reached the limit */
if( cache_entries < MAX_CACHE_ENTRIES_SOFT ) { /* no */
- r = m_alloc( sizeof *r );
+ r = xmalloc( sizeof *r );
r->flags.used = 1;
r->recno = recno;
memcpy( r->data, data, TRUST_RECORD_LEN );
@@ -231,7 +231,7 @@ put_record_into_cache( ulong recno, const char *data )
if( cache_entries < MAX_CACHE_ENTRIES_HARD ) { /* no */
if( opt.debug && !(cache_entries % 100) )
log_debug("increasing tdbio cache size\n");
- r = m_alloc( sizeof *r );
+ r = xmalloc( sizeof *r );
r->flags.used = 1;
r->recno = recno;
memcpy( r->data, data, TRUST_RECORD_LEN );
@@ -491,12 +491,12 @@ tdbio_set_dbname( const char *new_dbname, int create )
fname = make_filename (opt.homedir, new_dbname, NULL);
}
else
- fname = m_strdup (new_dbname);
+ fname = xstrdup (new_dbname);
if( access( fname, R_OK ) ) {
if( errno != ENOENT ) {
log_error( _("can't access `%s': %s\n"), fname, strerror(errno) );
- m_free(fname);
+ xfree(fname);
return G10ERR_TRUSTDB;
}
if( create ) {
@@ -514,7 +514,7 @@ tdbio_set_dbname( const char *new_dbname, int create )
}
*p = DIRSEP_C;
- m_free(db_name);
+ xfree(db_name);
db_name = fname;
#ifdef __riscos__
if( !lockhandle )
@@ -560,7 +560,7 @@ tdbio_set_dbname( const char *new_dbname, int create )
return 0;
}
}
- m_free(db_name);
+ xfree(db_name);
db_name = fname;
return 0;
}
@@ -1528,7 +1528,7 @@ migrate_from_v2 ()
int rc, count;
ottable_size = 5;
- ottable = m_alloc (ottable_size * sizeof *ottable);
+ ottable = xmalloc (ottable_size * sizeof *ottable);
ottable_used = 0;
/* We have some restrictions here. We can't use the version record
@@ -1558,7 +1558,7 @@ migrate_from_v2 ()
if (ottable_used == ottable_size)
{
ottable_size += 1000;
- ottable = m_realloc (ottable, ottable_size * sizeof *ottable);
+ ottable = xrealloc (ottable, ottable_size * sizeof *ottable);
}
ottable[ottable_used].keyrecno = buftoulong (oldbuf+6);
ottable[ottable_used].ot = oldbuf[18];
@@ -1629,5 +1629,5 @@ migrate_from_v2 ()
if (rc)
log_fatal ("failed to sync `%s'\n", db_name);
log_info ("migrated %d version 2 ownertrusts\n", count);
- m_free (ottable);
+ xfree (ottable);
}
diff --git a/g10/textfilter.c b/g10/textfilter.c
index 3694cb33a..78c2bf7c1 100644
--- a/g10/textfilter.c
+++ b/g10/textfilter.c
@@ -147,7 +147,7 @@ text_filter( void *opaque, int control,
if( tfx->truncated )
log_error(_("can't handle text lines longer than %d characters\n"),
MAX_LINELEN );
- m_free( tfx->buffer );
+ xfree( tfx->buffer );
tfx->buffer = NULL;
}
else if( control == IOBUFCTRL_DESC )
diff --git a/g10/trustdb.c b/g10/trustdb.c
index 518ccd332..de39b54de 100644
--- a/g10/trustdb.c
+++ b/g10/trustdb.c
@@ -99,7 +99,7 @@ new_key_item (void)
{
struct key_item *k;
- k = m_alloc_clear (sizeof *k);
+ k = xmalloc_clear (sizeof *k);
return k;
}
@@ -111,8 +111,8 @@ release_key_items (struct key_item *k)
for (; k; k = k2)
{
k2 = k->next;
- m_free (k->trust_regexp);
- m_free (k);
+ xfree (k->trust_regexp);
+ xfree (k);
}
}
@@ -129,7 +129,7 @@ new_key_hash_table (void)
{
struct key_item **tbl;
- tbl = m_alloc_clear (1024 * sizeof *tbl);
+ tbl = xmalloc_clear (1024 * sizeof *tbl);
return tbl;
}
@@ -142,7 +142,7 @@ release_key_hash_table (KeyHashTable tbl)
return;
for (i=0; i < 1024; i++)
release_key_items (tbl[i]);
- m_free (tbl);
+ xfree (tbl);
}
/*
@@ -189,7 +189,7 @@ release_key_array ( struct key_array *keys )
if (keys) {
for (k=keys; k->keyblock; k++)
release_kbnode (k->keyblock);
- m_free (keys);
+ xfree (keys);
}
}
@@ -409,7 +409,7 @@ setup_trustdb( int level, const char *dbname )
if( trustdb_args.init )
return 0;
trustdb_args.level = level;
- trustdb_args.dbname = dbname? m_strdup(dbname): NULL;
+ trustdb_args.dbname = dbname? xstrdup(dbname): NULL;
return 0;
}
@@ -832,7 +832,7 @@ update_min_ownertrust (u32 *kid, unsigned int new_trust )
TRUSTREC rec;
int rc;
- pk = m_alloc_clear (sizeof *pk);
+ pk = xmalloc_clear (sizeof *pk);
rc = get_pubkey (pk, kid);
if (rc)
{
@@ -1066,14 +1066,14 @@ get_validity (PKT_public_key *pk, PKT_user_id *uid)
keyid_from_pk (pk, kid);
if (pk->main_keyid[0] != kid[0] || pk->main_keyid[1] != kid[1])
{ /* this is a subkey - get the mainkey */
- main_pk = m_alloc_clear (sizeof *main_pk);
+ main_pk = xmalloc_clear (sizeof *main_pk);
rc = get_pubkey (main_pk, pk->main_keyid);
if (rc)
{
- char *tempkeystr=m_strdup(keystr(pk->main_keyid));
+ char *tempkeystr=xstrdup(keystr(pk->main_keyid));
log_error ("error getting main key %s of subkey %s: %s\n",
tempkeystr, keystr(kid), g10_errstr(rc));
- m_free(tempkeystr);
+ xfree(tempkeystr);
validity = TRUST_UNKNOWN;
goto leave;
}
@@ -1270,7 +1270,7 @@ ask_ownertrust (u32 *kid,int minimum)
int rc;
int ot;
- pk = m_alloc_clear (sizeof *pk);
+ pk = xmalloc_clear (sizeof *pk);
rc = get_pubkey (pk, kid);
if (rc)
{
@@ -1701,7 +1701,7 @@ clean_uids_from_key(KBNODE keyblock,int noisy)
user,keystr(keyblock->pkt->pkt.public_key->keyid),
reason);
- m_free(user);
+ xfree(user);
}
}
}
@@ -1936,14 +1936,14 @@ validate_key_list (KEYDB_HANDLE hd, KeyHashTable full_trust,
KEYDB_SEARCH_DESC desc;
maxkeys = 1000;
- keys = m_alloc ((maxkeys+1) * sizeof *keys);
+ keys = xmalloc ((maxkeys+1) * sizeof *keys);
nkeys = 0;
rc = keydb_search_reset (hd);
if (rc)
{
log_error ("keydb_search_reset failed: %s\n", g10_errstr(rc));
- m_free (keys);
+ xfree (keys);
return NULL;
}
@@ -1960,7 +1960,7 @@ validate_key_list (KEYDB_HANDLE hd, KeyHashTable full_trust,
if (rc)
{
log_error ("keydb_search_first failed: %s\n", g10_errstr(rc));
- m_free (keys);
+ xfree (keys);
return NULL;
}
@@ -1973,7 +1973,7 @@ validate_key_list (KEYDB_HANDLE hd, KeyHashTable full_trust,
if (rc)
{
log_error ("keydb_get_keyblock failed: %s\n", g10_errstr(rc));
- m_free (keys);
+ xfree (keys);
return NULL;
}
@@ -2005,7 +2005,7 @@ validate_key_list (KEYDB_HANDLE hd, KeyHashTable full_trust,
if (nkeys == maxkeys) {
maxkeys += 1000;
- keys = m_realloc (keys, (maxkeys+1) * sizeof *keys);
+ keys = xrealloc (keys, (maxkeys+1) * sizeof *keys);
}
keys[nkeys++].keyblock = keyblock;
@@ -2029,7 +2029,7 @@ validate_key_list (KEYDB_HANDLE hd, KeyHashTable full_trust,
if (rc && rc != -1)
{
log_error ("keydb_search_next failed: %s\n", g10_errstr(rc));
- m_free (keys);
+ xfree (keys);
return NULL;
}
@@ -2298,7 +2298,7 @@ validate_keys (int interactive)
kar->keyblock->pkt->pkt.public_key->trust_value;
if(kar->keyblock->pkt->pkt.public_key->trust_regexp)
k->trust_regexp=
- m_strdup(kar->keyblock->pkt->
+ xstrdup(kar->keyblock->pkt->
pkt.public_key->trust_regexp);
k->next = klist;
klist = k;
diff --git a/g10/verify.c b/g10/verify.c
index a08a71291..64c4b908f 100644
--- a/g10/verify.c
+++ b/g10/verify.c
@@ -127,10 +127,10 @@ verify_signatures( int nfiles, char **files )
void
print_file_status( int status, const char *name, int what )
{
- char *p = m_alloc(strlen(name)+10);
+ char *p = xmalloc(strlen(name)+10);
sprintf(p, "%d %s", what, name );
write_status_text( status, p );
- m_free(p);
+ xfree(p);
}