mirror of
git://git.gnupg.org/gnupg.git
synced 2025-07-02 22:46:30 +02:00
Nuked almost all trailing white space.
We better do this once and for all instead of cluttering all future commits with diffs of trailing white spaces. In the majority of cases blank or single lines are affected and thus this change won't disturb a git blame too much. For future commits the pre-commit scripts checks that this won't happen again.
This commit is contained in:
parent
ffd099eb19
commit
b008274afd
305 changed files with 5385 additions and 5592 deletions
|
@ -79,7 +79,7 @@
|
|||
|
||||
* keybox-init.c (keybox_new, keybox_release): Track used handles.
|
||||
(_keybox_close_file): New.
|
||||
* keybox-update.c (keybox_insert_cert, keybox_set_flags)
|
||||
* keybox-update.c (keybox_insert_cert, keybox_set_flags)
|
||||
(keybox_delete, keybox_compress): Use the new close function.
|
||||
|
||||
2008-03-13 Werner Koch <wk@g10code.com>
|
||||
|
@ -162,7 +162,7 @@
|
|||
2005-06-15 Werner Koch <wk@g10code.com>
|
||||
|
||||
* keybox-file.c (_keybox_read_blob2): Make IMAGE unsigned.
|
||||
(_keybox_write_blob):
|
||||
(_keybox_write_blob):
|
||||
|
||||
* keybox-blob.c (create_blob_finish, _keybox_create_x509_blob):
|
||||
Fixed warnings about signed/unsigned pointer mismatches.
|
||||
|
@ -219,7 +219,7 @@
|
|||
* keybox-blob.c (_keybox_update_header_blob): New.
|
||||
* keybox-update.c (blob_filecopy): Handle header blob.
|
||||
* keybox-file.c (_keybox_read_blob2): New. Moved code from
|
||||
_keybox_read_blob to there.
|
||||
_keybox_read_blob to there.
|
||||
* keybox-dump.c (dump_header_blob): Print header info.
|
||||
|
||||
2004-04-21 Werner Koch <wk@gnupg.org>
|
||||
|
@ -228,11 +228,11 @@
|
|||
KEYBOX_FLAG_CREATED_AT.
|
||||
* keybox-update.c (keybox_compress): New.
|
||||
|
||||
* keybox-search.c (get32, get16, blob_get_type)
|
||||
(blob_get_blob_flags, has_short_kid, has_long_kid)
|
||||
(has_fingerprint, has_issuer, has_issuer_sn, has_sn, has_subject)
|
||||
* keybox-search.c (get32, get16, blob_get_type)
|
||||
(blob_get_blob_flags, has_short_kid, has_long_kid)
|
||||
(has_fingerprint, has_issuer, has_issuer_sn, has_sn, has_subject)
|
||||
(has_subject_or_alt, has_mail): inline them.
|
||||
|
||||
|
||||
* keybox-update.c (blob_filecopy): Fixed an error/eof check
|
||||
(s/if(fread)/if(nread)/).
|
||||
|
||||
|
@ -256,17 +256,17 @@
|
|||
* keybox-blob.c: Include time.h
|
||||
|
||||
2003-06-03 Werner Koch <wk@gnupg.org>
|
||||
|
||||
|
||||
Changed all error codes in all files to the new libgpg-error scheme.
|
||||
|
||||
* keybox-defs.h: Include gpg-error.h .
|
||||
(KeyboxError): Removed.
|
||||
(KeyboxError): Removed.
|
||||
* Makefile.am: Removed keybox-error.c stuff.
|
||||
|
||||
2002-11-14 Werner Koch <wk@gnupg.org>
|
||||
|
||||
* keybox-search.c (blob_cmp_name) <compare all names>: Fixed
|
||||
length compare; there is no 0 stored since nearly a year.
|
||||
length compare; there is no 0 stored since nearly a year.
|
||||
|
||||
2002-10-31 Neal H. Walfield <neal@g10code.de>
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# Keybox Makefile
|
||||
# Keybox Makefile
|
||||
# Copyright (C) 2001, 2002, 2003 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is part of GnuPG.
|
||||
|
@ -7,12 +7,12 @@
|
|||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation; either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# GnuPG is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
@ -31,7 +31,7 @@ bin_PROGRAMS = kbxutil
|
|||
if HAVE_W32CE_SYSTEM
|
||||
extra_libs = $(LIBASSUAN_LIBS)
|
||||
else
|
||||
extra_libs =
|
||||
extra_libs =
|
||||
endif
|
||||
|
||||
common_sources = \
|
||||
|
@ -43,7 +43,7 @@ common_sources = \
|
|||
keybox-search.c \
|
||||
keybox-update.c \
|
||||
keybox-openpgp.c \
|
||||
keybox-dump.c
|
||||
keybox-dump.c
|
||||
|
||||
|
||||
libkeybox_a_SOURCES = $(common_sources)
|
||||
|
@ -56,4 +56,4 @@ kbxutil_LDADD = ../common/libcommon.a ../gl/libgnu.a \
|
|||
$(KSBA_LIBS) $(LIBGCRYPT_LIBS) $(extra_libs) \
|
||||
$(GPG_ERROR_LIBS) $(LIBINTL) $(LIBICONV) $(W32SOCKLIBS)
|
||||
|
||||
$(PROGRAMS) : ../common/libcommon.a ../gl/libgnu.a
|
||||
$(PROGRAMS) : ../common/libcommon.a ../gl/libgnu.a
|
||||
|
|
|
@ -46,7 +46,7 @@ enum cmd_and_opt_values {
|
|||
oOutput = 'o',
|
||||
oQuiet = 'q',
|
||||
oVerbose = 'v',
|
||||
|
||||
|
||||
aNoSuchCmd = 500, /* force other values not to be a letter */
|
||||
aFindByFpr,
|
||||
aFindByKid,
|
||||
|
@ -73,13 +73,13 @@ static ARGPARSE_OPTS opts[] = {
|
|||
/* { aFindByFpr, "find-by-fpr", 0, "|FPR| find key using it's fingerprnt" }, */
|
||||
/* { aFindByKid, "find-by-kid", 0, "|KID| find key using it's keyid" }, */
|
||||
/* { aFindByUid, "find-by-uid", 0, "|NAME| find key by user name" }, */
|
||||
{ aStats, "stats", 0, "show key statistics" },
|
||||
{ aStats, "stats", 0, "show key statistics" },
|
||||
{ aImportOpenPGP, "import-openpgp", 0, "import OpenPGP keyblocks"},
|
||||
{ aFindDups, "find-dups", 0, "find duplicates" },
|
||||
{ aCut, "cut", 0, "export records" },
|
||||
|
||||
|
||||
{ 301, NULL, 0, N_("@\nOptions:\n ") },
|
||||
|
||||
|
||||
{ oFrom, "from", 4, "|N|first record to export" },
|
||||
{ oTo, "to", 4, "|N|last record to export" },
|
||||
/* { oArmor, "armor", 0, N_("create ascii armored output")}, */
|
||||
|
@ -88,7 +88,7 @@ static ARGPARSE_OPTS opts[] = {
|
|||
{ oVerbose, "verbose", 0, N_("verbose") },
|
||||
{ oQuiet, "quiet", 0, N_("be somewhat more quiet") },
|
||||
{ oDryRun, "dry-run", 0, N_("do not make any changes") },
|
||||
|
||||
|
||||
{ oDebug, "debug" ,4|16, N_("set debugging flags")},
|
||||
{ oDebugAll, "debug-all" ,0, N_("enable full debugging")},
|
||||
|
||||
|
@ -144,7 +144,7 @@ my_gcry_logger (void *dummy, int level, const char *fmt, va_list arg_ptr)
|
|||
case GCRY_LOG_FATAL:level = JNLIB_LOG_FATAL; break;
|
||||
case GCRY_LOG_BUG: level = JNLIB_LOG_BUG; break;
|
||||
case GCRY_LOG_DEBUG:level = JNLIB_LOG_DEBUG; break;
|
||||
default: level = JNLIB_LOG_ERROR; break;
|
||||
default: level = JNLIB_LOG_ERROR; break;
|
||||
}
|
||||
log_logv (level, fmt, arg_ptr);
|
||||
}
|
||||
|
@ -236,7 +236,7 @@ read_file (const char *fname, size_t *r_length)
|
|||
FILE *fp;
|
||||
char *buf;
|
||||
size_t buflen;
|
||||
|
||||
|
||||
if (!strcmp (fname, "-"))
|
||||
{
|
||||
size_t nread, bufsize = 0;
|
||||
|
@ -245,7 +245,7 @@ read_file (const char *fname, size_t *r_length)
|
|||
buf = NULL;
|
||||
buflen = 0;
|
||||
#define NCHUNK 8192
|
||||
do
|
||||
do
|
||||
{
|
||||
bufsize += NCHUNK;
|
||||
if (!buf)
|
||||
|
@ -278,14 +278,14 @@ read_file (const char *fname, size_t *r_length)
|
|||
log_error ("can't open `%s': %s\n", fname, strerror (errno));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
if (fstat (fileno(fp), &st))
|
||||
{
|
||||
log_error ("can't stat `%s': %s\n", fname, strerror (errno));
|
||||
fclose (fp);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
buflen = st.st_size;
|
||||
buf = xtrymalloc (buflen+1);
|
||||
if (!buf)
|
||||
|
@ -342,7 +342,7 @@ dump_openpgp_key (keybox_openpgp_info_t info, const unsigned char *image)
|
|||
struct _keybox_openpgp_key_info *k;
|
||||
|
||||
k = &info->subkeys;
|
||||
do
|
||||
do
|
||||
{
|
||||
printf ("sub %02X%02X%02X%02X",
|
||||
k->keyid[4], k->keyid[5],
|
||||
|
@ -358,7 +358,7 @@ dump_openpgp_key (keybox_openpgp_info_t info, const unsigned char *image)
|
|||
struct _keybox_openpgp_uid_info *u;
|
||||
|
||||
u = &info->uids;
|
||||
do
|
||||
do
|
||||
{
|
||||
printf ("uid\t\t%.*s\n", (int)u->len, image + u->off);
|
||||
u = u->next;
|
||||
|
@ -412,10 +412,10 @@ main( int argc, char **argv )
|
|||
ARGPARSE_ARGS pargs;
|
||||
enum cmd_and_opt_values cmd = 0;
|
||||
unsigned long from = 0, to = ULONG_MAX;
|
||||
|
||||
|
||||
set_strusage( my_strusage );
|
||||
gcry_control (GCRYCTL_DISABLE_SECMEM);
|
||||
log_set_prefix ("kbxutil", 1);
|
||||
log_set_prefix ("kbxutil", 1);
|
||||
|
||||
/* Make sure that our subsystems are ready. */
|
||||
i18n_init ();
|
||||
|
@ -474,51 +474,51 @@ main( int argc, char **argv )
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (to < from)
|
||||
log_error ("record number of \"--to\" is lower than \"--from\" one\n");
|
||||
|
||||
|
||||
if (log_get_errorcount(0) )
|
||||
myexit(2);
|
||||
|
||||
|
||||
if (!cmd)
|
||||
{ /* Default is to list a KBX file */
|
||||
if (!argc)
|
||||
if (!argc)
|
||||
_keybox_dump_file (NULL, 0, stdout);
|
||||
else
|
||||
{
|
||||
for (; argc; argc--, argv++)
|
||||
for (; argc; argc--, argv++)
|
||||
_keybox_dump_file (*argv, 0, stdout);
|
||||
}
|
||||
}
|
||||
else if (cmd == aStats )
|
||||
{
|
||||
if (!argc)
|
||||
if (!argc)
|
||||
_keybox_dump_file (NULL, 1, stdout);
|
||||
else
|
||||
{
|
||||
for (; argc; argc--, argv++)
|
||||
for (; argc; argc--, argv++)
|
||||
_keybox_dump_file (*argv, 1, stdout);
|
||||
}
|
||||
}
|
||||
else if (cmd == aFindDups )
|
||||
{
|
||||
if (!argc)
|
||||
if (!argc)
|
||||
_keybox_dump_find_dups (NULL, 0, stdout);
|
||||
else
|
||||
{
|
||||
for (; argc; argc--, argv++)
|
||||
for (; argc; argc--, argv++)
|
||||
_keybox_dump_find_dups (*argv, 0, stdout);
|
||||
}
|
||||
}
|
||||
else if (cmd == aCut )
|
||||
{
|
||||
if (!argc)
|
||||
if (!argc)
|
||||
_keybox_dump_cut_records (NULL, from, to, stdout);
|
||||
else
|
||||
{
|
||||
for (; argc; argc--, argv++)
|
||||
for (; argc; argc--, argv++)
|
||||
_keybox_dump_cut_records (*argv, from, to, stdout);
|
||||
}
|
||||
}
|
||||
|
@ -528,12 +528,12 @@ main( int argc, char **argv )
|
|||
import_openpgp ("-");
|
||||
else
|
||||
{
|
||||
for (; argc; argc--, argv++)
|
||||
for (; argc; argc--, argv++)
|
||||
import_openpgp (*argv);
|
||||
}
|
||||
}
|
||||
#if 0
|
||||
else if ( cmd == aFindByFpr )
|
||||
else if ( cmd == aFindByFpr )
|
||||
{
|
||||
char *fpr;
|
||||
if ( argc != 2 )
|
||||
|
@ -541,17 +541,17 @@ main( int argc, char **argv )
|
|||
fpr = format_fingerprint ( argv[1] );
|
||||
if ( !fpr )
|
||||
log_error ("invalid formatted fingerprint\n");
|
||||
else
|
||||
else
|
||||
{
|
||||
kbxfile_search_by_fpr ( argv[0], fpr );
|
||||
gcry_free ( fpr );
|
||||
}
|
||||
}
|
||||
else if ( cmd == aFindByKid )
|
||||
else if ( cmd == aFindByKid )
|
||||
{
|
||||
u32 kid[2];
|
||||
int mode;
|
||||
|
||||
|
||||
if ( argc != 2 )
|
||||
wrong_args ("kbxfile short-or-long-keyid");
|
||||
mode = format_keyid ( argv[1], kid );
|
||||
|
@ -562,7 +562,7 @@ main( int argc, char **argv )
|
|||
kbxfile_search_by_kid ( argv[0], kid, mode );
|
||||
}
|
||||
}
|
||||
else if ( cmd == aFindByUid )
|
||||
else if ( cmd == aFindByUid )
|
||||
{
|
||||
if ( argc != 2 )
|
||||
wrong_args ("kbxfile userID");
|
||||
|
@ -571,7 +571,7 @@ main( int argc, char **argv )
|
|||
#endif
|
||||
else
|
||||
log_error ("unsupported action\n");
|
||||
|
||||
|
||||
myexit(0);
|
||||
return 8; /*NEVER REACHED*/
|
||||
}
|
||||
|
@ -590,5 +590,3 @@ myexit( int rc )
|
|||
keybox_errors_seen? 1 : 0;
|
||||
exit(rc );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ X.509 specific are noted like [X.509: xxx]
|
|||
u16 special key flags
|
||||
bit 0 = qualified signature (not yet implemented}
|
||||
u16 reserved
|
||||
u16 size of serialnumber(may be zero)
|
||||
u16 size of serialnumber(may be zero)
|
||||
n u16 (see above) bytes of serial number
|
||||
u16 number of user IDs
|
||||
u16 size of additional user ID information
|
||||
|
@ -84,7 +84,7 @@ X.509 specific are noted like [X.509: xxx]
|
|||
0x10000000 = valid and expires at some date in 1978.
|
||||
0xffffffff = valid and does not expire
|
||||
u8 assigned ownertrust [X509: not used]
|
||||
u8 all_validity
|
||||
u8 all_validity
|
||||
OpenPGP: see ../g10/trustdb/TRUST_* [not yet used]
|
||||
X509: Bit 4 set := key has been revoked. Note that this value
|
||||
matches TRUST_FLAG_REVOKED
|
||||
|
@ -180,7 +180,7 @@ struct keyboxblob {
|
|||
byte *blob;
|
||||
size_t bloblen;
|
||||
off_t fileoffset;
|
||||
|
||||
|
||||
/* stuff used only by keybox_create_blob */
|
||||
unsigned char *serialbuf;
|
||||
const unsigned char *serial;
|
||||
|
@ -193,10 +193,10 @@ struct keyboxblob {
|
|||
u32 *sigs;
|
||||
struct fixup_list *fixups;
|
||||
int fixup_out_of_core;
|
||||
|
||||
|
||||
struct keyid_list *temp_kids;
|
||||
struct membuf bufbuf; /* temporary store for the blob */
|
||||
struct membuf *buf;
|
||||
struct membuf *buf;
|
||||
};
|
||||
|
||||
|
||||
|
@ -227,7 +227,7 @@ put_membuf (struct membuf *mb, const void *buf, size_t len)
|
|||
if (mb->len + len >= mb->size)
|
||||
{
|
||||
char *p;
|
||||
|
||||
|
||||
mb->size += len + 1024;
|
||||
p = xtryrealloc (mb->buf, mb->size);
|
||||
if (!p)
|
||||
|
@ -293,14 +293,14 @@ static void
|
|||
add_fixup (KEYBOXBLOB blob, u32 off, u32 val)
|
||||
{
|
||||
struct fixup_list *fl;
|
||||
|
||||
|
||||
if (blob->fixup_out_of_core)
|
||||
return;
|
||||
|
||||
fl = xtrycalloc(1, sizeof *fl);
|
||||
if (!fl)
|
||||
blob->fixup_out_of_core = 1;
|
||||
else
|
||||
else
|
||||
{
|
||||
fl->off = off;
|
||||
fl->val = val;
|
||||
|
@ -313,7 +313,7 @@ add_fixup (KEYBOXBLOB blob, u32 off, u32 val)
|
|||
|
||||
#ifdef KEYBOX_WITH_OPENPGP
|
||||
/*
|
||||
OpenPGP specific stuff
|
||||
OpenPGP specific stuff
|
||||
*/
|
||||
|
||||
|
||||
|
@ -326,8 +326,8 @@ static int
|
|||
pgp_temp_store_kid (KEYBOXBLOB blob, PKT_public_key *pk)
|
||||
{
|
||||
struct keyid_list *k, *r;
|
||||
|
||||
k = xtrymalloc (sizeof *k);
|
||||
|
||||
k = xtrymalloc (sizeof *k);
|
||||
if (!k)
|
||||
return -1;
|
||||
k->kid[0] = pk->keyid[0] >> 24 ;
|
||||
|
@ -341,9 +341,9 @@ pgp_temp_store_kid (KEYBOXBLOB blob, PKT_public_key *pk)
|
|||
k->seqno = 0;
|
||||
k->next = blob->temp_kids;
|
||||
blob->temp_kids = k;
|
||||
for (r=k; r; r = r->next)
|
||||
for (r=k; r; r = r->next)
|
||||
k->seqno++;
|
||||
|
||||
|
||||
return k->seqno;
|
||||
}
|
||||
|
||||
|
@ -357,7 +357,7 @@ pgp_create_key_part (KEYBOXBLOB blob, KBNODE keyblock)
|
|||
for (n=0, node = keyblock; node; node = node->next)
|
||||
{
|
||||
if ( node->pkt->pkttype == PKT_PUBLIC_KEY
|
||||
|| node->pkt->pkttype == PKT_PUBLIC_SUBKEY )
|
||||
|| node->pkt->pkttype == PKT_PUBLIC_SUBKEY )
|
||||
{
|
||||
PKT_public_key *pk = node->pkt->pkt.public_key;
|
||||
char tmp[20];
|
||||
|
@ -379,7 +379,7 @@ pgp_create_key_part (KEYBOXBLOB blob, KBNODE keyblock)
|
|||
n++;
|
||||
}
|
||||
else if ( node->pkt->pkttype == PKT_SECRET_KEY
|
||||
|| node->pkt->pkttype == PKT_SECRET_SUBKEY )
|
||||
|| node->pkt->pkttype == PKT_SECRET_SUBKEY )
|
||||
{
|
||||
never_reached (); /* actually not yet implemented */
|
||||
}
|
||||
|
@ -399,7 +399,7 @@ pgp_create_uid_part (KEYBOXBLOB blob, KBNODE keyblock)
|
|||
if (node->pkt->pkttype == PKT_USER_ID)
|
||||
{
|
||||
PKT_user_id *u = node->pkt->pkt.user_id;
|
||||
|
||||
|
||||
blob->uids[n].len = u->len;
|
||||
blob->uids[n].flags = 0;
|
||||
blob->uids[n].validity = 0;
|
||||
|
@ -415,13 +415,13 @@ pgp_create_sig_part (KEYBOXBLOB blob, KBNODE keyblock)
|
|||
{
|
||||
KBNODE node;
|
||||
int n;
|
||||
|
||||
|
||||
for (n=0, node = keyblock; node; node = node->next)
|
||||
{
|
||||
if (node->pkt->pkttype == PKT_SIGNATURE)
|
||||
{
|
||||
PKT_signature *sig = node->pkt->pkt.signature;
|
||||
|
||||
|
||||
blob->sigs[n] = 0; /* FIXME: check the signature here */
|
||||
n++;
|
||||
}
|
||||
|
@ -449,7 +449,7 @@ pgp_create_blob_keyblock (KEYBOXBLOB blob, KBNODE keyblock)
|
|||
node->pkt->pkttype, gpg_errstr(rc) );
|
||||
return GPGERR_WRITE_FILE;
|
||||
}
|
||||
if ( node->pkt->pkttype == PKT_USER_ID )
|
||||
if ( node->pkt->pkttype == PKT_USER_ID )
|
||||
{
|
||||
PKT_user_id *u = node->pkt->pkt.user_id;
|
||||
/* build_packet has set the offset of the name into u ;
|
||||
|
@ -463,12 +463,12 @@ pgp_create_blob_keyblock (KEYBOXBLOB blob, KBNODE keyblock)
|
|||
add_fixup (blob, a->len - kbstart);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif /*KEYBOX_WITH_OPENPGP*/
|
||||
|
||||
|
||||
#ifdef KEYBOX_WITH_X509
|
||||
/*
|
||||
/*
|
||||
X.509 specific stuff
|
||||
*/
|
||||
|
||||
|
@ -492,7 +492,7 @@ x509_create_blob_cert (KEYBOXBLOB blob, ksba_cert_t cert)
|
|||
add_fixup (blob, 12, a->len - kbstart);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
#endif /*KEYBOX_WITH_X509*/
|
||||
|
||||
/* Write a stored keyID out to the buffer */
|
||||
|
@ -500,8 +500,8 @@ static void
|
|||
write_stored_kid (KEYBOXBLOB blob, int seqno)
|
||||
{
|
||||
struct keyid_list *r;
|
||||
|
||||
for ( r = blob->temp_kids; r; r = r->next )
|
||||
|
||||
for ( r = blob->temp_kids; r; r = r->next )
|
||||
{
|
||||
if (r->seqno == seqno )
|
||||
{
|
||||
|
@ -517,8 +517,8 @@ static void
|
|||
release_kid_list (struct keyid_list *kl)
|
||||
{
|
||||
struct keyid_list *r, *r2;
|
||||
|
||||
for ( r = kl; r; r = r2 )
|
||||
|
||||
for ( r = kl; r; r = r2 )
|
||||
{
|
||||
r2 = r->next;
|
||||
xfree (r);
|
||||
|
@ -534,7 +534,7 @@ create_blob_header (KEYBOXBLOB blob, int blobtype, int as_ephemeral)
|
|||
int i;
|
||||
|
||||
put32 ( a, 0 ); /* blob length, needs fixup */
|
||||
put8 ( a, blobtype);
|
||||
put8 ( a, blobtype);
|
||||
put8 ( a, 1 ); /* blob type version */
|
||||
put16 ( a, as_ephemeral? 2:0 ); /* blob flags */
|
||||
|
||||
|
@ -593,7 +593,7 @@ create_blob_header (KEYBOXBLOB blob, int blobtype, int as_ephemeral)
|
|||
fixup all the keyID offsets */
|
||||
for (i=0; i < blob->nkeys; i++ )
|
||||
{
|
||||
if (blob->keys[i].off_kid)
|
||||
if (blob->keys[i].off_kid)
|
||||
{ /* this is a v3 one */
|
||||
add_fixup (blob, blob->keys[i].off_kid_addr, a->len);
|
||||
write_stored_kid (blob, blob->keys[i].off_kid);
|
||||
|
@ -601,18 +601,18 @@ create_blob_header (KEYBOXBLOB blob, int blobtype, int as_ephemeral)
|
|||
else
|
||||
{ /* the better v4 key IDs - just store an offset 8 bytes back */
|
||||
add_fixup (blob, blob->keys[i].off_kid_addr,
|
||||
blob->keys[i].off_kid_addr - 8);
|
||||
blob->keys[i].off_kid_addr - 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (blobtype == BLOBTYPE_X509)
|
||||
{
|
||||
/* We don't want to point to ASN.1 encoded UserIDs (DNs) but to
|
||||
the utf-8 string represenation of them */
|
||||
for (i=0; i < blob->nuids; i++ )
|
||||
{
|
||||
if (blob->uids[i].name)
|
||||
if (blob->uids[i].name)
|
||||
{ /* this is a v3 one */
|
||||
add_fixup (blob, blob->uids[i].off_addr, a->len);
|
||||
put_membuf (blob->buf, blob->uids[i].name, blob->uids[i].len);
|
||||
|
@ -645,7 +645,7 @@ create_blob_finish (KEYBOXBLOB blob)
|
|||
/* write a placeholder for the checksum */
|
||||
for (i = 0; i < 16; i++ )
|
||||
put32 (a, 0); /* Hmmm: why put32() ?? */
|
||||
|
||||
|
||||
/* get the memory area */
|
||||
n = 0; /* (Just to avoid compiler warning.) */
|
||||
p = get_membuf (a, &n);
|
||||
|
@ -681,7 +681,7 @@ create_blob_finish (KEYBOXBLOB blob)
|
|||
memcpy (pp , p, n);
|
||||
blob->blob = pp;
|
||||
blob->bloblen = n;
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -703,7 +703,7 @@ _keybox_create_pgp_blob (KEYBOXBLOB *r_blob, KBNODE keyblock, int as_ephemeral)
|
|||
/* fixme: Do some sanity checks on the keyblock */
|
||||
|
||||
/* count userids and keys so that we can allocate the arrays */
|
||||
for (node = keyblock; node; node = node->next)
|
||||
for (node = keyblock; node; node = node->next)
|
||||
{
|
||||
switch (node->pkt->pkttype)
|
||||
{
|
||||
|
@ -735,7 +735,7 @@ _keybox_create_pgp_blob (KEYBOXBLOB *r_blob, KBNODE keyblock, int as_ephemeral)
|
|||
rc = pgp_create_sig_part ( blob, keyblock );
|
||||
if (rc)
|
||||
goto leave;
|
||||
|
||||
|
||||
init_membuf (&blob->bufbuf, 1024);
|
||||
blob->buf = &blob->bufbuf;
|
||||
rc = create_blob_header (blob, BLOBTYPE_OPENPGP, as_ephemeral);
|
||||
|
@ -751,7 +751,7 @@ _keybox_create_pgp_blob (KEYBOXBLOB *r_blob, KBNODE keyblock, int as_ephemeral)
|
|||
if (rc)
|
||||
goto leave;
|
||||
|
||||
|
||||
|
||||
leave:
|
||||
release_kid_list (blob->temp_kids);
|
||||
blob->temp_kids = NULL;
|
||||
|
@ -868,7 +868,7 @@ _keybox_create_x509_blob (KEYBOXBLOB *r_blob, ksba_cert_t cert,
|
|||
rc = gpg_error_from_syserror ();
|
||||
goto leave;
|
||||
}
|
||||
|
||||
|
||||
p = ksba_cert_get_issuer (cert, 0);
|
||||
if (!p)
|
||||
{
|
||||
|
@ -881,7 +881,7 @@ _keybox_create_x509_blob (KEYBOXBLOB *r_blob, ksba_cert_t cert,
|
|||
if (blob->nuids >= max_names)
|
||||
{
|
||||
char **tmp;
|
||||
|
||||
|
||||
max_names += 100;
|
||||
tmp = xtryrealloc (names, max_names * sizeof *names);
|
||||
if (!tmp)
|
||||
|
@ -895,9 +895,9 @@ _keybox_create_x509_blob (KEYBOXBLOB *r_blob, ksba_cert_t cert,
|
|||
if (!i && (p=x509_email_kludge (p)))
|
||||
names[blob->nuids++] = p; /* due to !i we don't need to check bounds*/
|
||||
}
|
||||
|
||||
|
||||
/* space for signature information */
|
||||
blob->nsigs = 1;
|
||||
blob->nsigs = 1;
|
||||
|
||||
blob->keys = xtrycalloc (blob->nkeys, sizeof *blob->keys );
|
||||
blob->uids = xtrycalloc (blob->nuids, sizeof *blob->uids );
|
||||
|
@ -944,14 +944,14 @@ _keybox_create_x509_blob (KEYBOXBLOB *r_blob, ksba_cert_t cert,
|
|||
if (rc)
|
||||
goto leave;
|
||||
|
||||
|
||||
|
||||
leave:
|
||||
release_kid_list (blob->temp_kids);
|
||||
blob->temp_kids = NULL;
|
||||
if (blob && names)
|
||||
{
|
||||
for (i=0; i < blob->nuids; i++)
|
||||
xfree (names[i]);
|
||||
xfree (names[i]);
|
||||
}
|
||||
xfree (names);
|
||||
if (rc)
|
||||
|
@ -974,7 +974,7 @@ _keybox_new_blob (KEYBOXBLOB *r_blob,
|
|||
unsigned char *image, size_t imagelen, off_t off)
|
||||
{
|
||||
KEYBOXBLOB blob;
|
||||
|
||||
|
||||
*r_blob = NULL;
|
||||
blob = xtrycalloc (1, sizeof *blob);
|
||||
if (!blob)
|
||||
|
|
|
@ -54,7 +54,7 @@ typedef struct keyboxblob *KEYBOXBLOB;
|
|||
|
||||
typedef struct keybox_name *KB_NAME;
|
||||
typedef struct keybox_name const *CONST_KB_NAME;
|
||||
struct keybox_name
|
||||
struct keybox_name
|
||||
{
|
||||
/* Link to the next resources, so that we can walk all
|
||||
resources. */
|
||||
|
@ -70,7 +70,7 @@ struct keybox_name
|
|||
entrues are set to NULL. HANDLE_TABLE may be NULL. */
|
||||
KEYBOX_HANDLE *handle_table;
|
||||
size_t handle_table_size;
|
||||
|
||||
|
||||
/* Not yet used. */
|
||||
int is_locked;
|
||||
|
||||
|
@ -89,7 +89,7 @@ struct keybox_handle {
|
|||
FILE *fp;
|
||||
int eof;
|
||||
int error;
|
||||
int ephemeral;
|
||||
int ephemeral;
|
||||
struct {
|
||||
KEYBOXBLOB blob;
|
||||
off_t offset;
|
||||
|
@ -215,7 +215,7 @@ void _keybox_free (void *p);
|
|||
#define STR2(v) STR(v)
|
||||
|
||||
/*
|
||||
a couple of handy macros
|
||||
a couple of handy macros
|
||||
*/
|
||||
|
||||
#define return_if_fail(expr) do { \
|
||||
|
@ -257,5 +257,3 @@ void _keybox_free (void *p);
|
|||
|
||||
|
||||
#endif /*KEYBOX_DEFS_H*/
|
||||
|
||||
|
||||
|
|
|
@ -93,9 +93,9 @@ dump_header_blob (const byte *buffer, size_t length, FILE *fp)
|
|||
if ( memcmp (buffer+8, "KBXf", 4))
|
||||
fprintf (fp, "[Error: invalid magic number]\n");
|
||||
|
||||
n = get32 (buffer+16);
|
||||
n = get32 (buffer+16);
|
||||
fprintf( fp, "created-at: %lu\n", n );
|
||||
n = get32 (buffer+20);
|
||||
n = get32 (buffer+20);
|
||||
fprintf( fp, "last-maint: %lu\n", n );
|
||||
|
||||
return 0;
|
||||
|
@ -117,7 +117,7 @@ _keybox_dump_blob (KEYBOXBLOB blob, FILE *fp)
|
|||
const byte *p;
|
||||
|
||||
buffer = _keybox_get_blob_image (blob, &length);
|
||||
|
||||
|
||||
if (length < 32)
|
||||
{
|
||||
fprintf (fp, "[blob too short]\n");
|
||||
|
@ -125,7 +125,7 @@ _keybox_dump_blob (KEYBOXBLOB blob, FILE *fp)
|
|||
}
|
||||
|
||||
n = get32( buffer );
|
||||
if (n > length)
|
||||
if (n > length)
|
||||
fprintf (fp, "[blob larger than length - output truncated]\n");
|
||||
else
|
||||
length = n; /* ignore the rest */
|
||||
|
@ -159,7 +159,7 @@ _keybox_dump_blob (KEYBOXBLOB blob, FILE *fp)
|
|||
fprintf (fp, "[blob too short]\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
n = get16 (buffer + 6);
|
||||
fprintf( fp, "Blob-Flags: %04lX", n);
|
||||
if (n)
|
||||
|
@ -188,7 +188,7 @@ _keybox_dump_blob (KEYBOXBLOB blob, FILE *fp)
|
|||
|
||||
fprintf( fp, "Data-Offset: %lu\n", rawdata_off );
|
||||
fprintf( fp, "Data-Length: %lu\n", rawdata_len );
|
||||
if (rawdata_off > length || rawdata_len > length
|
||||
if (rawdata_off > length || rawdata_len > length
|
||||
|| rawdata_off+rawdata_off > length)
|
||||
fprintf (fp, "[Error: raw data larger than blob]\n");
|
||||
|
||||
|
@ -207,7 +207,7 @@ _keybox_dump_blob (KEYBOXBLOB blob, FILE *fp)
|
|||
{
|
||||
int i;
|
||||
ulong kidoff, kflags;
|
||||
|
||||
|
||||
fprintf (fp, "Key-Fpr[%lu]: ", n );
|
||||
for (i=0; i < 20; i++ )
|
||||
fprintf (fp, "%02X", p[i]);
|
||||
|
@ -220,7 +220,7 @@ _keybox_dump_blob (KEYBOXBLOB blob, FILE *fp)
|
|||
kflags = get16 (p + 24 );
|
||||
fprintf( fp, "\nKey-Flags[%lu]: %04lX\n", n, kflags);
|
||||
}
|
||||
|
||||
|
||||
/* serial number */
|
||||
fputs ("Serial-No: ", fp);
|
||||
nserial = get16 (p);
|
||||
|
@ -244,7 +244,7 @@ _keybox_dump_blob (KEYBOXBLOB blob, FILE *fp)
|
|||
for (n=0; n < nuids; n++, p += uidinfolen)
|
||||
{
|
||||
ulong uidoff, uidlen, uflags;
|
||||
|
||||
|
||||
uidoff = get32( p );
|
||||
uidlen = get32( p+4 );
|
||||
if (type == BLOBTYPE_X509 && !n)
|
||||
|
@ -284,7 +284,7 @@ _keybox_dump_blob (KEYBOXBLOB blob, FILE *fp)
|
|||
fprintf (fp, "Uid-Validity[%lu]: %d\n", n, p[10] );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
nsigs = get16 (p);
|
||||
fprintf (fp, "Sig-Count: %lu\n", nsigs );
|
||||
siginfolen = get16 (p + 2);
|
||||
|
@ -294,7 +294,7 @@ _keybox_dump_blob (KEYBOXBLOB blob, FILE *fp)
|
|||
for (n=0; n < nsigs; n++, p += siginfolen)
|
||||
{
|
||||
ulong sflags;
|
||||
|
||||
|
||||
sflags = get32 (p);
|
||||
fprintf (fp, "Sig-Expire[%lu]: ", n );
|
||||
if (!sflags)
|
||||
|
@ -341,11 +341,11 @@ hash_blob_rawdata (KEYBOXBLOB blob, unsigned char *digest)
|
|||
ulong rawdata_off, rawdata_len;
|
||||
|
||||
buffer = _keybox_get_blob_image (blob, &length);
|
||||
|
||||
|
||||
if (length < 32)
|
||||
return -1;
|
||||
n = get32 (buffer);
|
||||
if (n < length)
|
||||
if (n < length)
|
||||
length = n; /* Blob larger than length in header - ignore the rest. */
|
||||
|
||||
type = buffer[4];
|
||||
|
@ -364,11 +364,11 @@ hash_blob_rawdata (KEYBOXBLOB blob, unsigned char *digest)
|
|||
|
||||
if (length < 40)
|
||||
return -1;
|
||||
|
||||
|
||||
rawdata_off = get32 (buffer + 8);
|
||||
rawdata_len = get32 (buffer + 12);
|
||||
|
||||
if (rawdata_off > length || rawdata_len > length
|
||||
if (rawdata_off > length || rawdata_len > length
|
||||
|| rawdata_off+rawdata_off > length)
|
||||
return -1; /* Out of bounds. */
|
||||
|
||||
|
@ -408,7 +408,7 @@ update_stats (KEYBOXBLOB blob, struct file_stats_s *s)
|
|||
}
|
||||
|
||||
n = get32( buffer );
|
||||
if (n > length)
|
||||
if (n > length)
|
||||
s->too_large_blobs++;
|
||||
else
|
||||
length = n; /* ignore the rest */
|
||||
|
@ -439,7 +439,7 @@ update_stats (KEYBOXBLOB blob, struct file_stats_s *s)
|
|||
s->too_short_blobs++;
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
n = get16 (buffer + 6);
|
||||
if (n)
|
||||
{
|
||||
|
@ -512,13 +512,13 @@ _keybox_dump_file (const char *filename, int stats_only, FILE *outfp)
|
|||
rc = 0;
|
||||
if (rc)
|
||||
fprintf (outfp, "error reading `%s': %s\n", filename, gpg_strerror (rc));
|
||||
|
||||
|
||||
if (fp != stdin)
|
||||
fclose (fp);
|
||||
|
||||
if (stats_only)
|
||||
{
|
||||
fprintf (outfp,
|
||||
fprintf (outfp,
|
||||
"Total number of blobs: %8lu\n"
|
||||
" header: %8lu\n"
|
||||
" empty: %8lu\n"
|
||||
|
@ -551,9 +551,9 @@ _keybox_dump_file (const char *filename, int stats_only, FILE *outfp)
|
|||
|
||||
|
||||
|
||||
struct dupitem_s
|
||||
struct dupitem_s
|
||||
{
|
||||
unsigned long recno;
|
||||
unsigned long recno;
|
||||
unsigned char digest[20];
|
||||
};
|
||||
|
||||
|
@ -563,7 +563,7 @@ cmp_dupitems (const void *arg_a, const void *arg_b)
|
|||
{
|
||||
struct dupitem_s *a = (struct dupitem_s *)arg_a;
|
||||
struct dupitem_s *b = (struct dupitem_s *)arg_b;
|
||||
|
||||
|
||||
return memcmp (a->digest, b->digest, 20);
|
||||
}
|
||||
|
||||
|
@ -581,7 +581,7 @@ _keybox_dump_find_dups (const char *filename, int print_them, FILE *outfp)
|
|||
char fprbuf[3*20+1];
|
||||
|
||||
(void)print_them;
|
||||
|
||||
|
||||
memset (zerodigest, 0, sizeof zerodigest);
|
||||
|
||||
if (!(fp = open_file (&filename, outfp)))
|
||||
|
@ -601,7 +601,7 @@ _keybox_dump_find_dups (const char *filename, int print_them, FILE *outfp)
|
|||
while ( !(rc = _keybox_read_blob (&blob, fp)) )
|
||||
{
|
||||
unsigned char digest[20];
|
||||
|
||||
|
||||
if (hash_blob_rawdata (blob, digest))
|
||||
fprintf (outfp, "error in blob %ld of `%s'\n", recno, filename);
|
||||
else if (memcmp (digest, zerodigest, 20))
|
||||
|
@ -668,7 +668,7 @@ _keybox_dump_cut_records (const char *filename, unsigned long from,
|
|||
KEYBOXBLOB blob;
|
||||
int rc;
|
||||
unsigned long recno = 0;
|
||||
|
||||
|
||||
if (!(fp = open_file (&filename, stderr)))
|
||||
return gpg_error_from_syserror ();
|
||||
|
||||
|
|
|
@ -6,12 +6,12 @@
|
|||
|
||||
/**
|
||||
* keybox_strerror:
|
||||
* @err: Error code
|
||||
*
|
||||
* @err: Error code
|
||||
*
|
||||
* This function returns a textual representaion of the given
|
||||
* errorcode. If this is an unknown value, a string with the value
|
||||
* is returned (Beware: it is hold in a static buffer).
|
||||
*
|
||||
*
|
||||
* Return value: String with the error description.
|
||||
**/
|
||||
const char *
|
||||
|
@ -44,4 +44,3 @@ keybox_strerror (KeyboxError err)
|
|||
|
||||
return s;
|
||||
}
|
||||
|
||||
|
|
|
@ -76,8 +76,8 @@ _keybox_read_blob2 (KEYBOXBLOB *r_blob, FILE *fp, int *skipped_deleted)
|
|||
imagelen = (c1 << 24) | (c2 << 16) | (c3 << 8 ) | c4;
|
||||
if (imagelen > 500000) /* Sanity check. */
|
||||
return gpg_error (GPG_ERR_TOO_LARGE);
|
||||
|
||||
if (imagelen < 5)
|
||||
|
||||
if (imagelen < 5)
|
||||
return gpg_error (GPG_ERR_TOO_SHORT);
|
||||
|
||||
if (!type)
|
||||
|
@ -90,7 +90,7 @@ _keybox_read_blob2 (KEYBOXBLOB *r_blob, FILE *fp, int *skipped_deleted)
|
|||
}
|
||||
|
||||
image = xtrymalloc (imagelen);
|
||||
if (!image)
|
||||
if (!image)
|
||||
return gpg_error_from_syserror ();
|
||||
|
||||
image[0] = c1; image[1] = c2; image[2] = c3; image[3] = c4; image[4] = type;
|
||||
|
@ -100,7 +100,7 @@ _keybox_read_blob2 (KEYBOXBLOB *r_blob, FILE *fp, int *skipped_deleted)
|
|||
xfree (image);
|
||||
return tmperr;
|
||||
}
|
||||
|
||||
|
||||
rc = r_blob? _keybox_new_blob (r_blob, image, imagelen, off) : 0;
|
||||
if (rc || !r_blob)
|
||||
xfree (image);
|
||||
|
@ -142,7 +142,7 @@ _keybox_write_header_blob (FILE *fp)
|
|||
|
||||
image[4] = BLOBTYPE_HEADER;
|
||||
image[5] = 1; /* Version */
|
||||
|
||||
|
||||
memcpy (image+8, "KBXf", 4);
|
||||
val = time (NULL);
|
||||
/* created_at and last maintenance run. */
|
||||
|
@ -159,5 +159,3 @@ _keybox_write_header_blob (FILE *fp)
|
|||
return gpg_error_from_syserror ();
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* keybox-init.c - Initalization of the library
|
||||
/* keybox-init.c - Initalization of the library
|
||||
* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
|
@ -59,7 +59,7 @@ keybox_register_file (const char *fname, int secret)
|
|||
/* keep a list of all issued pointers */
|
||||
kr->next = kb_names;
|
||||
kb_names = kr;
|
||||
|
||||
|
||||
/* create the offset table the first time a function here is used */
|
||||
/* if (!kb_offtbl) */
|
||||
/* kb_offtbl = new_offset_hash_table (); */
|
||||
|
@ -75,11 +75,11 @@ keybox_is_writable (void *token)
|
|||
return r? !access (r->fname, W_OK) : 0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
/* Create a new handle for the resource associated with TOKEN. SECRET
|
||||
is just a cross-check.
|
||||
|
||||
|
||||
The returned handle must be released using keybox_release (). */
|
||||
KEYBOX_HANDLE
|
||||
keybox_new (void *token, int secret)
|
||||
|
@ -118,7 +118,7 @@ keybox_new (void *token, int secret)
|
|||
size_t newsize;
|
||||
|
||||
newsize = resource->handle_table_size + 5;
|
||||
tmptbl = xtryrealloc (resource->handle_table,
|
||||
tmptbl = xtryrealloc (resource->handle_table,
|
||||
newsize * sizeof (*tmptbl));
|
||||
if (!tmptbl)
|
||||
{
|
||||
|
@ -135,7 +135,7 @@ keybox_new (void *token, int secret)
|
|||
return hd;
|
||||
}
|
||||
|
||||
void
|
||||
void
|
||||
keybox_release (KEYBOX_HANDLE hd)
|
||||
{
|
||||
if (!hd)
|
||||
|
@ -171,7 +171,7 @@ int
|
|||
keybox_set_ephemeral (KEYBOX_HANDLE hd, int yes)
|
||||
{
|
||||
if (!hd)
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
hd->ephemeral = yes;
|
||||
return 0;
|
||||
}
|
||||
|
@ -180,7 +180,7 @@ keybox_set_ephemeral (KEYBOX_HANDLE hd, int yes)
|
|||
/* Close the file of the resource identified by HD. For consistent
|
||||
results this fucntion closes the files of all handles pointing to
|
||||
the resource identified by HD. */
|
||||
void
|
||||
void
|
||||
_keybox_close_file (KEYBOX_HANDLE hd)
|
||||
{
|
||||
int idx;
|
||||
|
|
|
@ -72,8 +72,8 @@ enum packet_types
|
|||
follwing data on success:
|
||||
|
||||
R_DATAPKT = Pointer to the begin of the packet data.
|
||||
R_DATALEN = Length of this data. This has already been checked to fit
|
||||
into the buffer.
|
||||
R_DATALEN = Length of this data. This has already been checked to fit
|
||||
into the buffer.
|
||||
R_PKTTYPE = The packet type.
|
||||
R_NTOTAL = The total number of bytes of this packet
|
||||
|
||||
|
@ -91,11 +91,11 @@ next_packet (unsigned char const **bufptr, size_t *buflen,
|
|||
|
||||
if (!len)
|
||||
return gpg_error (GPG_ERR_NO_DATA);
|
||||
|
||||
|
||||
ctb = *buf++; len--;
|
||||
if ( !(ctb & 0x80) )
|
||||
return gpg_error (GPG_ERR_INV_PACKET); /* Invalid CTB. */
|
||||
|
||||
|
||||
pktlen = 0;
|
||||
if ((ctb & 0x40)) /* New style (OpenPGP) CTB. */
|
||||
{
|
||||
|
@ -108,7 +108,7 @@ next_packet (unsigned char const **bufptr, size_t *buflen,
|
|||
if ( c < 192 )
|
||||
pktlen = c;
|
||||
else if ( c < 224 )
|
||||
{
|
||||
{
|
||||
pktlen = (c - 192) * 256;
|
||||
if (!len)
|
||||
return gpg_error (GPG_ERR_INV_PACKET); /* No 2nd length byte. */
|
||||
|
@ -150,7 +150,7 @@ next_packet (unsigned char const **bufptr, size_t *buflen,
|
|||
switch (pkttype)
|
||||
{
|
||||
case PKT_SIGNATURE:
|
||||
case PKT_SECRET_KEY:
|
||||
case PKT_SECRET_KEY:
|
||||
case PKT_PUBLIC_KEY:
|
||||
case PKT_SECRET_SUBKEY:
|
||||
case PKT_MARKER:
|
||||
|
@ -166,9 +166,9 @@ next_packet (unsigned char const **bufptr, size_t *buflen,
|
|||
return gpg_error (GPG_ERR_UNEXPECTED);
|
||||
}
|
||||
|
||||
if (pktlen == 0xffffffff)
|
||||
if (pktlen == 0xffffffff)
|
||||
return gpg_error (GPG_ERR_INV_PACKET);
|
||||
|
||||
|
||||
if (pktlen > len)
|
||||
return gpg_error (GPG_ERR_INV_PACKET); /* Packet length header too long. */
|
||||
|
||||
|
@ -207,14 +207,14 @@ parse_key (const unsigned char *data, size_t datalen,
|
|||
version = *data++; datalen--;
|
||||
if (version < 2 || version > 4 )
|
||||
return gpg_error (GPG_ERR_INV_PACKET); /* Invalid version. */
|
||||
|
||||
|
||||
timestamp = ((data[0]<<24)|(data[1]<<16)|(data[2]<<8)|(data[3]));
|
||||
data +=4; datalen -=4;
|
||||
|
||||
if (version < 4)
|
||||
{
|
||||
unsigned short ndays;
|
||||
|
||||
|
||||
if (datalen < 2)
|
||||
return gpg_error (GPG_ERR_INV_PACKET);
|
||||
ndays = ((data[0]<<8)|(data[1]));
|
||||
|
@ -234,7 +234,7 @@ parse_key (const unsigned char *data, size_t datalen,
|
|||
case 1:
|
||||
case 2:
|
||||
case 3: /* RSA */
|
||||
npkey = 2;
|
||||
npkey = 2;
|
||||
break;
|
||||
case 16:
|
||||
case 20: /* Elgamal */
|
||||
|
@ -256,7 +256,7 @@ parse_key (const unsigned char *data, size_t datalen,
|
|||
for (i=0; i < npkey; i++ )
|
||||
{
|
||||
unsigned int nbits, nbytes;
|
||||
|
||||
|
||||
if (datalen < 2)
|
||||
return gpg_error (GPG_ERR_INV_PACKET);
|
||||
nbits = ((data[0]<<8)|(data[1]));
|
||||
|
@ -266,14 +266,14 @@ parse_key (const unsigned char *data, size_t datalen,
|
|||
return gpg_error (GPG_ERR_INV_PACKET);
|
||||
/* For use by v3 fingerprint calculation we need to know the RSA
|
||||
modulus and exponent. */
|
||||
if (i==0)
|
||||
if (i==0)
|
||||
{
|
||||
mpi_n = data;
|
||||
mpi_n = data;
|
||||
mpi_n_len = nbytes;
|
||||
}
|
||||
else if (i==1)
|
||||
mpi_e_len = nbytes;
|
||||
|
||||
|
||||
data += nbytes; datalen -= nbytes;
|
||||
}
|
||||
n = data - data_start;
|
||||
|
@ -293,12 +293,12 @@ parse_key (const unsigned char *data, size_t datalen,
|
|||
memcpy (ki->fpr, gcry_md_read (md, 0), 16);
|
||||
gcry_md_close (md);
|
||||
ki->fprlen = 16;
|
||||
|
||||
|
||||
if (mpi_n_len < 8)
|
||||
{
|
||||
/* Moduli less than 64 bit are out of the specs scope. Zero
|
||||
them out becuase this is what gpg does too. */
|
||||
memset (ki->keyid, 0, 8);
|
||||
memset (ki->keyid, 0, 8);
|
||||
}
|
||||
else
|
||||
memcpy (ki->keyid, mpi_n + mpi_n_len - 8, 8);
|
||||
|
@ -359,7 +359,7 @@ _keybox_parse_openpgp (const unsigned char *image, size_t imagelen,
|
|||
int first = 1;
|
||||
struct _keybox_openpgp_key_info *k, **ktail = NULL;
|
||||
struct _keybox_openpgp_uid_info *u, **utail = NULL;
|
||||
|
||||
|
||||
memset (info, 0, sizeof *info);
|
||||
if (nparsed)
|
||||
*nparsed = 0;
|
||||
|
@ -386,7 +386,7 @@ _keybox_parse_openpgp (const unsigned char *image, size_t imagelen,
|
|||
}
|
||||
else if (pkttype == PKT_PUBLIC_KEY || pkttype == PKT_SECRET_KEY)
|
||||
break; /* Next keyblock encountered - ready. */
|
||||
|
||||
|
||||
if (nparsed)
|
||||
*nparsed += n;
|
||||
|
||||
|
@ -424,7 +424,7 @@ _keybox_parse_openpgp (const unsigned char *image, size_t imagelen,
|
|||
if (err)
|
||||
break;
|
||||
}
|
||||
else if( pkttype == PKT_PUBLIC_SUBKEY && datalen && *data == '#' )
|
||||
else if( pkttype == PKT_PUBLIC_SUBKEY && datalen && *data == '#' )
|
||||
{
|
||||
/* Early versions of GnuPG used old PGP comment packets;
|
||||
* luckily all those comments are prefixed by a hash
|
||||
|
@ -488,7 +488,7 @@ _keybox_parse_openpgp (const unsigned char *image, size_t imagelen,
|
|||
|
||||
if (pkttype == PKT_PUBLIC_KEY || pkttype == PKT_SECRET_KEY)
|
||||
break; /* Next keyblock encountered - ready. */
|
||||
|
||||
|
||||
if (nparsed)
|
||||
*nparsed += n;
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
/*
|
||||
This file is a temporary kludge until we can come up with solution
|
||||
to share this description between keybox and the application
|
||||
specific keydb
|
||||
|
@ -54,12 +54,12 @@ struct gpg_pkt_user_id_s;
|
|||
typedef struct gpg_pkt_user_id_s *gpg_pkt_user_id_t;
|
||||
|
||||
/* A search descriptor. */
|
||||
struct keydb_search_desc
|
||||
struct keydb_search_desc
|
||||
{
|
||||
KeydbSearchMode mode;
|
||||
int (*skipfnc)(void *, u32 *, gpg_pkt_user_id_t);
|
||||
int (*skipfnc)(void *, u32 *, gpg_pkt_user_id_t);
|
||||
void *skipfncvalue;
|
||||
const unsigned char *sn;
|
||||
const unsigned char *sn;
|
||||
int snlen; /* -1 := sn is a hex string */
|
||||
union {
|
||||
const char *name;
|
||||
|
|
|
@ -112,7 +112,7 @@ _keybox_get_flag_location (const unsigned char *buffer, size_t length,
|
|||
*flag_off = 6;
|
||||
*flag_size = 2;
|
||||
break;
|
||||
|
||||
|
||||
case KEYBOX_FLAG_OWNERTRUST:
|
||||
case KEYBOX_FLAG_VALIDITY:
|
||||
case KEYBOX_FLAG_CREATED_AT:
|
||||
|
@ -127,7 +127,7 @@ _keybox_get_flag_location (const unsigned char *buffer, size_t length,
|
|||
if (pos+2 > length)
|
||||
return GPG_ERR_INV_OBJ; /* Out of bounds. */
|
||||
/* Serial number. */
|
||||
nserial = get16 (buffer+pos);
|
||||
nserial = get16 (buffer+pos);
|
||||
pos += 2 + nserial;
|
||||
if (pos+4 > length)
|
||||
return GPG_ERR_INV_OBJ; /* Out of bounds. */
|
||||
|
@ -135,7 +135,7 @@ _keybox_get_flag_location (const unsigned char *buffer, size_t length,
|
|||
nuids = get16 (buffer + pos); pos += 2;
|
||||
uidinfolen = get16 (buffer + pos); pos += 2;
|
||||
if (uidinfolen < 12 )
|
||||
return GPG_ERR_INV_OBJ;
|
||||
return GPG_ERR_INV_OBJ;
|
||||
pos += uidinfolen*nuids;
|
||||
if (pos+4 > length)
|
||||
return GPG_ERR_INV_OBJ ; /* Out of bounds. */
|
||||
|
@ -143,7 +143,7 @@ _keybox_get_flag_location (const unsigned char *buffer, size_t length,
|
|||
nsigs = get16 (buffer + pos); pos += 2;
|
||||
siginfolen = get16 (buffer + pos); pos += 2;
|
||||
if (siginfolen < 4 )
|
||||
return GPG_ERR_INV_OBJ;
|
||||
return GPG_ERR_INV_OBJ;
|
||||
pos += siginfolen*nsigs;
|
||||
if (pos+1+1+2+4+4+4+4 > length)
|
||||
return GPG_ERR_INV_OBJ ; /* Out of bounds. */
|
||||
|
@ -190,7 +190,7 @@ get_flag_from_image (const unsigned char *buffer, size_t length,
|
|||
case 4: *value = get32 (buffer + pos); break;
|
||||
default: ec = GPG_ERR_BUG; break;
|
||||
}
|
||||
|
||||
|
||||
return ec;
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ blob_cmp_sn (KEYBOXBLOB blob, const unsigned char *sn, int snlen)
|
|||
return 0; /* out of bounds */
|
||||
|
||||
/*serial*/
|
||||
nserial = get16 (buffer+pos);
|
||||
nserial = get16 (buffer+pos);
|
||||
off = pos + 2;
|
||||
if (off+nserial > length)
|
||||
return 0; /* out of bounds */
|
||||
|
@ -316,7 +316,7 @@ blob_cmp_name (KEYBOXBLOB blob, int idx,
|
|||
return 0; /* out of bounds */
|
||||
|
||||
/*serial*/
|
||||
nserial = get16 (buffer+pos);
|
||||
nserial = get16 (buffer+pos);
|
||||
pos += 2 + nserial;
|
||||
if (pos+4 > length)
|
||||
return 0; /* out of bounds */
|
||||
|
@ -332,7 +332,7 @@ blob_cmp_name (KEYBOXBLOB blob, int idx,
|
|||
if (idx < 0)
|
||||
{ /* compare all names starting with that (negated) index */
|
||||
idx = -idx;
|
||||
|
||||
|
||||
for ( ;idx < nuids; idx++)
|
||||
{
|
||||
size_t mypos = pos;
|
||||
|
@ -409,7 +409,7 @@ blob_cmp_mail (KEYBOXBLOB blob, const char *name, size_t namelen, int substr)
|
|||
return 0; /* out of bounds */
|
||||
|
||||
/*serial*/
|
||||
nserial = get16 (buffer+pos);
|
||||
nserial = get16 (buffer+pos);
|
||||
pos += 2 + nserial;
|
||||
if (pos+4 > length)
|
||||
return 0; /* out of bounds */
|
||||
|
@ -428,7 +428,7 @@ blob_cmp_mail (KEYBOXBLOB blob, const char *name, size_t namelen, int substr)
|
|||
for (idx=1 ;idx < nuids; idx++)
|
||||
{
|
||||
size_t mypos = pos;
|
||||
|
||||
|
||||
mypos += idx*uidinfolen;
|
||||
off = get32 (buffer+mypos);
|
||||
len = get32 (buffer+mypos+4);
|
||||
|
@ -439,7 +439,7 @@ blob_cmp_mail (KEYBOXBLOB blob, const char *name, size_t namelen, int substr)
|
|||
len--; /* one back */
|
||||
if ( len < 3 || buffer[off+len] != '>')
|
||||
continue; /* not a proper email address */
|
||||
len--;
|
||||
len--;
|
||||
if (substr)
|
||||
{
|
||||
if (ascii_memcasemem (buffer+off+1, len, name, namelen))
|
||||
|
@ -474,7 +474,7 @@ blob_x509_has_grip (KEYBOXBLOB blob, const unsigned char *grip)
|
|||
unsigned char array[20];
|
||||
unsigned char *rcp;
|
||||
size_t n;
|
||||
|
||||
|
||||
buffer = _keybox_get_blob_image (blob, &length);
|
||||
if (length < 40)
|
||||
return 0; /* Too short. */
|
||||
|
@ -527,7 +527,7 @@ blob_x509_has_grip (KEYBOXBLOB blob, const unsigned char *grip)
|
|||
|
||||
|
||||
/*
|
||||
The has_foo functions are used as helpers for search
|
||||
The has_foo functions are used as helpers for search
|
||||
*/
|
||||
static inline int
|
||||
has_short_kid (KEYBOXBLOB blob, u32 lkid)
|
||||
|
@ -599,7 +599,7 @@ has_issuer_sn (KEYBOXBLOB blob, const char *name,
|
|||
return 0;
|
||||
|
||||
namelen = strlen (name);
|
||||
|
||||
|
||||
return (blob_cmp_sn (blob, sn, snlen)
|
||||
&& blob_cmp_name (blob, 0 /* issuer */, name, namelen, 0));
|
||||
}
|
||||
|
@ -678,7 +678,7 @@ release_sn_array (struct sn_array_s *array, size_t size)
|
|||
|
||||
*/
|
||||
|
||||
int
|
||||
int
|
||||
keybox_search_reset (KEYBOX_HANDLE hd)
|
||||
{
|
||||
if (!hd)
|
||||
|
@ -697,13 +697,13 @@ keybox_search_reset (KEYBOX_HANDLE hd)
|
|||
}
|
||||
hd->error = 0;
|
||||
hd->eof = 0;
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* Note: When in ephemeral mode the search function does visit all
|
||||
blobs but in standard mode, blobs flagged as ephemeral are ignored. */
|
||||
int
|
||||
int
|
||||
keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc)
|
||||
{
|
||||
int rc;
|
||||
|
@ -722,18 +722,18 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc)
|
|||
hd->found.blob = NULL;
|
||||
}
|
||||
|
||||
if (hd->error)
|
||||
if (hd->error)
|
||||
return hd->error; /* still in error state */
|
||||
if (hd->eof)
|
||||
if (hd->eof)
|
||||
return -1; /* still EOF */
|
||||
|
||||
/* figure out what information we need */
|
||||
need_words = any_skip = 0;
|
||||
for (n=0; n < ndesc; n++)
|
||||
for (n=0; n < ndesc; n++)
|
||||
{
|
||||
switch (desc[n].mode)
|
||||
switch (desc[n].mode)
|
||||
{
|
||||
case KEYDB_SEARCH_MODE_WORDS:
|
||||
case KEYDB_SEARCH_MODE_WORDS:
|
||||
need_words = 1;
|
||||
break;
|
||||
case KEYDB_SEARCH_MODE_FIRST:
|
||||
|
@ -743,7 +743,7 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if (desc[n].skipfnc)
|
||||
if (desc[n].skipfnc)
|
||||
any_skip = 1;
|
||||
if (desc[n].snlen == -1 && !sn_array)
|
||||
{
|
||||
|
@ -776,7 +776,7 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc)
|
|||
int i, odd;
|
||||
size_t snlen;
|
||||
|
||||
for (n=0; n < ndesc; n++)
|
||||
for (n=0; n < ndesc; n++)
|
||||
{
|
||||
if (!desc[n].sn)
|
||||
;
|
||||
|
@ -844,14 +844,14 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc)
|
|||
if (!hd->ephemeral && (blobflags & 2))
|
||||
continue; /* Not in ephemeral mode but blob is flagged ephemeral. */
|
||||
|
||||
for (n=0; n < ndesc; n++)
|
||||
for (n=0; n < ndesc; n++)
|
||||
{
|
||||
switch (desc[n].mode)
|
||||
{
|
||||
case KEYDB_SEARCH_MODE_NONE:
|
||||
case KEYDB_SEARCH_MODE_NONE:
|
||||
never_reached ();
|
||||
break;
|
||||
case KEYDB_SEARCH_MODE_EXACT:
|
||||
case KEYDB_SEARCH_MODE_EXACT:
|
||||
if (has_subject_or_alt (blob, desc[n].u.name, 0))
|
||||
goto found;
|
||||
break;
|
||||
|
@ -868,7 +868,7 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc)
|
|||
goto found;
|
||||
break;
|
||||
case KEYDB_SEARCH_MODE_MAILEND:
|
||||
case KEYDB_SEARCH_MODE_WORDS:
|
||||
case KEYDB_SEARCH_MODE_WORDS:
|
||||
never_reached (); /* not yet implemented */
|
||||
break;
|
||||
case KEYDB_SEARCH_MODE_ISSUER:
|
||||
|
@ -890,7 +890,7 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc)
|
|||
if (has_subject (blob, desc[n].u.name))
|
||||
goto found;
|
||||
break;
|
||||
case KEYDB_SEARCH_MODE_SHORT_KID:
|
||||
case KEYDB_SEARCH_MODE_SHORT_KID:
|
||||
if (has_short_kid (blob, desc[n].u.kid[1]))
|
||||
goto found;
|
||||
break;
|
||||
|
@ -907,20 +907,20 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc)
|
|||
if (has_keygrip (blob, desc[n].u.grip))
|
||||
goto found;
|
||||
break;
|
||||
case KEYDB_SEARCH_MODE_FIRST:
|
||||
case KEYDB_SEARCH_MODE_FIRST:
|
||||
goto found;
|
||||
break;
|
||||
case KEYDB_SEARCH_MODE_NEXT:
|
||||
case KEYDB_SEARCH_MODE_NEXT:
|
||||
goto found;
|
||||
break;
|
||||
default:
|
||||
default:
|
||||
rc = gpg_error (GPG_ERR_INV_VALUE);
|
||||
goto found;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
found:
|
||||
for (n=any_skip?0:ndesc; n < ndesc; n++)
|
||||
found:
|
||||
for (n=any_skip?0:ndesc; n < ndesc; n++)
|
||||
{
|
||||
/* if (desc[n].skipfnc */
|
||||
/* && desc[n].skipfnc (desc[n].skipfncvalue, aki, NULL)) */
|
||||
|
@ -929,7 +929,7 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc)
|
|||
if (n == ndesc)
|
||||
break; /* got it */
|
||||
}
|
||||
|
||||
|
||||
if (!rc)
|
||||
{
|
||||
hd->found.blob = blob;
|
||||
|
@ -939,7 +939,7 @@ keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc)
|
|||
_keybox_release_blob (blob);
|
||||
hd->eof = 1;
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
_keybox_release_blob (blob);
|
||||
hd->error = rc;
|
||||
|
@ -1042,4 +1042,3 @@ keybox_get_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int *value)
|
|||
ec = get_flag_from_image (buffer, length, what, value);
|
||||
return ec? gpg_error (ec):0;
|
||||
}
|
||||
|
||||
|
|
|
@ -66,12 +66,12 @@ fseeko (FILE * stream, off_t newpos, int whence)
|
|||
static int
|
||||
create_tmp_file (const char *template,
|
||||
char **r_bakfname, char **r_tmpfname, FILE **r_fp)
|
||||
{
|
||||
{
|
||||
char *bakfname, *tmpfname;
|
||||
|
||||
|
||||
*r_bakfname = NULL;
|
||||
*r_tmpfname = NULL;
|
||||
|
||||
|
||||
# ifdef USE_ONLY_8DOT3
|
||||
/* Here is another Windoze bug?:
|
||||
* you cant rename("pubring.kbx.tmp", "pubring.kbx");
|
||||
|
@ -88,7 +88,7 @@ create_tmp_file (const char *template,
|
|||
return gpg_error_from_syserror ();
|
||||
strcpy (bakfname, template);
|
||||
strcpy (bakfname+strlen(template)-4, EXTSEP_S "kb_");
|
||||
|
||||
|
||||
tmpfname = xtrymalloc (strlen (template) + 1);
|
||||
if (!tmpfname)
|
||||
{
|
||||
|
@ -99,14 +99,14 @@ create_tmp_file (const char *template,
|
|||
strcpy (tmpfname,template);
|
||||
strcpy (tmpfname + strlen (template)-4, EXTSEP_S "k__");
|
||||
}
|
||||
else
|
||||
else
|
||||
{ /* File does not end with kbx, thus we hope we are working on a
|
||||
modern file system and appending a suffix works. */
|
||||
bakfname = xtrymalloc ( strlen (template) + 5);
|
||||
if (!bakfname)
|
||||
return gpg_error_from_syserror ();
|
||||
strcpy (stpcpy (bakfname, template), EXTSEP_S "kb_");
|
||||
|
||||
|
||||
tmpfname = xtrymalloc ( strlen (template) + 5);
|
||||
if (!tmpfname)
|
||||
{
|
||||
|
@ -121,7 +121,7 @@ create_tmp_file (const char *template,
|
|||
if (!bakfname)
|
||||
return gpg_error_from_syserror ();
|
||||
strcpy (stpcpy (bakfname,template),"~");
|
||||
|
||||
|
||||
tmpfname = xtrymalloc ( strlen (template) + 5);
|
||||
if (!tmpfname)
|
||||
{
|
||||
|
@ -173,7 +173,7 @@ rename_tmp_file (const char *bakfname, const char *tmpfname,
|
|||
|
||||
/* First make a backup file except for secret keyboxes. */
|
||||
if (!secret)
|
||||
{
|
||||
{
|
||||
#if defined(HAVE_DOSISH_SYSTEM) || defined(__riscos__)
|
||||
gnupg_remove (bakfname);
|
||||
#endif
|
||||
|
@ -182,7 +182,7 @@ rename_tmp_file (const char *bakfname, const char *tmpfname,
|
|||
return gpg_error_from_syserror ();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Then rename the file. */
|
||||
#if defined(HAVE_DOSISH_SYSTEM) || defined(__riscos__)
|
||||
gnupg_remove (fname);
|
||||
|
@ -200,7 +200,7 @@ rename_tmp_file (const char *bakfname, const char *tmpfname,
|
|||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -212,7 +212,7 @@ rename_tmp_file (const char *bakfname, const char *tmpfname,
|
|||
3 = update
|
||||
*/
|
||||
static int
|
||||
blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
|
||||
blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
|
||||
int secret, off_t start_offset)
|
||||
{
|
||||
FILE *fp, *newfp;
|
||||
|
@ -222,14 +222,14 @@ blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
|
|||
char buffer[4096];
|
||||
int nread, nbytes;
|
||||
|
||||
/* Open the source file. Because we do a rename, we have to check the
|
||||
/* Open the source file. Because we do a rename, we have to check the
|
||||
permissions of the file */
|
||||
if (access (fname, W_OK))
|
||||
return gpg_error_from_syserror ();
|
||||
|
||||
fp = fopen (fname, "rb");
|
||||
if (mode == 1 && !fp && errno == ENOENT)
|
||||
{
|
||||
{
|
||||
/* Insert mode but file does not exist:
|
||||
Create a new keybox file. */
|
||||
newfp = fopen (fname, "wb");
|
||||
|
@ -268,10 +268,10 @@ blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
|
|||
fclose(fp);
|
||||
goto leave;
|
||||
}
|
||||
|
||||
|
||||
/* prepare for insert */
|
||||
if (mode == 1)
|
||||
{
|
||||
{
|
||||
/* Copy everything to the new file. */
|
||||
while ( (nread = fread (buffer, 1, DIM(buffer), fp)) > 0 )
|
||||
{
|
||||
|
@ -287,12 +287,12 @@ blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
|
|||
goto leave;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Prepare for delete or update. */
|
||||
if ( mode == 2 || mode == 3 )
|
||||
{
|
||||
if ( mode == 2 || mode == 3 )
|
||||
{
|
||||
off_t current = 0;
|
||||
|
||||
|
||||
/* Copy first part to the new file. */
|
||||
while ( current < start_offset )
|
||||
{
|
||||
|
@ -303,7 +303,7 @@ blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
|
|||
if (!nread)
|
||||
break;
|
||||
current += nread;
|
||||
|
||||
|
||||
if (fwrite (buffer, nread, 1, newfp) != 1)
|
||||
{
|
||||
rc = gpg_error_from_syserror ();
|
||||
|
@ -315,24 +315,24 @@ blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
|
|||
rc = gpg_error_from_syserror ();
|
||||
goto leave;
|
||||
}
|
||||
|
||||
|
||||
/* Skip this blob. */
|
||||
rc = _keybox_read_blob (NULL, fp);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/* Do an insert or update. */
|
||||
if ( mode == 1 || mode == 3 )
|
||||
{
|
||||
{
|
||||
rc = _keybox_write_blob (blob, newfp);
|
||||
if (rc)
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
/* Copy the rest of the packet for an delete or update. */
|
||||
if (mode == 2 || mode == 3)
|
||||
{
|
||||
{
|
||||
while ( (nread = fread (buffer, 1, DIM(buffer), fp)) > 0 )
|
||||
{
|
||||
if (fwrite (buffer, nread, 1, newfp) != 1)
|
||||
|
@ -347,7 +347,7 @@ blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
|
|||
goto leave;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Close both files. */
|
||||
if (fclose(fp))
|
||||
{
|
||||
|
@ -371,7 +371,7 @@ blob_filecopy (int mode, const char *fname, KEYBOXBLOB blob,
|
|||
|
||||
|
||||
|
||||
#ifdef KEYBOX_WITH_X509
|
||||
#ifdef KEYBOX_WITH_X509
|
||||
int
|
||||
keybox_insert_cert (KEYBOX_HANDLE hd, ksba_cert_t cert,
|
||||
unsigned char *sha1_digest)
|
||||
|
@ -381,12 +381,12 @@ keybox_insert_cert (KEYBOX_HANDLE hd, ksba_cert_t cert,
|
|||
KEYBOXBLOB blob;
|
||||
|
||||
if (!hd)
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
if (!hd->kb)
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
fname = hd->kb->fname;
|
||||
if (!fname)
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
|
||||
/* Close this one otherwise we will mess up the position for a next
|
||||
search. Fixme: it would be better to adjust the position after
|
||||
|
@ -440,12 +440,12 @@ keybox_set_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int value)
|
|||
if (!hd->found.blob)
|
||||
return gpg_error (GPG_ERR_NOTHING_FOUND);
|
||||
if (!hd->kb)
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
if (!hd->found.blob)
|
||||
return gpg_error (GPG_ERR_NOTHING_FOUND);
|
||||
fname = hd->kb->fname;
|
||||
if (!fname)
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
|
||||
off = _keybox_get_blob_fileoffset (hd->found.blob);
|
||||
if (off == (off_t)-1)
|
||||
|
@ -455,7 +455,7 @@ keybox_set_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int value)
|
|||
ec = _keybox_get_flag_location (buffer, length, what, &flag_pos, &flag_size);
|
||||
if (ec)
|
||||
return gpg_error (ec);
|
||||
|
||||
|
||||
off += flag_pos;
|
||||
|
||||
_keybox_close_file (hd);
|
||||
|
@ -477,7 +477,7 @@ keybox_set_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int value)
|
|||
|
||||
switch (flag_size)
|
||||
{
|
||||
case 1:
|
||||
case 1:
|
||||
case 2:
|
||||
case 4:
|
||||
if (fwrite (tmp+4-flag_size, flag_size, 1, fp) != 1)
|
||||
|
@ -513,10 +513,10 @@ keybox_delete (KEYBOX_HANDLE hd)
|
|||
if (!hd->found.blob)
|
||||
return gpg_error (GPG_ERR_NOTHING_FOUND);
|
||||
if (!hd->kb)
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
fname = hd->kb->fname;
|
||||
if (!fname)
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
|
||||
off = _keybox_get_blob_fileoffset (hd->found.blob);
|
||||
if (off == (off_t)-1)
|
||||
|
@ -562,18 +562,18 @@ keybox_compress (KEYBOX_HANDLE hd)
|
|||
int skipped_deleted;
|
||||
|
||||
if (!hd)
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
if (!hd->kb)
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
if (hd->secret)
|
||||
return gpg_error (GPG_ERR_NOT_IMPLEMENTED);
|
||||
fname = hd->kb->fname;
|
||||
if (!fname)
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
return gpg_error (GPG_ERR_INV_HANDLE);
|
||||
|
||||
_keybox_close_file (hd);
|
||||
|
||||
/* Open the source file. Because we do a rename, we have to check the
|
||||
/* Open the source file. Because we do a rename, we have to check the
|
||||
permissions of the file */
|
||||
if (access (fname, W_OK))
|
||||
return gpg_error_from_syserror ();
|
||||
|
@ -599,7 +599,7 @@ keybox_compress (KEYBOX_HANDLE hd)
|
|||
{
|
||||
u32 last_maint = ((buffer[20] << 24) | (buffer[20+1] << 16)
|
||||
| (buffer[20+2] << 8) | (buffer[20+3]));
|
||||
|
||||
|
||||
if ( (last_maint + 3*3600) > time (NULL) )
|
||||
{
|
||||
fclose (fp);
|
||||
|
@ -620,7 +620,7 @@ keybox_compress (KEYBOX_HANDLE hd)
|
|||
return rc;;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Processing loop. By reading using _keybox_read_blob we
|
||||
automagically skip any blobs flagged as deleted. Thus what we
|
||||
only have to do is to check all ephemeral flagged blocks whether
|
||||
|
@ -665,7 +665,7 @@ keybox_compress (KEYBOX_HANDLE hd)
|
|||
continue;
|
||||
}
|
||||
|
||||
if (_keybox_get_flag_location (buffer, length,
|
||||
if (_keybox_get_flag_location (buffer, length,
|
||||
KEYBOX_FLAG_BLOB, &pos, &size)
|
||||
|| size != 2)
|
||||
{
|
||||
|
@ -676,7 +676,7 @@ keybox_compress (KEYBOX_HANDLE hd)
|
|||
if ((blobflags & KEYBOX_FLAG_BLOB_EPHEMERAL))
|
||||
{
|
||||
/* This is an ephemeral blob. */
|
||||
if (_keybox_get_flag_location (buffer, length,
|
||||
if (_keybox_get_flag_location (buffer, length,
|
||||
KEYBOX_FLAG_CREATED_AT, &pos, &size)
|
||||
|| size != 4)
|
||||
created_at = 0; /* oops. */
|
||||
|
@ -719,4 +719,3 @@ keybox_compress (KEYBOX_HANDLE hd)
|
|||
xfree(tmpfname);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* keybox-util.c - Utility functions for Keybox
|
||||
/* keybox-util.c - Utility functions for Keybox
|
||||
* Copyright (C) 2001 Free Software Foundation, Inc.
|
||||
*
|
||||
* This file is part of GnuPG.
|
||||
|
@ -68,4 +68,3 @@ _keybox_free (void *p)
|
|||
if (p)
|
||||
free_func (p);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#ifndef KEYBOX_H
|
||||
#define KEYBOX_H 1
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
extern "C" {
|
||||
#if 0
|
||||
}
|
||||
#endif
|
||||
|
@ -28,7 +28,7 @@ extern "C" {
|
|||
|
||||
#include "keybox-search-desc.h"
|
||||
|
||||
#define KEYBOX_WITH_OPENPGP 1
|
||||
#define KEYBOX_WITH_OPENPGP 1
|
||||
#define KEYBOX_WITH_X509 1
|
||||
|
||||
|
||||
|
@ -73,7 +73,7 @@ int keybox_set_ephemeral (KEYBOX_HANDLE hd, int yes);
|
|||
|
||||
|
||||
/*-- keybox-search.c --*/
|
||||
#ifdef KEYBOX_WITH_X509
|
||||
#ifdef KEYBOX_WITH_X509
|
||||
int keybox_get_cert (KEYBOX_HANDLE hd, ksba_cert_t *ret_cert);
|
||||
#endif /*KEYBOX_WITH_X509*/
|
||||
int keybox_get_flags (KEYBOX_HANDLE hd, int what, int idx, unsigned int *value);
|
||||
|
@ -83,7 +83,7 @@ int keybox_search (KEYBOX_HANDLE hd, KEYBOX_SEARCH_DESC *desc, size_t ndesc);
|
|||
|
||||
|
||||
/*-- keybox-update.c --*/
|
||||
#ifdef KEYBOX_WITH_X509
|
||||
#ifdef KEYBOX_WITH_X509
|
||||
int keybox_insert_cert (KEYBOX_HANDLE hd, ksba_cert_t cert,
|
||||
unsigned char *sha1_digest);
|
||||
int keybox_update_cert (KEYBOX_HANDLE hd, ksba_cert_t cert,
|
||||
|
|
|
@ -27,12 +27,12 @@ cat <<EOF
|
|||
|
||||
/**
|
||||
* keybox_strerror:
|
||||
* @err: Error code
|
||||
*
|
||||
* @err: Error code
|
||||
*
|
||||
* This function returns a textual representaion of the given
|
||||
* errorcode. If this is an unknown value, a string with the value
|
||||
* is returned (Beware: it is hold in a static buffer).
|
||||
*
|
||||
*
|
||||
* Return value: String with the error description.
|
||||
**/
|
||||
const char *
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue