summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--AUTHORS1
-rw-r--r--ChangeLog6
-rw-r--r--NEWS11
-rw-r--r--TODO20
-rwxr-xr-xchecks/defs.inc1
-rw-r--r--cipher/blowfish.c2
-rw-r--r--cipher/blowfish.h6
-rw-r--r--cipher/cast5.c2
-rw-r--r--cipher/cast5.h6
-rw-r--r--cipher/cipher.c4
-rw-r--r--cipher/des.h6
-rw-r--r--cipher/dsa.c6
-rw-r--r--cipher/dsa.h2
-rw-r--r--cipher/dynload.c32
-rw-r--r--cipher/dynload.h12
-rw-r--r--cipher/elgamal.c14
-rw-r--r--cipher/elgamal.h2
-rw-r--r--cipher/md.c6
-rw-r--r--cipher/pubkey.c26
-rw-r--r--cipher/random.c2
-rw-r--r--cipher/rndunix.c5
-rw-r--r--configure.in15
-rw-r--r--doc/gpg.1pod13
-rw-r--r--g10/ChangeLog12
-rw-r--r--g10/armor.c15
-rw-r--r--g10/build-packet.c22
-rw-r--r--g10/g10.c10
-rw-r--r--g10/keydb.h4
-rw-r--r--g10/keyedit.c24
-rw-r--r--g10/keygen.c2
-rw-r--r--g10/main.h2
-rw-r--r--g10/parse-packet.c13
-rw-r--r--g10/pkclist.c47
-rw-r--r--g10/seckey-cert.c18
-rw-r--r--g10/skclist.c14
-rw-r--r--g10/tdbio.c7
-rw-r--r--g10/trustdb.c62
-rw-r--r--include/ChangeLog4
-rw-r--r--include/cipher.h2
-rw-r--r--include/http.h2
-rw-r--r--include/iobuf.h7
-rw-r--r--include/mpi.h4
-rw-r--r--include/types.h1
-rw-r--r--include/util.h2
-rw-r--r--mpi/mpi-scan.c10
-rw-r--r--util/ChangeLog7
-rw-r--r--util/argparse.c56
-rw-r--r--util/dotlock.c5
-rw-r--r--util/http.c32
-rw-r--r--util/iobuf.c48
-rw-r--r--util/secmem.c2
-rw-r--r--util/strgutil.c2
-rw-r--r--util/ttyio.c2
53 files changed, 359 insertions, 279 deletions
diff --git a/AUTHORS b/AUTHORS
index 6d1dfb14c..d69b17579 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -20,6 +20,7 @@ GNUPG Michael Roth Germany 1998-09-17
Assigns changes.
mroth@nessie.de
Wrote cipher/des.c.
+Changes and bug fixes all over the place.
GNUPG Niklas Hernaeus 1998-09-18
diff --git a/ChangeLog b/ChangeLog
index 3e99e5cd6..842434a06 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Tue Feb 16 14:10:02 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * configure.in (socket): Check for -lsocket and -lnsl.
+ (osf4): Disable all warnings for DEC's cc.
+ (-Wall): Add more warning options for gcc
+
Sat Feb 13 12:04:43 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* configure.in: Changed detection of compiler flags.
diff --git a/NEWS b/NEWS
index 8b423f74f..932a32fc0 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,17 @@
* changed the internal design of getkey which now allows a
efficient lookup of multiple keys and add a word match mode.
+ * New option --encrypt-to
+
+ * Some changes to the configure stuff. Switched to automake 1.4.
+ Removed intl/ from CVS, autgen.sh now uses gettextize.
+
+ * Preferences now include twofish and removed preference to Blowfish with
+ a special hack to suppress the "not listed in preferences" warning.
+ This is to allow us to switch completely to Twofish in the near future.
+
+ * Changed the locking stuff.
+
Noteworthy changes in version 0.9.2
-----------------------------------
diff --git a/TODO b/TODO
index 85367e82f..685df9244 100644
--- a/TODO
+++ b/TODO
@@ -11,12 +11,8 @@ Bugs
* README does not verify okay. verify inserts an extra CR,LF
just before "Esoteric Command" (after ~8k of text).
- * Did I add -lsocket and -lnls for Solaris?
-
Important
----------
- * replace gettext by a non exploitable one.
-
* Check revocation and expire stuff. PLEASE: THIS MUST BE TESTED!
* Check calculation of key validity. PLEASE: IT IS IMPORTED THAT
@@ -28,21 +24,9 @@ Important
Needed
------
- * encrypttoself, damit keine Angabe von -r immer noch zu einer
- abfrage führt.
-
* remove more "Fixmes"
- * Replace Blowfish by Twofish and add the new encrypted packet type
- which has a MACing option (append SHA1 hash to the plaintext and
- encrypt this all) - We need an identifier for Twofish to put this
- one into the cipher preferences.
-
- * The -export-dynamic flag to ld works only for FreeBSD 3.0. It does
- not exist on FreeBSD's 2.2.x version of ld.
- Also, on my FreeBSD 2.2-stable box, i simply removed the
- -Wl,-export-dynamic flag from my Makefile and it linked and seems to
- be working OK so far.
+ * Implement 256 bit key Twofish.
* Use capabilities if available.
@@ -55,6 +39,8 @@ Minor Bugs
implementaion to a create handle, make and release implemenation
and use an atexit to cleanup all pending locks. This is also
faster.
+ * --list-packets should continue even w/o a passphrase (or in batch
+ mode).
Nice to have
------------
diff --git a/checks/defs.inc b/checks/defs.inc
index 8b0aa255b..42ee1dca8 100755
--- a/checks/defs.inc
+++ b/checks/defs.inc
@@ -81,5 +81,6 @@ no-greeting
no-secmem-warning
load-extension ../cipher/tiger
batch
+lock-once
EOF
diff --git a/cipher/blowfish.c b/cipher/blowfish.c
index 8cffa8b3e..8bfce67c9 100644
--- a/cipher/blowfish.c
+++ b/cipher/blowfish.c
@@ -455,7 +455,7 @@ decrypt_block( BLOWFISH_context *bc, byte *outbuf, byte *inbuf )
static const char*
-selftest()
+selftest(void)
{
BLOWFISH_context c;
byte plain[] = "BLOWFISH";
diff --git a/cipher/blowfish.h b/cipher/blowfish.h
index b1d65f36c..827baa141 100644
--- a/cipher/blowfish.h
+++ b/cipher/blowfish.h
@@ -26,9 +26,9 @@
const char *
blowfish_get_info( int algo, size_t *keylen,
size_t *blocksize, size_t *contextsize,
- int (**setkey)( void *c, byte *key, unsigned keylen ),
- void (**encrypt)( void *c, byte *outbuf, byte *inbuf ),
- void (**decrypt)( void *c, byte *outbuf, byte *inbuf )
+ int (**setkeyf)( void *c, byte *key, unsigned keylen ),
+ void (**encryptf)( void *c, byte *outbuf, byte *inbuf ),
+ void (**decryptf)( void *c, byte *outbuf, byte *inbuf )
);
#endif /*G10_BLOWFISH_H*/
diff --git a/cipher/cast5.c b/cipher/cast5.c
index 6f131ca23..0e602bd2e 100644
--- a/cipher/cast5.c
+++ b/cipher/cast5.c
@@ -455,7 +455,7 @@ decrypt_block( CAST5_context *c, byte *outbuf, byte *inbuf )
static const char*
-selftest()
+selftest(void)
{
CAST5_context c;
byte key[16] = { 0x01, 0x23, 0x45, 0x67, 0x12, 0x34, 0x56, 0x78,
diff --git a/cipher/cast5.h b/cipher/cast5.h
index df7f16519..798eaa23f 100644
--- a/cipher/cast5.h
+++ b/cipher/cast5.h
@@ -25,9 +25,9 @@
const char *
cast5_get_info( int algo, size_t *keylen,
size_t *blocksize, size_t *contextsize,
- int (**setkey)( void *c, byte *key, unsigned keylen ),
- void (**encrypt)( void *c, byte *outbuf, byte *inbuf ),
- void (**decrypt)( void *c, byte *outbuf, byte *inbuf )
+ int (**setkeyf)( void *c, byte *key, unsigned keylen ),
+ void (**encryptf)( void *c, byte *outbuf, byte *inbuf ),
+ void (**decryptf)( void *c, byte *outbuf, byte *inbuf )
);
#endif /*G10_CAST5_H*/
diff --git a/cipher/cipher.c b/cipher/cipher.c
index 37d60251b..601165b71 100644
--- a/cipher/cipher.c
+++ b/cipher/cipher.c
@@ -77,7 +77,7 @@ dummy_decrypt_block( void *c, byte *outbuf, byte *inbuf ) { BUG(); }
* Put the static entries into the table.
*/
static void
-setup_cipher_table()
+setup_cipher_table(void)
{
int i;
@@ -146,7 +146,7 @@ setup_cipher_table()
* Try to load all modules and return true if new modules are available
*/
static int
-load_cipher_modules()
+load_cipher_modules(void)
{
static int done = 0;
static int initialized = 0;
diff --git a/cipher/des.h b/cipher/des.h
index cf2f320d8..f68560686 100644
--- a/cipher/des.h
+++ b/cipher/des.h
@@ -26,9 +26,9 @@
const char *
des_get_info( int algo, size_t *keylen,
size_t *blocksize, size_t *contextsize,
- int (**setkey)( void *c, byte *key, unsigned keylen ),
- void (**encrypt)( void *c, byte *outbuf, byte *inbuf ),
- void (**decrypt)( void *c, byte *outbuf, byte *inbuf )
+ int (**setkeyf)( void *c, byte *key, unsigned keylen ),
+ void (**encryptf)( void *c, byte *outbuf, byte *inbuf ),
+ void (**decryptf)( void *c, byte *outbuf, byte *inbuf )
);
#endif /*G10_DES_H*/
diff --git a/cipher/dsa.c b/cipher/dsa.c
index 7222df338..c8fcd66ef 100644
--- a/cipher/dsa.c
+++ b/cipher/dsa.c
@@ -412,7 +412,7 @@ dsa_get_nbits( int algo, MPI *pkey )
*/
const char *
dsa_get_info( int algo, int *npkey, int *nskey, int *nenc, int *nsig,
- int *usage )
+ int *use )
{
*npkey = 4;
*nskey = 5;
@@ -420,8 +420,8 @@ dsa_get_info( int algo, int *npkey, int *nskey, int *nenc, int *nsig,
*nsig = 2;
switch( algo ) {
- case PUBKEY_ALGO_DSA: *usage = PUBKEY_USAGE_SIG; return "DSA";
- default: *usage = 0; return NULL;
+ case PUBKEY_ALGO_DSA: *use = PUBKEY_USAGE_SIG; return "DSA";
+ default: *use = 0; return NULL;
}
}
diff --git a/cipher/dsa.h b/cipher/dsa.h
index e5bc8c7b8..1456d65b6 100644
--- a/cipher/dsa.h
+++ b/cipher/dsa.h
@@ -27,6 +27,6 @@ int dsa_verify( int algo, MPI hash, MPI *data, MPI *pkey,
int (*cmp)(void *, MPI), void *opaquev );
unsigned dsa_get_nbits( int algo, MPI *pkey );
const char *dsa_get_info( int algo, int *npkey, int *nskey,
- int *nenc, int *nsig, int *usage );
+ int *nenc, int *nsig, int *use );
#endif /*G10_DSA_H*/
diff --git a/cipher/dynload.c b/cipher/dynload.c
index b8c7c67d8..75dcb3969 100644
--- a/cipher/dynload.c
+++ b/cipher/dynload.c
@@ -101,15 +101,15 @@ register_cipher_extension( const char *mainpgm, const char *fname )
mainpgm_path = m_strdup(mainpgm);
#endif
if( *fname != '/' ) { /* do tilde expansion etc */
- char *p ;
+ char *tmp;
if( strchr(fname, '/') )
- p = make_filename(fname, NULL);
+ tmp = make_filename(fname, NULL);
else
- p = make_filename(GNUPG_LIBDIR, fname, NULL);
- el = m_alloc_clear( sizeof *el + strlen(p) );
- strcpy(el->name, p );
- m_free(p);
+ tmp = make_filename(GNUPG_LIBDIR, fname, NULL);
+ el = m_alloc_clear( sizeof *el + strlen(tmp) );
+ strcpy(el->name, tmp );
+ m_free(tmp);
}
else {
el = m_alloc_clear( sizeof *el + strlen(fname) );
@@ -371,9 +371,9 @@ enum_gnupgext_digests( void **enum_context,
const char *
enum_gnupgext_ciphers( void **enum_context, int *algo,
size_t *keylen, size_t *blocksize, size_t *contextsize,
- int (**setkey)( void *c, byte *key, unsigned keylen ),
- void (**encrypt)( void *c, byte *outbuf, byte *inbuf ),
- void (**decrypt)( void *c, byte *outbuf, byte *inbuf )
+ int (**setkeyf)( void *c, byte *key, unsigned keylen ),
+ void (**encryptf)( void *c, byte *outbuf, byte *inbuf ),
+ void (**decryptf)( void *c, byte *outbuf, byte *inbuf )
)
{
EXTLIST r;
@@ -419,7 +419,7 @@ enum_gnupgext_ciphers( void **enum_context, int *algo,
continue;
*algo = *(int*)sym;
algname = (*finfo)( *algo, keylen, blocksize, contextsize,
- setkey, encrypt, decrypt );
+ setkeyf, encryptf, decryptf );
if( algname ) {
ctx->r = r;
return algname;
@@ -435,11 +435,11 @@ enum_gnupgext_ciphers( void **enum_context, int *algo,
const char *
enum_gnupgext_pubkeys( void **enum_context, int *algo,
- int *npkey, int *nskey, int *nenc, int *nsig, int *usage,
+ int *npkey, int *nskey, int *nenc, int *nsig, int *use,
int (**generate)( int algo, unsigned nbits, MPI *skey, MPI **retfactors ),
int (**check_secret_key)( int algo, MPI *skey ),
- int (**encrypt)( int algo, MPI *resarr, MPI data, MPI *pkey ),
- int (**decrypt)( int algo, MPI *result, MPI *data, MPI *skey ),
+ int (**encryptf)( int algo, MPI *resarr, MPI data, MPI *pkey ),
+ int (**decryptf)( int algo, MPI *result, MPI *data, MPI *skey ),
int (**sign)( int algo, MPI *resarr, MPI data, MPI *skey ),
int (**verify)( int algo, MPI hash, MPI *data, MPI *pkey,
int (*cmp)(void *, MPI), void *opaquev ),
@@ -491,9 +491,9 @@ enum_gnupgext_pubkeys( void **enum_context, int *algo,
if( vers != 1 || class != 31 )
continue;
*algo = *(int*)sym;
- algname = (*finfo)( *algo, npkey, nskey, nenc, nsig, usage,
- generate, check_secret_key, encrypt,
- decrypt, sign, verify, get_nbits );
+ algname = (*finfo)( *algo, npkey, nskey, nenc, nsig, use,
+ generate, check_secret_key, encryptf,
+ decryptf, sign, verify, get_nbits );
if( algname ) {
ctx->r = r;
return algname;
diff --git a/cipher/dynload.h b/cipher/dynload.h
index 792531cf0..af8940712 100644
--- a/cipher/dynload.h
+++ b/cipher/dynload.h
@@ -37,19 +37,19 @@ enum_gnupgext_digests( void **enum_context,
const char *
enum_gnupgext_ciphers( void **enum_context, int *algo,
size_t *keylen, size_t *blocksize, size_t *contextsize,
- int (**setkey)( void *c, byte *key, unsigned keylen ),
- void (**encrypt)( void *c, byte *outbuf, byte *inbuf ),
- void (**decrypt)( void *c, byte *outbuf, byte *inbuf )
+ int (**setkeyf)( void *c, byte *key, unsigned keylen ),
+ void (**encryptf)( void *c, byte *outbuf, byte *inbuf ),
+ void (**decryptf)( void *c, byte *outbuf, byte *inbuf )
);
const char *
enum_gnupgext_pubkeys( void **enum_context, int *algo,
- int *npkey, int *nskey, int *nenc, int *nsig, int *usage,
+ int *npkey, int *nskey, int *nenc, int *nsig, int *use,
int (**generate)( int algo, unsigned nbits, MPI *skey, MPI **retfactors ),
int (**check_secret_key)( int algo, MPI *skey ),
- int (**encrypt)( int algo, MPI *resarr, MPI data, MPI *pkey ),
- int (**decrypt)( int algo, MPI *result, MPI *data, MPI *skey ),
+ int (**encryptf)( int algo, MPI *resarr, MPI data, MPI *pkey ),
+ int (**decryptf)( int algo, MPI *result, MPI *data, MPI *skey ),
int (**sign)( int algo, MPI *resarr, MPI data, MPI *skey ),
int (**verify)( int algo, MPI hash, MPI *data, MPI *pkey,
int (*cmp)(void *, MPI), void *opaquev ),
diff --git a/cipher/elgamal.c b/cipher/elgamal.c
index 9a9b35629..90d5aca18 100644
--- a/cipher/elgamal.c
+++ b/cipher/elgamal.c
@@ -109,9 +109,9 @@ gen_k( MPI p )
for(;;) {
if( DBG_CIPHER )
fputc('.', stderr);
- { char *p = get_random_bits( nbits, 1, 1 );
- mpi_set_buffer( k, p, (nbits+7)/8, 0 );
- m_free(p);
+ { char *pp = get_random_bits( nbits, 1, 1 );
+ mpi_set_buffer( k, pp, (nbits+7)/8, 0 );
+ m_free(pp);
/* make sure that the number is of the exact lenght */
if( mpi_test_bit( k, nbits-1 ) )
mpi_set_highbit( k, nbits-1 );
@@ -530,7 +530,7 @@ elg_get_nbits( int algo, MPI *pkey )
*/
const char *
elg_get_info( int algo, int *npkey, int *nskey, int *nenc, int *nsig,
- int *usage )
+ int *use )
{
*npkey = 3;
*nskey = 4;
@@ -539,12 +539,12 @@ elg_get_info( int algo, int *npkey, int *nskey, int *nenc, int *nsig,
switch( algo ) {
case PUBKEY_ALGO_ELGAMAL:
- *usage = PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC;
+ *use = PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC;
return "ELG";
case PUBKEY_ALGO_ELGAMAL_E:
- *usage = PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC;
+ *use = PUBKEY_USAGE_SIG|PUBKEY_USAGE_ENC;
return "ELG-E";
- default: *usage = 0; return NULL;
+ default: *use = 0; return NULL;
}
}
diff --git a/cipher/elgamal.h b/cipher/elgamal.h
index ac708a9bb..f104c2a52 100644
--- a/cipher/elgamal.h
+++ b/cipher/elgamal.h
@@ -29,7 +29,7 @@ int elg_verify( int algo, MPI hash, MPI *data, MPI *pkey,
int (*cmp)(void *, MPI), void *opaquev );
unsigned elg_get_nbits( int algo, MPI *pkey );
const char *elg_get_info( int algo, int *npkey, int *nskey,
- int *nenc, int *nsig, int *usage );
+ int *nenc, int *nsig, int *use );
#endif /*G10_ELGAMAL_H*/
diff --git a/cipher/md.c b/cipher/md.c
index 6c4d1124b..95167ff49 100644
--- a/cipher/md.c
+++ b/cipher/md.c
@@ -479,15 +479,15 @@ md_asn_oid( int algo, size_t *asnlen, size_t *mdlen )
void
md_start_debug( MD_HANDLE md, const char *suffix )
{
- static int index=0;
+ static int idx=0;
char buf[25];
if( md->debug ) {
log_debug("Oops: md debug already started\n");
return;
}
- index++;
- sprintf(buf, "dbgmd-%05d.%.10s", index, suffix );
+ idx++;
+ sprintf(buf, "dbgmd-%05d.%.10s", idx, suffix );
md->debug = fopen(buf, "w");
if( !md->debug )
log_debug("md debug: can't open %s\n", buf );
diff --git a/cipher/pubkey.c b/cipher/pubkey.c
index 58ba00007..dbdd8ae2b 100644
--- a/cipher/pubkey.c
+++ b/cipher/pubkey.c
@@ -42,7 +42,7 @@ struct pubkey_table_s {
int nskey;
int nenc;
int nsig;
- int usage;
+ int use;
int (*generate)( int algo, unsigned nbits, MPI *skey, MPI **retfactors );
int (*check_secret_key)( int algo, MPI *skey );
int (*encrypt)( int algo, MPI *resarr, MPI data, MPI *pkey );
@@ -91,7 +91,7 @@ dummy_get_nbits( int algo, MPI *pkey )
* Put the static entries into the table.
*/
static void
-setup_pubkey_table()
+setup_pubkey_table(void)
{
int i;
@@ -102,7 +102,7 @@ setup_pubkey_table()
&pubkey_table[i].nskey,
&pubkey_table[i].nenc,
&pubkey_table[i].nsig,
- &pubkey_table[i].usage );
+ &pubkey_table[i].use );
pubkey_table[i].generate = elg_generate;
pubkey_table[i].check_secret_key = elg_check_secret_key;
pubkey_table[i].encrypt = elg_encrypt;
@@ -119,7 +119,7 @@ setup_pubkey_table()
&pubkey_table[i].nskey,
&pubkey_table[i].nenc,
&pubkey_table[i].nsig,
- &pubkey_table[i].usage );
+ &pubkey_table[i].use );
pubkey_table[i].generate = elg_generate;
pubkey_table[i].check_secret_key = elg_check_secret_key;
pubkey_table[i].encrypt = elg_encrypt;
@@ -136,7 +136,7 @@ setup_pubkey_table()
&pubkey_table[i].nskey,
&pubkey_table[i].nenc,
&pubkey_table[i].nsig,
- &pubkey_table[i].usage );
+ &pubkey_table[i].use );
pubkey_table[i].generate = dsa_generate;
pubkey_table[i].check_secret_key = dsa_check_secret_key;
pubkey_table[i].encrypt = dummy_encrypt;
@@ -157,7 +157,7 @@ setup_pubkey_table()
* Try to load all modules and return true if new modules are available
*/
static int
-load_pubkey_modules()
+load_pubkey_modules(void)
{
static int initialized = 0;
static int done = 0;
@@ -187,7 +187,7 @@ load_pubkey_modules()
/* now load all extensions */
while( (name = enum_gnupgext_pubkeys( &context, &ct->algo,
&ct->npkey, &ct->nskey, &ct->nenc,
- &ct->nsig, &ct->usage,
+ &ct->nsig, &ct->use,
&ct->generate,
&ct->check_secret_key,
&ct->encrypt,
@@ -273,21 +273,21 @@ check_pubkey_algo( int algo )
}
/****************
- * a usage of 0 means: don't care
+ * a use of 0 means: don't care
*/
int
-check_pubkey_algo2( int algo, unsigned usage )
+check_pubkey_algo2( int algo, unsigned use )
{
int i;
do {
for(i=0; pubkey_table[i].name; i++ )
if( pubkey_table[i].algo == algo ) {
- if( (usage & PUBKEY_USAGE_SIG)
- && !(pubkey_table[i].usage & PUBKEY_USAGE_SIG) )
+ if( (use & PUBKEY_USAGE_SIG)
+ && !(pubkey_table[i].use & PUBKEY_USAGE_SIG) )
return G10ERR_WR_PUBKEY_ALGO;
- if( (usage & PUBKEY_USAGE_ENC)
- && !(pubkey_table[i].usage & PUBKEY_USAGE_ENC) )
+ if( (use & PUBKEY_USAGE_ENC)
+ && !(pubkey_table[i].use & PUBKEY_USAGE_ENC) )
return G10ERR_WR_PUBKEY_ALGO;
return 0; /* okay */
}
diff --git a/cipher/random.c b/cipher/random.c
index bcd017d4c..eedfcfa65 100644
--- a/cipher/random.c
+++ b/cipher/random.c
@@ -106,7 +106,7 @@ static int gather_faked( void (*add)(const void*, size_t, int), int requester,
static void
-initialize()
+initialize(void)
{
/* The data buffer is allocated somewhat larger, so that
* we can use this extra space (which is allocated in secure memory)
diff --git a/cipher/rndunix.c b/cipher/rndunix.c
index 0132cd901..b7381a55c 100644
--- a/cipher/rndunix.c
+++ b/cipher/rndunix.c
@@ -401,11 +401,8 @@ slow_poll(FILE *dbgfp, int dbgall, size_t *nbytes )
fd_set fds;
#if defined( __hpux )
size_t maxFD = 0;
- int pageSize = 4096; /* PHUX doesn't have getpagesize() */
- #elif defined( _M_XENIX ) || defined( __aux )
- int maxFD = 0, pageSize = 4096;/* Nor do others, but they get fd right */
#else
- int maxFD = 0, pageSize = getpagesize();
+ int maxFD = 0;
#endif /* OS-specific brokenness */
int bufPos, i, usefulness = 0;
diff --git a/configure.in b/configure.in
index e16954361..f912ec4e2 100644
--- a/configure.in
+++ b/configure.in
@@ -90,9 +90,9 @@ dnl AC_CYGWIN32
MPI_OPT_FLAGS=""
if test "$GCC" = yes; then
- CFLAGS="$CFLAGS -Wall"
+ CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
dnl Always enable optimazation in MPI
- if echo "$CFLAGS" | grep "[-]O" >/dev/null ; then
+ if (echo "$CFLAGS" | grep '[-]O') >/dev/null ; then
:
else
MPI_OPT_FLAGS=-O2
@@ -129,6 +129,13 @@ case "${target}" in
CFLAGS="$CFLAGS -Ae -D_HPUX_SOURCE"
fi
;;
+ *-dec-osf4*)
+ if test -z "$GCC" ; then
+ # Suppress all warnings
+ # to get rid of the unsigned/signed char mismatch warnings.
+ CFLAGS="$CFLAGS -w"
+ fi
+ ;;
m68k-atari-mint)
;;
*)
@@ -188,6 +195,10 @@ if test "$try_gdbm" = yes; then
AC_CHECK_LIB(gdbm,gdbm_firstkey)
fi
+dnl Solaris needs -lsocket and -lnsl
+AC_CHECK_LIB(socket, socket)
+AC_CHECK_LIB(nsl, gethostbyname)
+
if test "$try_dynload" = yes ; then
AC_CHECK_LIB(dl,dlopen)
diff --git a/doc/gpg.1pod b/doc/gpg.1pod
index f7e5a4ce8..2ac02cecc 100644
--- a/doc/gpg.1pod
+++ b/doc/gpg.1pod
@@ -254,9 +254,16 @@ B<--trusted-key> I<keyid>
your key.
B<-r> I<name>, B<--recipient> I<name>
- Use I<name> as the user-id for encryption.
- This option is silently ignored for the list commands,
- so that it can be used in an options file.
+ Encrypt for user id I<name>. If this option is not
+ specified, GnuPG asks for the user id.
+
+B<--encrypt-to> I<name>
+ Same as B<--recipient> but this one is intended for
+ in the options file and may be used together with
+ an own user-id as an "encrypt-to-self". These keys
+ are only used when there are other recipients given
+ either by use of --recipient or by the asked user id.
+ No trust checking is performed for these user ids.
B<-v>, B<--verbose>
Give more information during processing. If used
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 996c6cf1a..be12cba2f 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,15 @@
+Tue Feb 16 14:10:02 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * g10.c (main): New option --encrypt-to
+
+ * pkclist.c (build_pk_list): Implemented encrypt-to.
+
+ * parse-packet.c (parse_user_id): Removed the hack to work with
+ utf-8 strings.
+
+ * g10.c (main): Install lockfile cleanup handler.
+ * tdbio.c (cleanup): Removed: this is now handled by dotlock.
+
Sat Feb 13 14:13:04 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* tdbio.c (tdbio_set_dbname): Init lockhandle for a new trustdb
diff --git a/g10/armor.c b/g10/armor.c
index 5aba3322a..80cddf5ca 100644
--- a/g10/armor.c
+++ b/g10/armor.c
@@ -608,15 +608,16 @@ radix64_read( armor_filter_context_t *afx, IOBUF a, size_t *retn,
/* some mailers leave quoted-printable encoded characters
* so we try to workaround this */
if( afx->buffer_pos+2 < afx->buffer_len ) {
- int c1, c2, c3;
- c1 = afx->buffer[afx->buffer_pos];
- c2 = afx->buffer[afx->buffer_pos+1];
- c3 = afx->buffer[afx->buffer_pos+2];
- if( isxdigit(c1) && isxdigit(c2) && strchr( "=\n\r\t ", c3 )) {
+ int cc1, cc2, cc3;
+ cc1 = afx->buffer[afx->buffer_pos];
+ cc2 = afx->buffer[afx->buffer_pos+1];
+ cc3 = afx->buffer[afx->buffer_pos+2];
+ if( isxdigit(cc1) && isxdigit(cc2)
+ && strchr( "=\n\r\t ", cc3 )) {
/* well it seems to be the case - adjust */
- c = isdigit(c1)? (c1 - '0'): (toupper(c1)-'A'+10);
+ c = isdigit(cc1)? (cc1 - '0'): (toupper(cc1)-'A'+10);
c <<= 4;
- c |= isdigit(c2)? (c2 - '0'): (toupper(c2)-'A'+10);
+ c |= isdigit(cc2)? (cc2 - '0'): (toupper(cc2)-'A'+10);
afx->buffer_pos += 2;
afx->qp_detected = 1;
goto again;
diff --git a/g10/build-packet.c b/g10/build-packet.c
index a1eb12623..85c73b0e0 100644
--- a/g10/build-packet.c
+++ b/g10/build-packet.c
@@ -677,20 +677,20 @@ do_signature( IOBUF out, int ctb, PKT_signature *sig )
iobuf_put(a, sig->pubkey_algo );
iobuf_put(a, sig->digest_algo );
if( sig->version >= 4 ) {
- size_t n;
+ size_t nn;
/* timestamp and keyid must have been packed into the
* subpackets prior to the call of this function, because
* these subpackets are hashed */
- n = sig->hashed_data?((sig->hashed_data[0]<<8)
- |sig->hashed_data[1]) :0;
- write_16(a, n);
- if( n )
- iobuf_write( a, sig->hashed_data+2, n );
- n = sig->unhashed_data?((sig->unhashed_data[0]<<8)
- |sig->unhashed_data[1]) :0;
- write_16(a, n);
- if( n )
- iobuf_write( a, sig->unhashed_data+2, n );
+ nn = sig->hashed_data?((sig->hashed_data[0]<<8)
+ |sig->hashed_data[1]) :0;
+ write_16(a, nn);
+ if( nn )
+ iobuf_write( a, sig->hashed_data+2, nn );
+ nn = sig->unhashed_data?((sig->unhashed_data[0]<<8)
+ |sig->unhashed_data[1]) :0;
+ write_16(a, nn);
+ if( nn )
+ iobuf_write( a, sig->unhashed_data+2, nn );
}
iobuf_put(a, sig->digest_start[0] );
iobuf_put(a, sig->digest_start[1] );
diff --git a/g10/g10.c b/g10/g10.c
index df35870b7..0fbc4c646 100644
--- a/g10/g10.c
+++ b/g10/g10.c
@@ -156,6 +156,7 @@ enum cmd_and_opt_values { aNull = 0,
oEscapeFrom,
oLockOnce,
oKeyServer,
+ oEncryptTo,
aTest };
@@ -218,6 +219,7 @@ static ARGPARSE_OPTS opts[] = {
{ oArmor, "armor", 0, N_("create ascii armored output")},
{ oRecipient, "recipient", 2, N_("|NAME|encrypt for NAME")},
{ oRecipient, "remote-user", 2, "@"}, /* old option name */
+ { oEncryptTo, "encrypt-to", 2, "@" },
#ifdef IS_G10
{ oUser, "local-user",2, N_("use this user-id to sign or decrypt")},
{ oCompress, NULL, 1, N_("|N|set compress level N (0 disables)") },
@@ -541,6 +543,7 @@ main( int argc, char **argv )
disable_core_dumps();
#endif
init_signals();
+ create_dotlock(NULL); /* register locking cleanup */
i18n_init();
opt.compress = -1; /* defaults to standard compress level */
/* fixme: set the next two to zero and decide where used */
@@ -761,6 +764,13 @@ main( int argc, char **argv )
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 oEncryptTo: /* store the recipient in the second list */
+ sl = m_alloc( sizeof *sl + strlen(pargs.r.ret_str));
+ strcpy(sl->d, pargs.r.ret_str);
+ sl->flags = 1;
+ sl->next = remusr;
+ remusr = sl;
+ break;
#ifdef IS_G10
case oRecipient: /* store the recipient */
sl = m_alloc( sizeof *sl + strlen(pargs.r.ret_str));
diff --git a/g10/keydb.h b/g10/keydb.h
index 9a7dcc869..b648c271b 100644
--- a/g10/keydb.h
+++ b/g10/keydb.h
@@ -111,13 +111,13 @@ struct pubkey_find_info {
/*-- pkclist.c --*/
int check_signatures_trust( PKT_signature *sig );
void release_pk_list( PK_LIST pk_list );
-int build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned usage );
+int build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use );
int select_algo_from_prefs( PK_LIST pk_list, int preftype );
/*-- skclist.c --*/
void release_sk_list( SK_LIST sk_list );
int build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list,
- int unlock, unsigned usage );
+ int unlock, unsigned use );
/*-- passphrase.h --*/
int have_static_passphrase(void);
diff --git a/g10/keyedit.c b/g10/keyedit.c
index 197ede4e6..f6e06c036 100644
--- a/g10/keyedit.c
+++ b/g10/keyedit.c
@@ -49,8 +49,8 @@ static int menu_adduid( KBNODE keyblock, KBNODE sec_keyblock );
static void menu_deluid( KBNODE pub_keyblock, KBNODE sec_keyblock );
static void menu_delkey( KBNODE pub_keyblock, KBNODE sec_keyblock );
static int menu_expire( KBNODE pub_keyblock, KBNODE sec_keyblock );
-static int menu_select_uid( KBNODE keyblock, int index );
-static int menu_select_key( KBNODE keyblock, int index );
+static int menu_select_uid( KBNODE keyblock, int idx );
+static int menu_select_key( KBNODE keyblock, int idx );
static int count_uids( KBNODE keyblock );
static int count_uids_with_flag( KBNODE keyblock, unsigned flag );
static int count_keys_with_flag( KBNODE keyblock, unsigned flag );
@@ -1309,21 +1309,21 @@ menu_expire( KBNODE pub_keyblock, KBNODE sec_keyblock )
* Returns: True if the selection changed;
*/
static int
-menu_select_uid( KBNODE keyblock, int index )
+menu_select_uid( KBNODE keyblock, int idx )
{
KBNODE node;
int i;
/* first check that the index is valid */
- if( index ) {
+ if( idx ) {
for( i=0, node = keyblock; node; node = node->next ) {
if( node->pkt->pkttype == PKT_USER_ID ) {
- if( ++i == index )
+ if( ++i == idx )
break;
}
}
if( !node ) {
- tty_printf(_("No user id with index %d\n"), index );
+ tty_printf(_("No user id with index %d\n"), idx );
return 0;
}
}
@@ -1337,7 +1337,7 @@ menu_select_uid( KBNODE keyblock, int index )
/* and toggle the new index */
for( i=0, node = keyblock; node; node = node->next ) {
if( node->pkt->pkttype == PKT_USER_ID ) {
- if( ++i == index )
+ if( ++i == idx )
if( (node->flag & NODFLG_SELUID) )
node->flag &= ~NODFLG_SELUID;
else
@@ -1353,22 +1353,22 @@ menu_select_uid( KBNODE keyblock, int index )
* Returns: True if the selection changed;
*/
static int
-menu_select_key( KBNODE keyblock, int index )
+menu_select_key( KBNODE keyblock, int idx )
{
KBNODE node;
int i;
/* first check that the index is valid */
- if( index ) {
+ if( idx ) {
for( i=0, node = keyblock; node; node = node->next ) {
if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY
|| node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
- if( ++i == index )
+ if( ++i == idx )
break;
}
}
if( !node ) {
- tty_printf(_("No secondary key with index %d\n"), index );
+ tty_printf(_("No secondary key with index %d\n"), idx );
return 0;
}
}
@@ -1384,7 +1384,7 @@ menu_select_key( KBNODE keyblock, int index )
for( i=0, node = keyblock; node; node = node->next ) {
if( node->pkt->pkttype == PKT_PUBLIC_SUBKEY
|| node->pkt->pkttype == PKT_SECRET_SUBKEY ) {
- if( ++i == index )
+ if( ++i == idx )
if( (node->flag & NODFLG_SELKEY) )
node->flag &= ~NODFLG_SELKEY;
else
diff --git a/g10/keygen.c b/g10/keygen.c
index 12fa9422c..dd812e729 100644
--- a/g10/keygen.c
+++ b/g10/keygen.c
@@ -488,7 +488,7 @@ ask_keysize( int algo )
static u32
-ask_expire_interval()
+ask_expire_interval(void)
{
char *answer;
int valid_days=0;
diff --git a/g10/main.h b/g10/main.h
index 2aa946bb2..6078de2f1 100644
--- a/g10/main.h
+++ b/g10/main.h
@@ -72,7 +72,7 @@ int encrypt_filter( void *opaque, int control,
/*-- sign.c --*/
int complete_sig( PKT_signature *sig, PKT_secret_key *sk, MD_HANDLE md );
int sign_file( STRLIST filenames, int detached, STRLIST locusr,
- int encrypt, STRLIST remusr, const char *outfile );
+ int do_encrypt, STRLIST remusr, const char *outfile );
int clearsign_file( const char *fname, STRLIST locusr, const char *outfile );
/*-- sig-check.c --*/
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index 3c45a45b4..40c737c39 100644
--- a/g10/parse-packet.c
+++ b/g10/parse-packet.c
@@ -1400,19 +1400,8 @@ parse_user_id( IOBUF inp, int pkttype, unsigned long pktlen, PACKET *packet )
packet->pkt.user_id = m_alloc(sizeof *packet->pkt.user_id + pktlen);
packet->pkt.user_id->len = pktlen;
p = packet->pkt.user_id->name;
- for( ; pktlen; pktlen--, p++ ) {
+ for( ; pktlen; pktlen--, p++ )
*p = iobuf_get_noeof(inp);
- /* 0xff is not a valid utf-8 encoding so we can use it to replace
- * Nulls. This has the advantage that we can work with regular
- * C strings. When exporting it, we change it back to Null
- * the utf-8 functions know about this special convention.
- * The advantage of this single character is that we can
- * simple replace it. Problem is that we can't handle the 0xff
- * character which may have been used by pref rfc2440 implementations
- * I hope we can live with this. */
- if( !*p )
- *p = 0xff;
- }
*p = 0;
if( list_mode ) {
diff --git a/g10/pkclist.c b/g10/pkclist.c
index f579fc37f..81e23b127 100644
--- a/g10/pkclist.c
+++ b/g10/pkclist.c
@@ -511,13 +511,43 @@ release_pk_list( PK_LIST pk_list )
}
int
-build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned usage )
+build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use )
{
PK_LIST pk_list = NULL;
PKT_public_key *pk=NULL;
int rc=0;
+ int any_recipients=0;
+ STRLIST rov;
+
+ /* check whether there are any recipients in the list and build the
+ * list of the encrypt-to ones (we always trust them) */
+ for( rov = remusr; rov; rov = rov->next ) {
+ if( !(rov->flags & 1) )
+ any_recipients = 1;
+ else if( (use & PUBKEY_USAGE_ENC) ) {
+ pk = m_alloc_clear( sizeof *pk );
+ pk->pubkey_usage = use;
+ if( (rc = get_pubkey_byname( NULL, pk, rov->d, NULL )) ) {
+ free_public_key( pk ); pk = NULL;
+ log_error(_("%s: skipped: %s\n"), rov->d, g10_errstr(rc) );
+ }
+ else if( !(rc=check_pubkey_algo2(pk->pubkey_algo, use )) ) {
+ PK_LIST r;
+
+ r = m_alloc( sizeof *r );
+ r->pk = pk; pk = NULL;
+ r->next = pk_list;
+ r->mark = 0;
+ pk_list = r;
+ }
+ else {
+ free_public_key( pk ); pk = NULL;
+ log_error(_("%s: skipped: %s\n"), rov->d, g10_errstr(rc) );
+ }
+ }
+ }
- if( !remusr && !opt.batch ) { /* ask */
+ if( !any_recipients && !opt.batch ) { /* ask */
char *answer=NULL;
tty_printf(_(
@@ -534,11 +564,11 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned usage )
if( pk )
free_public_key( pk );
pk = m_alloc_clear( sizeof *pk );
- pk->pubkey_usage = usage;
+ pk->pubkey_usage = use;
rc = get_pubkey_byname( NULL, pk, answer, NULL );
if( rc )
tty_printf(_("No such user ID.\n"));
- else if( !(rc=check_pubkey_algo2(pk->pubkey_algo, usage)) ) {
+ else if( !(rc=check_pubkey_algo2(pk->pubkey_algo, use)) ) {
int trustlevel;
rc = check_trust( pk, &trustlevel );
@@ -554,6 +584,7 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned usage )
r->next = pk_list;
r->mark = 0;
pk_list = r;
+ any_recipients = 1;
break;
}
}
@@ -568,12 +599,12 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned usage )
for(; remusr; remusr = remusr->next ) {
pk = m_alloc_clear( sizeof *pk );
- pk->pubkey_usage = usage;
+ pk->pubkey_usage = use;
if( (rc = get_pubkey_byname( NULL, pk, remusr->d, NULL )) ) {
free_public_key( pk ); pk = NULL;
log_error(_("%s: skipped: %s\n"), remusr->d, g10_errstr(rc) );
}
- else if( !(rc=check_pubkey_algo2(pk->pubkey_algo, usage )) ) {
+ else if( !(rc=check_pubkey_algo2(pk->pubkey_algo, use )) ) {
int trustlevel;
rc = check_trust( pk, &trustlevel );
@@ -591,6 +622,7 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned usage )
r->next = pk_list;
r->mark = 0;
pk_list = r;
+ any_recipients = 1;
}
else { /* we don't trust this pk */
free_public_key( pk ); pk = NULL;
@@ -603,8 +635,7 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned usage )
}
}
-
- if( !rc && !pk_list ) {
+ if( !rc && !any_recipients ) {
log_error(_("no valid addressees\n"));
rc = G10ERR_NO_USER_ID;
}
diff --git a/g10/seckey-cert.c b/g10/seckey-cert.c
index 7712036e4..cab99b65b 100644
--- a/g10/seckey-cert.c
+++ b/g10/seckey-cert.c
@@ -226,8 +226,8 @@ protect_secret_key( PKT_secret_key *sk, DEK *dek )
cipher_encrypt( cipher_hd, sk->protect.iv, sk->protect.iv, 8 );
if( sk->version >= 4 ) {
#define NMPIS (PUBKEY_MAX_NSKEY - PUBKEY_MAX_NPKEY)
- byte *buffer[NMPIS];
- unsigned nbytes[NMPIS];
+ byte *bufarr[NMPIS];
+ unsigned narr[NMPIS];
unsigned nbits[NMPIS];
int ndata=0;
byte *p, *data;
@@ -235,23 +235,23 @@ protect_secret_key( PKT_secret_key *sk, DEK *dek )
for(j=0, i = pubkey_get_npkey(sk->pubkey_algo);
i < pubkey_get_nskey(sk->pubkey_algo); i++, j++ ) {
assert( !mpi_is_opaque( sk->skey[i] ) );
- buffer[j] = mpi_get_buffer( sk->skey[i], &nbytes[j], NULL );
+ bufarr[j] = mpi_get_buffer( sk->skey[i], &narr[j], NULL );
nbits[j] = mpi_get_nbits( sk->skey[i] );
- ndata += nbytes[j] + 2;
+ ndata += narr[j] + 2;
}
for( ; j < NMPIS; j++ )
- buffer[j] = NULL;
+ bufarr[j] = NULL;
ndata += 2; /* for checksum */
data = m_alloc_secure( ndata );
p = data;
- for(j=0; j < NMPIS && buffer[j]; j++ ) {
+ for(j=0; j < NMPIS && bufarr[j]; j++ ) {
p[0] = nbits[j] >> 8 ;
p[1] = nbits[j];
p += 2;
- memcpy(p, buffer[j], nbytes[j] );
- p += nbytes[j];
- m_free(buffer[j]);
+ memcpy(p, bufarr[j], narr[j] );
+ p += narr[j];
+ m_free(bufarr[j]);
}
#undef NMPIS
csum = checksum( data, ndata-2);
diff --git a/g10/skclist.c b/g10/skclist.c
index 74ae2a804..df8b683f3 100644
--- a/g10/skclist.c
+++ b/g10/skclist.c
@@ -62,7 +62,7 @@ is_insecure( PKT_secret_key *sk )
int
build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list, int unlock,
- unsigned usage )
+ unsigned use )
{
SK_LIST sk_list = NULL;
int rc;
@@ -71,14 +71,14 @@ build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list, int unlock,
PKT_secret_key *sk;
sk = m_alloc_clear( sizeof *sk );
- sk->pubkey_usage = usage;
+ sk->pubkey_usage = use;
if( (rc = get_seckey_byname( sk, NULL, unlock )) ) {
free_secret_key( sk ); sk = NULL;
log_error("no default secret key: %s\n", g10_errstr(rc) );
}
- else if( !(rc=check_pubkey_algo2(sk->pubkey_algo, usage)) ) {
+ else if( !(rc=check_pubkey_algo2(sk->pubkey_algo, use)) ) {
SK_LIST r;
- if( sk->version == 4 && (usage & PUBKEY_USAGE_SIG)
+ if( sk->version == 4 && (use & PUBKEY_USAGE_SIG)
&& sk->pubkey_algo == PUBKEY_ALGO_ELGAMAL_E ) {
log_info("this is a PGP generated "
"ElGamal key which is NOT secure for signatures!\n");
@@ -107,14 +107,14 @@ build_sk_list( STRLIST locusr, SK_LIST *ret_sk_list, int unlock,
PKT_secret_key *sk;
sk = m_alloc_clear( sizeof *sk );
- sk->pubkey_usage = usage;
+ sk->pubkey_usage = use;
if( (rc = get_seckey_byname( sk, locusr->d, unlock )) ) {
free_secret_key( sk ); sk = NULL;
log_error(_("skipped `%s': %s\n"), locusr->d, g10_errstr(rc) );
}
- else if( !(rc=check_pubkey_algo2(sk->pubkey_algo, usage)) ) {
+ else if( !(rc=check_pubkey_algo2(sk->pubkey_algo, use)) ) {
SK_LIST r;
- if( sk->version == 4 && (usage & PUBKEY_USAGE_SIG)
+ if( sk->version == 4 && (use & PUBKEY_USAGE_SIG)
&& sk->pubkey_algo == PUBKEY_ALGO_ELGAMAL_E ) {
log_info(_("skipped `%s': this is a PGP generated "
"ElGamal key which is not secure for signatures!\n"),
diff --git a/g10/tdbio.c b/g10/tdbio.c
index 6aaa18012..3ba238c2f 100644
--- a/g10/tdbio.c
+++ b/g10/tdbio.c
@@ -514,7 +514,8 @@ open_db()
TRUSTREC rec;
assert( db_fd == -1 );
- lockhandle = create_dotlock( db_name );
+ if( !lockhandle )
+ lockhandle = create_dotlock( db_name );
if( !lockhandle )
log_fatal( _("%s: can't create lock\n"), db_name );
#ifdef HAVE_DOSISH_SYSTEM
@@ -611,7 +612,7 @@ tdbio_db_matches_options()
* Return the record number of the keyhash tbl or create a new one.
*/
static ulong
-get_keyhashrec()
+get_keyhashrec(void)
{
static ulong keyhashtbl; /* record number of the key hashtable */
@@ -636,7 +637,7 @@ get_keyhashrec()
* or create a new one.
*/
static ulong
-get_sdirhashrec()
+get_sdirhashrec(void)
{
static ulong sdirhashtbl; /* record number of the hashtable */
diff --git a/g10/trustdb.c b/g10/trustdb.c
index 34890c2da..119e186b5 100644
--- a/g10/trustdb.c
+++ b/g10/trustdb.c
@@ -115,7 +115,7 @@ static int get_dir_record( PKT_public_key *pk, TRUSTREC *rec );
static void upd_pref_record( TRUSTREC *urec, u32 *keyid, PKT_signature *sig );
static void upd_cert_record( KBNODE keyblock, KBNODE signode, u32 *keyid,
TRUSTREC *drec, RECNO_LIST *recno_list, int recheck,
- TRUSTREC *urec, const byte *uidhash, int revoke );
+ TRUSTREC *urec, const byte *uidhash, int revoked );
static struct keyid_list *trusted_key_list;
@@ -138,7 +138,7 @@ static struct local_id_item *unused_lid_items;
**********************************************/
static void
-die_invalid_db()
+die_invalid_db(void)
{
log_error(_(
"The trustdb is corrupted; please run \"gpgm --fix-trustdb\".\n") );
@@ -192,7 +192,7 @@ delete_record( ulong recno )
* sync the db
*/
static void
-do_sync( )
+do_sync(void)
{
int rc = tdbio_sync();
if( !rc )
@@ -480,7 +480,7 @@ register_trusted_key( const char *string )
* Verify that all our public keys are in the trustdb.
*/
static int
-verify_own_keys()
+verify_own_keys(void)
{
int rc;
void *enum_context = NULL;
@@ -2111,7 +2111,7 @@ check_hint_sig( ulong lid, KBNODE keyblock, u32 *keyid, byte *uidrec_hash,
PKT_signature *sigpkt = NULL;
TRUSTREC tmp;
u32 sigkid[2];
- int revoke = 0;
+ int revoked = 0;
if( sigrec->r.sig.sig[sigidx].flag & SIGF_CHECKED )
log_info(_("NOTE: sig rec %lu[%d] in hintlist "
@@ -2156,7 +2156,7 @@ check_hint_sig( ulong lid, KBNODE keyblock, u32 *keyid, byte *uidrec_hash,
if( sigpkt->keyid[0] == sigkid[0]
&& sigpkt->keyid[1] == sigkid[1]
&& ( (sigpkt->sig_class&~3) == 0x10
- || ( revoke = (sigpkt->sig_class == 0x30)) ) ) {
+ || ( revoked = (sigpkt->sig_class == 0x30)) ) ) {
state = 2;
break; /* found */
}
@@ -2186,10 +2186,10 @@ check_hint_sig( ulong lid, KBNODE keyblock, u32 *keyid, byte *uidrec_hash,
log_info("sig %08lX.%lu/%02X%02X/%08lX: %s\n",
(ulong)keyid[1], lid, uhash[18], uhash[19],
(ulong)sigpkt->keyid[1],
- revoke? _("Valid certificate revocation")
- : _("Good certificate") );
+ revoked? _("Valid certificate revocation")
+ : _("Good certificate") );
sigrec->r.sig.sig[sigidx].flag = SIGF_CHECKED | SIGF_VALID;
- if( revoke )
+ if( revoked )
sigrec->r.sig.sig[sigidx].flag |= SIGF_REVOKED;
}
else if( rc == G10ERR_NO_PUBKEY ) {
@@ -2779,9 +2779,9 @@ upd_pref_record( TRUSTREC *urec, u32 *keyid, PKT_signature *sig )
else { /* need more than one pref record */
TRUSTREC tmp;
ulong nextrn;
- int n = n_prefs_sig;
byte *pp = prefs_sig;
+ n = n_prefs_sig;
memcpy( prec.r.pref.data, pp, ITEMS_PER_PREF_RECORD );
n -= ITEMS_PER_PREF_RECORD;
pp += ITEMS_PER_PREF_RECORD;
@@ -2814,7 +2814,7 @@ upd_pref_record( TRUSTREC *urec, u32 *keyid, PKT_signature *sig )
static void
upd_cert_record( KBNODE keyblock, KBNODE signode, u32 *keyid,
TRUSTREC *drec, RECNO_LIST *recno_list, int recheck,
- TRUSTREC *urec, const byte *uidhash, int revoke )
+ TRUSTREC *urec, const byte *uidhash, int revoked )
{
/* We simply insert the signature into the sig records but
* avoid duplicate ones. We do not check them here because
@@ -2893,7 +2893,7 @@ upd_cert_record( KBNODE keyblock, KBNODE signode, u32 *keyid,
#endif
found_sig = 1;
}
- if( !recheck && !revoke && (rec.r.sig.sig[i].flag & SIGF_CHECKED) )
+ if( !recheck && !revoked && (rec.r.sig.sig[i].flag & SIGF_CHECKED) )
continue; /* we already checked this signature */
if( !recheck && (rec.r.sig.sig[i].flag & SIGF_NOPUBKEY) )
continue; /* we do not have the public key */
@@ -2907,10 +2907,10 @@ upd_cert_record( KBNODE keyblock, KBNODE signode, u32 *keyid,
log_info("sig %08lX.%lu/%02X%02X/%08lX: %s\n",
(ulong)keyid[1], lid, uidhash[18],
uidhash[19], (ulong)sig->keyid[1],
- revoke? _("Valid certificate revocation")
- : _("Good certificate") );
+ revoked? _("Valid certificate revocation")
+ : _("Good certificate") );
rec.r.sig.sig[i].flag = SIGF_CHECKED | SIGF_VALID;
- if( revoke )
+ if( revoked )
rec.r.sig.sig[i].flag |= SIGF_REVOKED;
}
else if( rc == G10ERR_NO_PUBKEY ) {
@@ -2922,18 +2922,18 @@ upd_cert_record( KBNODE keyblock, KBNODE signode, u32 *keyid,
_("Hmmm, public key lost?") );
#endif
rec.r.sig.sig[i].flag = SIGF_NOPUBKEY;
- if( revoke )
+ if( revoked )
rec.r.sig.sig[i].flag |= SIGF_REVOKED;
}
else {
log_info("sig %08lX.%lu/%02X%02X/%08lX: %s: %s\n",
(ulong)keyid[1], lid, uidhash[18],
uidhash[19], (ulong)sig->keyid[1],
- revoke? _("Invalid certificate revocation")
- : _("Invalid certificate"),
+ revoked? _("Invalid certificate revocation")
+ : _("Invalid certificate"),
g10_errstr(rc));
rec.r.sig.sig[i].flag = SIGF_CHECKED;
- if( revoke )
+ if( revoked )
rec.r.sig.sig[i].flag |= SIGF_REVOKED;
}
rec.dirty = 1;
@@ -2950,7 +2950,7 @@ upd_cert_record( KBNODE keyblock, KBNODE signode, u32 *keyid,
(ulong)keyid[1], lid,
uidhash[18], uidhash[19], tmp.recnum );
rec.r.sig.sig[i].flag = SIGF_NOPUBKEY;
- if( revoke )
+ if( revoked )
rec.r.sig.sig[i].flag |= SIGF_REVOKED;
rec.dirty = 1;
/* fixme: should we verify that the record is
@@ -2991,11 +2991,11 @@ upd_cert_record( KBNODE keyblock, KBNODE signode, u32 *keyid,
log_info("sig %08lX.%lu/%02X%02X/%08lX: %s\n",
(ulong)keyid[1], lid, uidhash[18],
uidhash[19], (ulong)sig->keyid[1],
- revoke? _("Valid certificate revocation")
- : _("Good certificate") );
+ revoked? _("Valid certificate revocation")
+ : _("Good certificate") );
newlid = pk_lid; /* this is the pk of the signature */
newflag = SIGF_CHECKED | SIGF_VALID;
- if( revoke )
+ if( revoked )
newflag |= SIGF_REVOKED;
}
else if( rc == G10ERR_NO_PUBKEY ) {
@@ -3005,19 +3005,19 @@ upd_cert_record( KBNODE keyblock, KBNODE signode, u32 *keyid,
uidhash[19], (ulong)sig->keyid[1], g10_errstr(rc) );
newlid = create_shadow_dir( sig, lid );
newflag = SIGF_NOPUBKEY;
- if( revoke )
+ if( revoked )
newflag |= SIGF_REVOKED;
}
else {
log_info( "sig %08lX.%lu/%02X%02X/%08lX: %s: %s\n",
(ulong)keyid[1], lid, uidhash[18], uidhash[19],
(ulong)sig->keyid[1],
- revoke? _("Invalid certificate revocation")
- : _("Invalid certificate"),
+ revoked? _("Invalid certificate revocation")
+ : _("Invalid certificate"),
g10_errstr(rc));
newlid = create_shadow_dir( sig, lid );
newflag = SIGF_CHECKED;
- if( revoke )
+ if( revoked )
newflag |= SIGF_REVOKED;
}
@@ -3264,12 +3264,12 @@ insert_trust_record( PKT_public_key *pk )
for( node=keyblock; node; node = node->next ) {
if( node->pkt->pkttype == PKT_PUBLIC_KEY
|| node->pkt->pkttype == PKT_PUBLIC_SUBKEY ) {
- PKT_public_key *pk = node->pkt->pkt.public_key;
- pk->local_id = dirrec.r.dir.lid;
+ PKT_public_key *a_pk = node->pkt->pkt.public_key;
+ a_pk->local_id = dirrec.r.dir.lid;
}
else if( node->pkt->pkttype == PKT_SIGNATURE ) {
- PKT_signature *sig = node->pkt->pkt.signature;
- sig->local_id = dirrec.r.dir.lid;
+ PKT_signature *a_sig = node->pkt->pkt.signature;
+ a_sig->local_id = dirrec.r.dir.lid;
}
}
diff --git a/include/ChangeLog b/include/ChangeLog
index 7f7045738..c510d244c 100644
--- a/include/ChangeLog
+++ b/include/ChangeLog
@@ -1,3 +1,7 @@
+Tue Feb 16 14:10:02 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * types.h (STRLIST): Add field flags.
+
Wed Feb 10 17:15:39 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* cipher.h (CIPHER_ALGO_TWOFISH): Chnaged ID to 10 and renamed
diff --git a/include/cipher.h b/include/cipher.h
index 55a566264..8e7012fa3 100644
--- a/include/cipher.h
+++ b/include/cipher.h
@@ -144,7 +144,7 @@ void cipher_sync( CIPHER_HANDLE c );
int string_to_pubkey_algo( const char *string );
const char * pubkey_algo_to_string( int algo );
int check_pubkey_algo( int algo );
-int check_pubkey_algo2( int algo, unsigned usage );
+int check_pubkey_algo2( int algo, unsigned use );
int pubkey_get_npkey( int algo );
int pubkey_get_nskey( int algo );
int pubkey_get_nsig( int algo );
diff --git a/include/http.h b/include/http.h
index d55213eb9..7e6d9d970 100644
--- a/include/http.h
+++ b/include/http.h
@@ -52,7 +52,7 @@ typedef enum {
struct http_context {
int initialized;
unsigned int status_code;
- int socket;
+ int sock;
int in_data;
IOBUF fp_read;
IOBUF fp_write;
diff --git a/include/iobuf.h b/include/iobuf.h
index 92671005c..56607b723 100644
--- a/include/iobuf.h
+++ b/include/iobuf.h
@@ -36,8 +36,9 @@
typedef struct iobuf_struct *IOBUF;
+/* fixme: we should hide most of this stuff */
struct iobuf_struct {
- int usage; /* 1 input , 2 output, 3 temp */
+ int use; /* 1 input , 2 output, 3 temp */
unsigned long nlimit;
unsigned long nbytes; /* used together with nlimit */
unsigned long ntotal; /* total bytes read (position of stream) */
@@ -69,7 +70,7 @@ struct iobuf_struct {
int iobuf_debug_mode;
-IOBUF iobuf_alloc(int usage, size_t bufsize);
+IOBUF iobuf_alloc(int use, size_t bufsize);
IOBUF iobuf_temp(void);
IOBUF iobuf_temp_with_content( const char *buffer, size_t length );
IOBUF iobuf_open( const char *fname );
@@ -136,6 +137,6 @@ int iobuf_in_block_mode( IOBUF a );
#define iobuf_get_temp_buffer(a) ( (a)->d.buf )
#define iobuf_get_temp_length(a) ( (a)->d.len )
-#define iobuf_is_temp(a) ( (a)->usage == 3 )
+#define iobuf_is_temp(a) ( (a)->use == 3 )
#endif /*G10_IOBUF_H*/
diff --git a/include/mpi.h b/include/mpi.h
index 266b91554..ae32d1ba3 100644
--- a/include/mpi.h
+++ b/include/mpi.h
@@ -153,8 +153,8 @@ int mpi_cmp_ui( MPI u, ulong v );
int mpi_cmp( MPI u, MPI v );
/*-- mpi-scan.c --*/
-int mpi_getbyte( MPI a, unsigned index );
-void mpi_putbyte( MPI a, unsigned index, int value );
+int mpi_getbyte( MPI a, unsigned idx );
+void mpi_putbyte( MPI a, unsigned idx, int value );
unsigned mpi_trailing_zeros( MPI a );
/*-- mpi-bit.c --*/
diff --git a/include/types.h b/include/types.h
index 4c5e57cc6..241e40529 100644
--- a/include/types.h
+++ b/include/types.h
@@ -102,6 +102,7 @@
typedef struct string_list {
struct string_list *next;
+ unsigned int flags;
char d[1];
} *STRLIST;
diff --git a/include/util.h b/include/util.h
index 6462ddeae..358cdc5f9 100644
--- a/include/util.h
+++ b/include/util.h
@@ -41,7 +41,7 @@ typedef struct {
char *ret_str;
} r; /* Return values */
struct {
- int index;
+ int idx;
int inarg;
int stopped;
const char *last;
diff --git a/mpi/mpi-scan.c b/mpi/mpi-scan.c
index 82ac7262a..ea5673f4f 100644
--- a/mpi/mpi-scan.c
+++ b/mpi/mpi-scan.c
@@ -32,7 +32,7 @@
* FIXME: This code is VERY ugly!
*/
int
-mpi_getbyte( MPI a, unsigned index )
+mpi_getbyte( MPI a, unsigned idx )
{
int i, j;
unsigned n;
@@ -43,7 +43,7 @@ mpi_getbyte( MPI a, unsigned index )
for(n=0,i=0; i < a->nlimbs; i++ ) {
limb = ap[i];
for( j=0; j < BYTES_PER_MPI_LIMB; j++, n++ )
- if( n == index )
+ if( n == idx )
return (limb >> j*8) & 0xff;
}
return -1;
@@ -51,10 +51,10 @@ mpi_getbyte( MPI a, unsigned index )
/****************
- * Put a value at position INDEX into A. index counts from lsb to msb
+ * Put a value at position IDX into A. idx counts from lsb to msb
*/
void
-mpi_putbyte( MPI a, unsigned index, int xc )
+mpi_putbyte( MPI a, unsigned idx, int xc )
{
int i, j;
unsigned n;
@@ -66,7 +66,7 @@ mpi_putbyte( MPI a, unsigned index, int xc )
for(n=0,i=0; i < a->alloced; i++ ) {
limb = ap[i];
for( j=0; j < BYTES_PER_MPI_LIMB; j++, n++ )
- if( n == index ) {
+ if( n == idx ) {
#if BYTES_PER_MPI_LIMB == 4
if( j == 0 )
limb = (limb & 0xffffff00) | c;
diff --git a/util/ChangeLog b/util/ChangeLog
index a0a534603..d17103a69 100644
--- a/util/ChangeLog
+++ b/util/ChangeLog
@@ -1,3 +1,10 @@
+Tue Feb 16 14:10:02 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
+
+ * strgutil.c (add_to_strglist): Clear the new flags field
+ (append_to_strglist): Ditto.
+
+ * dotlock.c (read_lockfile): terminate pidstr (Michael).
+
Wed Feb 10 17:15:39 CET 1999 Werner Koch <wk@isil.d.shuttle.de>
* dotlock.c (remove_lockfiles): Add cleanup function.
diff --git a/util/argparse.c b/util/argparse.c
index 6514c2c3c..83efc0f64 100644
--- a/util/argparse.c
+++ b/util/argparse.c
@@ -49,7 +49,7 @@
* char *ret_str;
* } r; Return values
* struct {
- * int index;
+ * int idx;
* const char *last;
* void *aliases;
* } internal; DO NOT CHANGE
@@ -143,7 +143,7 @@ static void
initialize( ARGPARSE_ARGS *arg, const char *filename, unsigned *lineno )
{
if( !(arg->flags & (1<<15)) ) { /* initialize this instance */
- arg->internal.index = 0;
+ arg->internal.idx = 0;
arg->internal.last = NULL;
arg->internal.inarg = 0;
arg->internal.stopped = 0;
@@ -230,7 +230,7 @@ optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
{
int state, i, c;
- int index=0;
+ int idx=0;
char keyword[100];
char *buffer = NULL;
size_t buflen = 0;
@@ -256,13 +256,13 @@ optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
for(i=0; opts[i].short_opt; i++ )
if( opts[i].long_opt && !strcmp( opts[i].long_opt, keyword) )
break;
- index = i;
- arg->r_opt = opts[index].short_opt;
+ idx = i;
+ arg->r_opt = opts[idx].short_opt;
if( inverse ) /* this does not have an effect, hmmm */
arg->r_opt = -arg->r_opt;
- if( !opts[index].short_opt ) /* unknown command/option */
- arg->r_opt = (opts[index].flags & 256)? -7:-2;
- else if( (opts[index].flags & 8) ) /* no argument */
+ if( !opts[idx].short_opt ) /* unknown command/option */
+ arg->r_opt = (opts[idx].flags & 256)? -7:-2;
+ else if( (opts[idx].flags & 8) ) /* no argument */
arg->r_opt = -3; /* error */
else /* no or optional argument */
arg->r_type = 0; /* okay */
@@ -271,9 +271,9 @@ optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
else if( state == 3 ) { /* no argument found */
if( in_alias )
arg->r_opt = -3; /* error */
- else if( !(opts[index].flags & 7) ) /* does not take an arg */
+ else if( !(opts[idx].flags & 7) ) /* does not take an arg */
arg->r_type = 0; /* okay */
- else if( (opts[index].flags & 8) ) /* no optional argument */
+ else if( (opts[idx].flags & 8) ) /* no optional argument */
arg->r_type = 0; /* okay */
else /* no required argument */
arg->r_opt = -3; /* error */
@@ -301,7 +301,7 @@ optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
}
}
}
- else if( !(opts[index].flags & 7) ) /* does not take an arg */
+ else if( !(opts[idx].flags & 7) ) /* does not take an arg */
arg->r_opt = -6; /* error */
else {
if( !buffer ) {
@@ -312,7 +312,7 @@ optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
buffer[i] = 0;
trim_spaces( buffer );
- if( !set_opt_arg(arg, opts[index].flags, buffer) )
+ if( !set_opt_arg(arg, opts[idx].flags, buffer) )
m_free(buffer);
}
break;
@@ -340,15 +340,15 @@ optfile_parse( FILE *fp, const char *filename, unsigned *lineno,
for(i=0; opts[i].short_opt; i++ )
if( opts[i].long_opt && !strcmp( opts[i].long_opt, keyword) )
break;
- index = i;
- arg->r_opt = opts[index].short_opt;
- if( !opts[index].short_opt ) {
+ idx = i;
+ arg->r_opt = opts[idx].short_opt;
+ if( !opts[idx].short_opt ) {
if( !strcmp( keyword, "alias" ) ) {
in_alias = 1;
state = 3;
}
else {
- arg->r_opt = (opts[index].flags & 256)? -7:-2;
+ arg->r_opt = (opts[idx].flags & 256)? -7:-2;
state = -1; /* skip rest of line and leave */
}
}
@@ -445,7 +445,7 @@ find_long_option( ARGPARSE_ARGS *arg,
int
arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
{
- int index;
+ int idx;
int argc;
char **argv;
char *s, *s2;
@@ -454,10 +454,10 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
initialize( arg, NULL, NULL );
argc = *arg->argc;
argv = *arg->argv;
- index = arg->internal.index;
+ idx = arg->internal.idx;
- if( !index && argc && !(arg->flags & (1<<4)) ) { /* skip the first entry */
- argc--; argv++; index++;
+ if( !idx && argc && !(arg->flags & (1<<4)) ) { /* skip the first entry */
+ argc--; argv++; idx++;
}
next_one:
@@ -473,7 +473,7 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
arg->r_opt = -1; /* not an option but a argument */
arg->r_type = 2;
arg->r.ret_str = s;
- argc--; argv++; index++; /* set to next one */
+ argc--; argv++; idx++; /* set to next one */
}
else if( arg->internal.stopped ) { /* ready */
arg->r_opt = 0;
@@ -485,7 +485,7 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
arg->internal.inarg = 0;
if( !s[2] && !(arg->flags & (1<<3)) ) { /* stop option processing */
arg->internal.stopped = 1;
- argc--; argv++; index++;
+ argc--; argv++; idx++;
goto next_one;
}
@@ -548,7 +548,7 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
else {
set_opt_arg(arg, opts[i].flags, s2);
if( !argpos ) {
- argc--; argv++; index++; /* skip one */
+ argc--; argv++; idx++; /* skip one */
}
}
}
@@ -558,7 +558,7 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
else
arg->r_type = 0;
}
- argc--; argv++; index++; /* set to next one */
+ argc--; argv++; idx++; /* set to next one */
}
else if( (*s == '-' && s[1]) || arg->internal.inarg ) { /* short option */
int dash_kludge = 0;
@@ -611,7 +611,7 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
}
else {
set_opt_arg(arg, opts[i].flags, s2);
- argc--; argv++; index++; /* skip one */
+ argc--; argv++; idx++; /* skip one */
}
}
s = "x"; /* so that !s[1] yields false */
@@ -622,14 +622,14 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
}
if( !s[1] || dash_kludge ) { /* no more concatenated short options */
arg->internal.inarg = 0;
- argc--; argv++; index++;
+ argc--; argv++; idx++;
}
}
else if( arg->flags & (1<<2) ) {
arg->r_opt = -1; /* not an option but a argument */
arg->r_type = 2;
arg->r.ret_str = s;
- argc--; argv++; index++; /* set to next one */
+ argc--; argv++; idx++; /* set to next one */
}
else {
arg->internal.stopped = 1; /* stop option processing */
@@ -639,7 +639,7 @@ arg_parse( ARGPARSE_ARGS *arg, ARGPARSE_OPTS *opts)
leave:
*arg->argc = argc;
*arg->argv = argv;
- arg->internal.index = index;
+ arg->internal.idx = idx;
return arg->r_opt;
}
diff --git a/util/dotlock.c b/util/dotlock.c
index 656454ee3..213f0d38e 100644
--- a/util/dotlock.c
+++ b/util/dotlock.c
@@ -85,7 +85,7 @@ create_dotlock( const char *file_to_lock )
h = m_alloc_clear( sizeof *h );
#ifndef HAVE_DOSISH_SYSTEM
- sprintf( pidstr, "%10d\n", getpid() );
+ sprintf( pidstr, "%10d\n", (int)getpid() );
/* fixme: add the hostname to the second line (FQDN or IP addr?) */
/* create a temporary file */
@@ -298,12 +298,13 @@ read_lockfile( const char *name )
errno = e;
return -1;
}
- if( read(fd, pidstr, 10 ) != 10 ) {
+ if( read(fd, pidstr, 10 ) != 10 ) { /* Read 10 digits w/o newline */
log_debug("error reading lockfile `%s'", name );
close(fd);
errno = 0;
return -1;
}
+ pidstr[10] = 0; /* terminate pid string */
close(fd);
pid = atoi(pidstr);
if( !pid || pid == -1 ) {
diff --git a/util/http.c b/util/http.c
index 408209213..22f13938d 100644
--- a/util/http.c
+++ b/util/http.c
@@ -61,7 +61,7 @@ static byte *build_rel_path( PARSED_URI uri );
static int parse_response( HTTP_HD hd );
static int connect_server( const char *server, ushort port );
-static int write_server( int socket, const char *data, size_t length );
+static int write_server( int sock, const char *data, size_t length );
int
@@ -75,7 +75,7 @@ http_open( HTTP_HD hd, HTTP_REQ_TYPE reqtype, const char *url,
/* initialize the handle */
memset( hd, 0, sizeof *hd );
- hd->socket = -1;
+ hd->sock = -1;
hd->initialized = 1;
hd->req_type = reqtype;
@@ -83,15 +83,15 @@ http_open( HTTP_HD hd, HTTP_REQ_TYPE reqtype, const char *url,
if( !rc ) {
rc = send_request( hd );
if( !rc ) {
- hd->fp_write = iobuf_fdopen( hd->socket , "w" );
+ hd->fp_write = iobuf_fdopen( hd->sock , "w" );
if( hd->fp_write )
return 0;
rc = G10ERR_GENERAL;
}
}
- if( !hd->fp_read && !hd->fp_write && hd->socket != -1 )
- close( hd->socket );
+ if( !hd->fp_read && !hd->fp_write && hd->sock != -1 )
+ close( hd->sock );
iobuf_close( hd->fp_read );
iobuf_close( hd->fp_write);
release_parsed_uri( hd->uri );
@@ -119,15 +119,15 @@ http_wait_response( HTTP_HD hd, unsigned int *ret_status )
http_start_data( hd ); /* make sure that we are in the data */
iobuf_flush( hd->fp_write );
- hd->socket = dup( hd->socket );
- if( hd->socket == -1 )
+ hd->sock = dup( hd->sock );
+ if( hd->sock == -1 )
return G10ERR_GENERAL;
iobuf_close( hd->fp_write );
hd->fp_write = NULL;
- shutdown( hd->socket, 1 );
+ shutdown( hd->sock, 1 );
hd->in_data = 0;
- hd->fp_read = iobuf_fdopen( hd->socket , "r" );
+ hd->fp_read = iobuf_fdopen( hd->sock , "r" );
if( !hd->fp_read )
return G10ERR_GENERAL;
@@ -166,8 +166,8 @@ http_close( HTTP_HD hd )
{
if( !hd || !hd->initialized )
return;
- if( !hd->fp_read && !hd->fp_write && hd->socket != -1 )
- close( hd->socket );
+ if( !hd->fp_read && !hd->fp_write && hd->sock != -1 )
+ close( hd->sock );
iobuf_close( hd->fp_read );
iobuf_close( hd->fp_write );
release_parsed_uri( hd->uri );
@@ -427,8 +427,8 @@ send_request( HTTP_HD hd )
server = *hd->uri->host? hd->uri->host : "localhost";
port = hd->uri->port? hd->uri->port : 80;
- hd->socket = connect_server( server, port );
- if( hd->socket == -1 )
+ hd->sock = connect_server( server, port );
+ if( hd->sock == -1 )
return G10ERR_NETWORK;
p = build_rel_path( hd->uri );
@@ -440,7 +440,7 @@ send_request( HTTP_HD hd )
*p == '/'? "":"/", p );
m_free(p);
- rc = write_server( hd->socket, request, strlen(request) );
+ rc = write_server( hd->sock, request, strlen(request) );
m_free( request );
return rc;
@@ -656,13 +656,13 @@ connect_server( const char *server, ushort port )
static int
-write_server( int socket, const char *data, size_t length )
+write_server( int sock, const char *data, size_t length )
{
int nleft, nwritten;
nleft = length;
while( nleft > 0 ) {
- nwritten = write( socket, data, nleft );
+ nwritten = write( sock, data, nleft );
if( nwritten == -1 ) {
if( errno == EINTR )
continue;
diff --git a/util/iobuf.c b/util/iobuf.c
index 037d2cdc3..faee82d61 100644
--- a/util/iobuf.c
+++ b/util/iobuf.c
@@ -46,7 +46,7 @@ typedef struct {
#define OP_MIN_PARTIAL_CHUNK_2POW 9
typedef struct {
- int usage;
+ int use;
size_t size;
size_t count;
int partial; /* 1 = partial header, 2 in last partial packet */
@@ -340,7 +340,7 @@ block_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len)
log_debug("init block_filter %p\n", a );
if( a->partial )
a->count = 0;
- else if( a->usage == 1 )
+ else if( a->use == 1 )
a->count = a->size = 0;
else
a->count = a->size; /* force first length bytes */
@@ -352,7 +352,7 @@ block_filter(void *opaque, int control, IOBUF chain, byte *buf, size_t *ret_len)
*(char**)buf = "block_filter";
}
else if( control == IOBUFCTRL_FREE ) {
- if( a->usage == 2 ) { /* write the end markers */
+ if( a->use == 2 ) { /* write the end markers */
if( a->partial ) {
u32 len;
/* write out the remaining bytes without a partial header
@@ -426,17 +426,17 @@ print_chain( IOBUF a )
/****************
* Allocate a new io buffer, with no function assigned.
- * Usage is the desired usage: 1 for input, 2 for output, 3 for temp buffer
+ * Use is the desired usage: 1 for input, 2 for output, 3 for temp buffer
* BUFSIZE is a suggested buffer size.
*/
IOBUF
-iobuf_alloc(int usage, size_t bufsize)
+iobuf_alloc(int use, size_t bufsize)
{
IOBUF a;
static int number=0;
a = m_alloc_clear(sizeof *a);
- a->usage = usage;
+ a->use = use;
a->d.buf = m_alloc( bufsize );
a->d.size = bufsize;
a->no = ++number;
@@ -462,7 +462,7 @@ iobuf_close( IOBUF a )
for( ; a && !rc ; a = a2 ) {
a2 = a->chain;
- if( a->usage == 2 && (rc=iobuf_flush(a)) )
+ if( a->use == 2 && (rc=iobuf_flush(a)) )
log_error("iobuf_flush failed on close: %s\n", g10_errstr(rc));
if( DBG_IOBUF )
@@ -481,7 +481,7 @@ iobuf_cancel( IOBUF a )
{
const char *s;
- if( a && a->usage == 2 ) {
+ if( a && a->use == 2 ) {
s = get_real_fname(a);
if( s && *s )
remove(s); /* remove the file. Fixme: this will fail for MSDOZE*/
@@ -720,7 +720,7 @@ iobuf_push_filter( IOBUF a,
if( a->directfp )
BUG();
- if( a->usage == 2 && (rc=iobuf_flush(a)) )
+ if( a->use == 2 && (rc=iobuf_flush(a)) )
return rc;
/* make a copy of the current stream, so that
* A is the new stream and B the original one.
@@ -733,10 +733,10 @@ iobuf_push_filter( IOBUF a,
a->filter = NULL;
a->filter_ov = NULL;
a->filter_eof = 0;
- if( a->usage == 3 )
- a->usage = 2; /* make a write stream from a temp stream */
+ if( a->use == 3 )
+ a->use = 2; /* make a write stream from a temp stream */
- if( a->usage == 2 ) { /* allocate a fresh buffer for the original stream */
+ if( a->use == 2 ) { /* allocate a fresh buffer for the original stream */
b->d.buf = m_alloc( a->d.size );
b->d.len = 0;
b->d.start = 0;
@@ -805,7 +805,7 @@ pop_filter( IOBUF a, int (*f)(void *opaque, int control,
log_bug("iobuf_pop_filter(): filter function not found\n");
/* flush this stream if it is an output stream */
- if( a->usage == 2 && (rc=iobuf_flush(b)) ) {
+ if( a->use == 2 && (rc=iobuf_flush(b)) ) {
log_error("iobuf_flush failed in pop_filter: %s\n", g10_errstr(rc));
return rc;
}
@@ -853,7 +853,7 @@ underflow(IOBUF a)
int rc;
assert( a->d.start == a->d.len );
- if( a->usage == 3 )
+ if( a->use == 3 )
return -1; /* EOF because a temp buffer can't do an underflow */
if( a->filter_eof ) {
@@ -909,7 +909,7 @@ underflow(IOBUF a)
#endif
}
- if( a->usage == 1 && rc == -1 ) { /* EOF: we can remove the filter */
+ if( a->use == 1 && rc == -1 ) { /* EOF: we can remove the filter */
size_t dummy_len;
/* and tell the filter to free itself */
@@ -965,7 +965,7 @@ iobuf_flush(IOBUF a)
return 0;
/*log_debug("iobuf-%d.%d: flush\n", a->no, a->subno );*/
- if( a->usage == 3 ) { /* increase the temp buffer */
+ if( a->use == 3 ) { /* increase the temp buffer */
char *newbuf;
size_t newsize = a->d.size + 8192;
@@ -978,7 +978,7 @@ iobuf_flush(IOBUF a)
a->d.size = newsize;
return 0;
}
- else if( a->usage != 2 )
+ else if( a->use != 2 )
log_bug("flush on non-output iobuf\n");
else if( !a->filter )
log_bug("iobuf_flush: no filter\n");
@@ -1332,15 +1332,15 @@ iobuf_set_block_mode( IOBUF a, size_t n )
{
block_filter_ctx_t *ctx = m_alloc_clear( sizeof *ctx );
- assert( a->usage == 1 || a->usage == 2 );
- ctx->usage = a->usage;
+ assert( a->use == 1 || a->use == 2 );
+ ctx->use = a->use;
if( !n ) {
- if( a->usage == 1 )
+ if( a->use == 1 )
log_debug("pop_filter called in set_block_mode - please report\n");
pop_filter(a, block_filter, NULL );
}
else {
- ctx->size = n; /* only needed for usage 2 */
+ ctx->size = n; /* only needed for use 2 */
iobuf_push_filter(a, block_filter, ctx );
}
}
@@ -1354,10 +1354,10 @@ iobuf_set_partial_block_mode( IOBUF a, size_t len )
{
block_filter_ctx_t *ctx = m_alloc_clear( sizeof *ctx );
- assert( a->usage == 1 || a->usage == 2 );
- ctx->usage = a->usage;
+ assert( a->use == 1 || a->use == 2 );
+ ctx->use = a->use;
if( !len ) {
- if( a->usage == 1 )
+ if( a->use == 1 )
log_debug("pop_filter called in set_partial_block_mode"
" - please report\n");
pop_filter(a, block_filter, NULL );
diff --git a/util/secmem.c b/util/secmem.c
index 0aa4e9f61..aa6d822c7 100644
--- a/util/secmem.c
+++ b/util/secmem.c
@@ -71,7 +71,7 @@ static int suspend_warning;
static void
-print_warn()
+print_warn(void)
{
if( !no_warning )
log_info(_("Warning: using insecure memory!\n"));
diff --git a/util/strgutil.c b/util/strgutil.c
index b3213dc9c..cbedcf39e 100644
--- a/util/strgutil.c
+++ b/util/strgutil.c
@@ -67,6 +67,7 @@ add_to_strlist( STRLIST *list, const char *string )
STRLIST sl;
sl = m_alloc( sizeof *sl + strlen(string));
+ sl->flags = 0;
strcpy(sl->d, string);
sl->next = *list;
*list = sl;
@@ -79,6 +80,7 @@ append_to_strlist( STRLIST *list, const char *string )
STRLIST r, sl;
sl = m_alloc( sizeof *sl + strlen(string));
+ sl->flags = 0;
strcpy(sl->d, string);
sl->next = NULL;
if( !*list )
diff --git a/util/ttyio.c b/util/ttyio.c
index e457949a0..b5d0a1302 100644
--- a/util/ttyio.c
+++ b/util/ttyio.c
@@ -76,7 +76,7 @@ cleanup(void)
#endif
static void
-init_ttyfp()
+init_ttyfp(void)
{
if( initialized )
return;