mirror of
git://git.gnupg.org/gnupg.git
synced 2024-12-22 10:19:57 +01:00
agent: Replace most assert by log_assert.
--
This commit is contained in:
parent
5651b2c460
commit
54e96c6fd2
@ -23,7 +23,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <npth.h>
|
#include <npth.h>
|
||||||
|
|
||||||
#include "agent.h"
|
#include "agent.h"
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#ifndef HAVE_W32_SYSTEM
|
#ifndef HAVE_W32_SYSTEM
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#ifdef HAVE_SIGNAL_H
|
#ifdef HAVE_SIGNAL_H
|
||||||
# include <signal.h>
|
# include <signal.h>
|
||||||
|
@ -41,7 +41,6 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <assert.h>
|
|
||||||
#ifndef HAVE_W32_SYSTEM
|
#ifndef HAVE_W32_SYSTEM
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/un.h>
|
#include <sys/un.h>
|
||||||
@ -1030,7 +1029,7 @@ search_control_file (ssh_control_file_t cf, const char *hexgrip,
|
|||||||
{
|
{
|
||||||
gpg_error_t err;
|
gpg_error_t err;
|
||||||
|
|
||||||
assert (strlen (hexgrip) == 40 );
|
log_assert (strlen (hexgrip) == 40 );
|
||||||
|
|
||||||
if (r_disabled)
|
if (r_disabled)
|
||||||
*r_disabled = 0;
|
*r_disabled = 0;
|
||||||
@ -2646,7 +2645,7 @@ ssh_handler_request_identities (ctrl_t ctrl,
|
|||||||
continue; /* Should not happen. */
|
continue; /* Should not happen. */
|
||||||
if (cf->item.disabled)
|
if (cf->item.disabled)
|
||||||
continue;
|
continue;
|
||||||
assert (strlen (cf->item.hexgrip) == 40);
|
log_assert (strlen (cf->item.hexgrip) == 40);
|
||||||
hex2bin (cf->item.hexgrip, grip, sizeof (grip));
|
hex2bin (cf->item.hexgrip, grip, sizeof (grip));
|
||||||
|
|
||||||
err = agent_public_key_from_file (ctrl, grip, &key_public);
|
err = agent_public_key_from_file (ctrl, grip, &key_public);
|
||||||
|
@ -30,7 +30,6 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <dirent.h>
|
#include <dirent.h>
|
||||||
@ -2212,7 +2211,7 @@ cmd_import_key (assuan_context_t ctx, char *line)
|
|||||||
goto leave; /* Invalid canonical encoded S-expression. */
|
goto leave; /* Invalid canonical encoded S-expression. */
|
||||||
if (passphrase)
|
if (passphrase)
|
||||||
{
|
{
|
||||||
assert (!opt_unattended);
|
log_assert (!opt_unattended);
|
||||||
if (!cache_nonce)
|
if (!cache_nonce)
|
||||||
{
|
{
|
||||||
char buf[12];
|
char buf[12];
|
||||||
|
@ -22,7 +22,6 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "agent.h"
|
#include "agent.h"
|
||||||
#include "../common/i18n.h"
|
#include "../common/i18n.h"
|
||||||
@ -571,7 +570,7 @@ do_unprotect (const char *passphrase,
|
|||||||
}
|
}
|
||||||
skey[i] = NULL;
|
skey[i] = NULL;
|
||||||
skeylen = i;
|
skeylen = i;
|
||||||
assert (skeylen <= skeysize);
|
log_assert (skeylen <= skeysize);
|
||||||
|
|
||||||
/* Note: at this point NDATA should be 2 for a simple
|
/* Note: at this point NDATA should be 2 for a simple
|
||||||
checksum or 20 for the sha1 digest. */
|
checksum or 20 for the sha1 digest. */
|
||||||
@ -1105,8 +1104,8 @@ apply_protection (gcry_mpi_t *array, int npkey, int nskey,
|
|||||||
int ndata;
|
int ndata;
|
||||||
unsigned char *p, *data;
|
unsigned char *p, *data;
|
||||||
|
|
||||||
assert (npkey < nskey);
|
log_assert (npkey < nskey);
|
||||||
assert (nskey < DIM (bufarr));
|
log_assert (nskey < DIM (bufarr));
|
||||||
|
|
||||||
/* Collect only the secret key parameters into BUFARR et al and
|
/* Collect only the secret key parameters into BUFARR et al and
|
||||||
compute the required size of the data buffer. */
|
compute the required size of the data buffer. */
|
||||||
@ -1143,7 +1142,7 @@ apply_protection (gcry_mpi_t *array, int npkey, int nskey,
|
|||||||
xfree (bufarr[i]);
|
xfree (bufarr[i]);
|
||||||
bufarr[i] = NULL;
|
bufarr[i] = NULL;
|
||||||
}
|
}
|
||||||
assert (p == data + ndata - 20);
|
log_assert (p == data + ndata - 20);
|
||||||
|
|
||||||
/* Append a hash of the secret key parameters. */
|
/* Append a hash of the secret key parameters. */
|
||||||
gcry_md_hash_buffer (GCRY_MD_SHA1, p, data, ndata - 20);
|
gcry_md_hash_buffer (GCRY_MD_SHA1, p, data, ndata - 20);
|
||||||
|
@ -26,10 +26,8 @@
|
|||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <npth.h> /* (we use pth_sleep) */
|
#include <npth.h> /* (we use pth_sleep) */
|
||||||
|
|
||||||
#include "agent.h"
|
#include "agent.h"
|
||||||
@ -336,7 +334,7 @@ try_unprotect_cb (struct pin_entry_info_s *pi)
|
|||||||
gnupg_isotime_t now, protected_at, tmptime;
|
gnupg_isotime_t now, protected_at, tmptime;
|
||||||
char *desc = NULL;
|
char *desc = NULL;
|
||||||
|
|
||||||
assert (!arg->unprotected_key);
|
log_assert (!arg->unprotected_key);
|
||||||
|
|
||||||
arg->change_required = 0;
|
arg->change_required = 0;
|
||||||
err = agent_unprotect (ctrl, arg->protected_key, pi->pin, protected_at,
|
err = agent_unprotect (ctrl, arg->protected_key, pi->pin, protected_at,
|
||||||
@ -740,7 +738,7 @@ unprotect (ctrl_t ctrl, const char *cache_nonce, const char *desc_text,
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
assert (arg.unprotected_key);
|
log_assert (arg.unprotected_key);
|
||||||
if (arg.change_required)
|
if (arg.change_required)
|
||||||
{
|
{
|
||||||
/* The callback told as that the user should change their
|
/* The callback told as that the user should change their
|
||||||
@ -748,7 +746,7 @@ unprotect (ctrl_t ctrl, const char *cache_nonce, const char *desc_text,
|
|||||||
size_t canlen, erroff;
|
size_t canlen, erroff;
|
||||||
gcry_sexp_t s_skey;
|
gcry_sexp_t s_skey;
|
||||||
|
|
||||||
assert (arg.unprotected_key);
|
log_assert (arg.unprotected_key);
|
||||||
canlen = gcry_sexp_canon_len (arg.unprotected_key, 0, NULL, NULL);
|
canlen = gcry_sexp_canon_len (arg.unprotected_key, 0, NULL, NULL);
|
||||||
rc = gcry_sexp_sscan (&s_skey, &erroff,
|
rc = gcry_sexp_sscan (&s_skey, &erroff,
|
||||||
(char*)arg.unprotected_key, canlen);
|
(char*)arg.unprotected_key, canlen);
|
||||||
@ -1415,7 +1413,7 @@ agent_public_key_from_file (ctrl_t ctrl,
|
|||||||
such a task. After all that is what we do in protect.c. Need
|
such a task. After all that is what we do in protect.c. Need
|
||||||
to find common patterns and write a straightformward API to use
|
to find common patterns and write a straightformward API to use
|
||||||
them. */
|
them. */
|
||||||
assert (sizeof (size_t) <= sizeof (void*));
|
log_assert (sizeof (size_t) <= sizeof (void*));
|
||||||
|
|
||||||
format = xtrymalloc (15+4+7*npkey+10+15+1+1);
|
format = xtrymalloc (15+4+7*npkey+10+15+1+1);
|
||||||
if (!format)
|
if (!format)
|
||||||
@ -1440,14 +1438,14 @@ agent_public_key_from_file (ctrl_t ctrl,
|
|||||||
*p++ = '(';
|
*p++ = '(';
|
||||||
*p++ = *s++;
|
*p++ = *s++;
|
||||||
p = stpcpy (p, " %m)");
|
p = stpcpy (p, " %m)");
|
||||||
assert (argidx < DIM (args));
|
log_assert (argidx < DIM (args));
|
||||||
args[argidx++] = &array[idx];
|
args[argidx++] = &array[idx];
|
||||||
}
|
}
|
||||||
*p++ = ')';
|
*p++ = ')';
|
||||||
if (uri)
|
if (uri)
|
||||||
{
|
{
|
||||||
p = stpcpy (p, "(uri %b)");
|
p = stpcpy (p, "(uri %b)");
|
||||||
assert (argidx+1 < DIM (args));
|
log_assert (argidx+1 < DIM (args));
|
||||||
uri_intlen = (int)uri_length;
|
uri_intlen = (int)uri_length;
|
||||||
args[argidx++] = (void *)&uri_intlen;
|
args[argidx++] = (void *)&uri_intlen;
|
||||||
args[argidx++] = (void *)&uri;
|
args[argidx++] = (void *)&uri;
|
||||||
@ -1455,14 +1453,14 @@ agent_public_key_from_file (ctrl_t ctrl,
|
|||||||
if (comment)
|
if (comment)
|
||||||
{
|
{
|
||||||
p = stpcpy (p, "(comment %b)");
|
p = stpcpy (p, "(comment %b)");
|
||||||
assert (argidx+1 < DIM (args));
|
log_assert (argidx+1 < DIM (args));
|
||||||
comment_intlen = (int)comment_length;
|
comment_intlen = (int)comment_length;
|
||||||
args[argidx++] = (void *)&comment_intlen;
|
args[argidx++] = (void *)&comment_intlen;
|
||||||
args[argidx++] = (void*)&comment;
|
args[argidx++] = (void*)&comment;
|
||||||
}
|
}
|
||||||
*p++ = ')';
|
*p++ = ')';
|
||||||
*p = 0;
|
*p = 0;
|
||||||
assert (argidx < DIM (args));
|
log_assert (argidx < DIM (args));
|
||||||
args[argidx] = NULL;
|
args[argidx] = NULL;
|
||||||
|
|
||||||
err = gcry_sexp_build_array (&list, NULL, format, args);
|
err = gcry_sexp_build_array (&list, NULL, format, args);
|
||||||
@ -1559,7 +1557,7 @@ agent_key_info_from_file (ctrl_t ctrl, const unsigned char *grip,
|
|||||||
if (!err)
|
if (!err)
|
||||||
{
|
{
|
||||||
n = gcry_sexp_canon_len (s, 0, NULL, NULL);
|
n = gcry_sexp_canon_len (s, 0, NULL, NULL);
|
||||||
assert (n);
|
log_assert (n);
|
||||||
*r_shadow_info = xtrymalloc (n);
|
*r_shadow_info = xtrymalloc (n);
|
||||||
if (!*r_shadow_info)
|
if (!*r_shadow_info)
|
||||||
err = gpg_error_from_syserror ();
|
err = gpg_error_from_syserror ();
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
|
||||||
|
|
||||||
#include "agent.h"
|
#include "agent.h"
|
||||||
#include "../common/i18n.h"
|
#include "../common/i18n.h"
|
||||||
@ -47,12 +46,12 @@ store_key (gcry_sexp_t private, const char *passphrase, int force,
|
|||||||
}
|
}
|
||||||
|
|
||||||
len = gcry_sexp_sprint (private, GCRYSEXP_FMT_CANON, NULL, 0);
|
len = gcry_sexp_sprint (private, GCRYSEXP_FMT_CANON, NULL, 0);
|
||||||
assert (len);
|
log_assert (len);
|
||||||
buf = gcry_malloc_secure (len);
|
buf = gcry_malloc_secure (len);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
return out_of_core ();
|
return out_of_core ();
|
||||||
len = gcry_sexp_sprint (private, GCRYSEXP_FMT_CANON, buf, len);
|
len = gcry_sexp_sprint (private, GCRYSEXP_FMT_CANON, buf, len);
|
||||||
assert (len);
|
log_assert (len);
|
||||||
|
|
||||||
if (passphrase)
|
if (passphrase)
|
||||||
{
|
{
|
||||||
@ -127,7 +126,7 @@ check_passphrase_pattern (ctrl_t ctrl, const char *pw)
|
|||||||
argv[i++] = "--",
|
argv[i++] = "--",
|
||||||
argv[i++] = opt.check_passphrase_pattern,
|
argv[i++] = opt.check_passphrase_pattern,
|
||||||
argv[i] = NULL;
|
argv[i] = NULL;
|
||||||
assert (i < sizeof argv);
|
log_assert (i < sizeof argv);
|
||||||
|
|
||||||
if (gnupg_spawn_process_fd (pgmname, argv, fileno (infp), -1, -1, &pid))
|
if (gnupg_spawn_process_fd (pgmname, argv, fileno (infp), -1, -1, &pid))
|
||||||
result = 1; /* Execute error - assume password should no be used. */
|
result = 1; /* Execute error - assume password should no be used. */
|
||||||
@ -557,7 +556,7 @@ agent_genkey (ctrl_t ctrl, const char *cache_nonce,
|
|||||||
if (DBG_CRYPTO)
|
if (DBG_CRYPTO)
|
||||||
log_debug ("returning public key\n");
|
log_debug ("returning public key\n");
|
||||||
len = gcry_sexp_sprint (s_public, GCRYSEXP_FMT_CANON, NULL, 0);
|
len = gcry_sexp_sprint (s_public, GCRYSEXP_FMT_CANON, NULL, 0);
|
||||||
assert (len);
|
log_assert (len);
|
||||||
buf = xtrymalloc (len);
|
buf = xtrymalloc (len);
|
||||||
if (!buf)
|
if (!buf)
|
||||||
{
|
{
|
||||||
@ -567,7 +566,7 @@ agent_genkey (ctrl_t ctrl, const char *cache_nonce,
|
|||||||
return tmperr;
|
return tmperr;
|
||||||
}
|
}
|
||||||
len = gcry_sexp_sprint (s_public, GCRYSEXP_FMT_CANON, buf, len);
|
len = gcry_sexp_sprint (s_public, GCRYSEXP_FMT_CANON, buf, len);
|
||||||
assert (len);
|
log_assert (len);
|
||||||
put_membuf (outbuf, buf, len);
|
put_membuf (outbuf, buf, len);
|
||||||
gcry_sexp_release (s_public);
|
gcry_sexp_release (s_public);
|
||||||
xfree (buf);
|
xfree (buf);
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -1952,7 +1951,7 @@ agent_set_progress_cb (void (*cb)(ctrl_t ctrl, const char *what,
|
|||||||
static void
|
static void
|
||||||
agent_init_default_ctrl (ctrl_t ctrl)
|
agent_init_default_ctrl (ctrl_t ctrl)
|
||||||
{
|
{
|
||||||
assert (ctrl->session_env);
|
log_assert (ctrl->session_env);
|
||||||
|
|
||||||
/* Note we ignore malloc errors because we can't do much about it
|
/* Note we ignore malloc errors because we can't do much about it
|
||||||
and the request will fail anyway shortly after this
|
and the request will fail anyway shortly after this
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
@ -23,7 +23,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
@ -119,10 +118,10 @@ agent_pkdecrypt (ctrl_t ctrl, const char *desc_text,
|
|||||||
gcry_sexp_dump (s_plain);
|
gcry_sexp_dump (s_plain);
|
||||||
}
|
}
|
||||||
len = gcry_sexp_sprint (s_plain, GCRYSEXP_FMT_CANON, NULL, 0);
|
len = gcry_sexp_sprint (s_plain, GCRYSEXP_FMT_CANON, NULL, 0);
|
||||||
assert (len);
|
log_assert (len);
|
||||||
buf = xmalloc (len);
|
buf = xmalloc (len);
|
||||||
len = gcry_sexp_sprint (s_plain, GCRYSEXP_FMT_CANON, buf, len);
|
len = gcry_sexp_sprint (s_plain, GCRYSEXP_FMT_CANON, buf, len);
|
||||||
assert (len);
|
log_assert (len);
|
||||||
if (*buf == '(')
|
if (*buf == '(')
|
||||||
put_membuf (outbuf, buf, len);
|
put_membuf (outbuf, buf, len);
|
||||||
else
|
else
|
||||||
|
@ -24,8 +24,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
#include "agent.h"
|
#include "agent.h"
|
||||||
@ -250,13 +248,13 @@ do_encode_raw_pkcs1 (const byte *md, size_t mdlen, unsigned int nbits,
|
|||||||
frame[n++] = 0;
|
frame[n++] = 0;
|
||||||
frame[n++] = 1; /* Block type. */
|
frame[n++] = 1; /* Block type. */
|
||||||
i = nframe - mdlen - 3 ;
|
i = nframe - mdlen - 3 ;
|
||||||
assert (i >= 8); /* At least 8 bytes of padding. */
|
log_assert (i >= 8); /* At least 8 bytes of padding. */
|
||||||
memset (frame+n, 0xff, i );
|
memset (frame+n, 0xff, i );
|
||||||
n += i;
|
n += i;
|
||||||
frame[n++] = 0;
|
frame[n++] = 0;
|
||||||
memcpy (frame+n, md, mdlen );
|
memcpy (frame+n, md, mdlen );
|
||||||
n += mdlen;
|
n += mdlen;
|
||||||
assert (n == nframe);
|
log_assert (n == nframe);
|
||||||
|
|
||||||
/* Create the S-expression. */
|
/* Create the S-expression. */
|
||||||
rc = gcry_sexp_build (&hash, NULL,
|
rc = gcry_sexp_build (&hash, NULL,
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#ifdef HAVE_LOCALE_H
|
#ifdef HAVE_LOCALE_H
|
||||||
|
@ -25,7 +25,6 @@
|
|||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#ifdef HAVE_LOCALE_H
|
#ifdef HAVE_LOCALE_H
|
||||||
@ -198,10 +197,10 @@ make_canonical (const char *fname, const char *buf, size_t buflen)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_CANON, NULL, 0);
|
len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_CANON, NULL, 0);
|
||||||
assert (len);
|
log_assert (len);
|
||||||
result = xmalloc (len);
|
result = xmalloc (len);
|
||||||
len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_CANON, result, len);
|
len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_CANON, result, len);
|
||||||
assert (len);
|
log_assert (len);
|
||||||
gcry_sexp_release (sexp);
|
gcry_sexp_release (sexp);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -222,10 +221,10 @@ make_advanced (const unsigned char *buf, size_t buflen)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_ADVANCED, NULL, 0);
|
len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_ADVANCED, NULL, 0);
|
||||||
assert (len);
|
log_assert (len);
|
||||||
result = xmalloc (len);
|
result = xmalloc (len);
|
||||||
len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_ADVANCED, result, len);
|
len = gcry_sexp_sprint (sexp, GCRYSEXP_FMT_ADVANCED, result, len);
|
||||||
assert (len);
|
log_assert (len);
|
||||||
gcry_sexp_release (sexp);
|
gcry_sexp_release (sexp);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -433,7 +432,7 @@ read_and_shadow (const char *fname)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
resultlen = gcry_sexp_canon_len (result, 0, NULL,NULL);
|
resultlen = gcry_sexp_canon_len (result, 0, NULL,NULL);
|
||||||
assert (resultlen);
|
log_assert (resultlen);
|
||||||
|
|
||||||
if (opt_armor)
|
if (opt_armor)
|
||||||
{
|
{
|
||||||
@ -469,7 +468,7 @@ show_shadow_info (const char *fname)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
infolen = gcry_sexp_canon_len (info, 0, NULL,NULL);
|
infolen = gcry_sexp_canon_len (info, 0, NULL,NULL);
|
||||||
assert (infolen);
|
log_assert (infolen);
|
||||||
|
|
||||||
if (opt_armor)
|
if (opt_armor)
|
||||||
{
|
{
|
||||||
@ -496,7 +495,7 @@ show_file (const char *fname)
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
keylen = gcry_sexp_canon_len (key, 0, NULL,NULL);
|
keylen = gcry_sexp_canon_len (key, 0, NULL,NULL);
|
||||||
assert (keylen);
|
log_assert (keylen);
|
||||||
|
|
||||||
if (opt_canonical)
|
if (opt_canonical)
|
||||||
{
|
{
|
||||||
@ -723,7 +722,7 @@ get_passphrase (int promptno)
|
|||||||
gpg_strerror (err));
|
gpg_strerror (err));
|
||||||
agent_exit (0);
|
agent_exit (0);
|
||||||
}
|
}
|
||||||
assert (pw);
|
log_assert (pw);
|
||||||
|
|
||||||
return pw;
|
return pw;
|
||||||
}
|
}
|
||||||
|
@ -528,7 +528,7 @@ do_encryption (const unsigned char *hashbegin, size_t hashlen,
|
|||||||
memcpy (p, iv+blklen, blklen); /* Add padding. */
|
memcpy (p, iv+blklen, blklen); /* Add padding. */
|
||||||
p += blklen;
|
p += blklen;
|
||||||
}
|
}
|
||||||
assert ( p - outbuf == outlen);
|
log_assert ( p - outbuf == outlen);
|
||||||
if (use_ocb)
|
if (use_ocb)
|
||||||
{
|
{
|
||||||
gcry_cipher_final (hd);
|
gcry_cipher_final (hd);
|
||||||
@ -718,11 +718,11 @@ agent_protect (const unsigned char *plainkey, const char *passphrase,
|
|||||||
hash_end = s;
|
hash_end = s;
|
||||||
s++;
|
s++;
|
||||||
/* Skip to the end of the S-expression. */
|
/* Skip to the end of the S-expression. */
|
||||||
assert (depth == 1);
|
log_assert (depth == 1);
|
||||||
rc = sskip (&s, &depth);
|
rc = sskip (&s, &depth);
|
||||||
if (rc)
|
if (rc)
|
||||||
return rc;
|
return rc;
|
||||||
assert (!depth);
|
log_assert (!depth);
|
||||||
real_end = s-1;
|
real_end = s-1;
|
||||||
|
|
||||||
rc = do_encryption (hash_begin, hash_end - hash_begin + 1,
|
rc = do_encryption (hash_begin, hash_end - hash_begin + 1,
|
||||||
@ -760,7 +760,7 @@ agent_protect (const unsigned char *plainkey, const char *passphrase,
|
|||||||
|
|
||||||
memcpy (p, prot_end+1, real_end - prot_end);
|
memcpy (p, prot_end+1, real_end - prot_end);
|
||||||
p += real_end - prot_end;
|
p += real_end - prot_end;
|
||||||
assert ( p - *result == *resultlen);
|
log_assert ( p - *result == *resultlen);
|
||||||
xfree (protected);
|
xfree (protected);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -999,7 +999,7 @@ merge_lists (const unsigned char *protectedkey,
|
|||||||
|
|
||||||
/* Skip over the protected list element in the original list. */
|
/* Skip over the protected list element in the original list. */
|
||||||
s = protectedkey + replacepos;
|
s = protectedkey + replacepos;
|
||||||
assert (*s == '(');
|
log_assert (*s == '(');
|
||||||
s++;
|
s++;
|
||||||
i = 1;
|
i = 1;
|
||||||
rc = sskip (&s, &i);
|
rc = sskip (&s, &i);
|
||||||
@ -1026,7 +1026,7 @@ merge_lists (const unsigned char *protectedkey,
|
|||||||
rc = sskip (&s, &i);
|
rc = sskip (&s, &i);
|
||||||
if (rc)
|
if (rc)
|
||||||
goto failure;
|
goto failure;
|
||||||
assert (s[-1] == ')');
|
log_assert (s[-1] == ')');
|
||||||
endpos = s; /* one behind the end of the list */
|
endpos = s; /* one behind the end of the list */
|
||||||
|
|
||||||
/* Append the rest. */
|
/* Append the rest. */
|
||||||
@ -1571,7 +1571,7 @@ agent_shadow_key (const unsigned char *pubkey,
|
|||||||
point = s; /* insert right before the point */
|
point = s; /* insert right before the point */
|
||||||
depth--;
|
depth--;
|
||||||
s++;
|
s++;
|
||||||
assert (depth == 1);
|
log_assert (depth == 1);
|
||||||
|
|
||||||
/* Calculate required length by taking in account: the "shadowed-"
|
/* Calculate required length by taking in account: the "shadowed-"
|
||||||
prefix, the "shadowed", "t1-v1" as well as some parenthesis */
|
prefix, the "shadowed", "t1-v1" as well as some parenthesis */
|
||||||
|
@ -28,7 +28,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
|
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <assert.h>
|
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
#include <npth.h>
|
#include <npth.h>
|
||||||
@ -550,7 +549,7 @@ insert_colons (const char *string)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*p = 0;
|
*p = 0;
|
||||||
assert (strlen (buffer) <= nnew);
|
log_assert (strlen (buffer) <= nnew);
|
||||||
|
|
||||||
return buffer;
|
return buffer;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user