1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-11-10 21:38:50 +01:00

more bug fixesand some warning cleanups

This commit is contained in:
Werner Koch 2001-09-09 16:09:19 +00:00
parent 2874670be9
commit d4cd7a3d4b
23 changed files with 164 additions and 61 deletions

View File

@ -1,3 +1,13 @@
2001-09-09 Werner Koch <wk@gnupg.org>
* configure.ac: autoconf changed the name of the maintainer mode
flag, so that not all warnings where enabled. Fixed that.
Reported by Dirk Meyer.
2001-09-07 Werner Koch <wk@gnupg.org>
* configure.ac: Test for strsep().
2001-09-03 Werner Koch <wk@gnupg.org>
* configure.ac: Removed GDBM tests.

1
THANKS
View File

@ -41,6 +41,7 @@ David R. Bergstein dbergstein@home.com
Detlef Lannert lannert@lannert.rz.uni-duesseldorf.de
Dimitri dmitri@advantrix.com
Dirk Lattermann dlatt@t-online.de
Dirk Meyer dirk.meyer@dinoex.sub.org
Ed Boraas ecxjo@esperanto.org
Edmund GRIMLEY EVANS edmundo@rano.org
Edwin Woudt edwin@woudt.nl

4
TODO
View File

@ -1,4 +1,8 @@
* 12345678! does not work anymore
* Always use the primary key to sign other keys.
* add listing of notation data
* Check the changes to the gpg random gatherer on all W32 platforms.

View File

@ -1,3 +1,7 @@
2001-09-09 Werner Koch <wk@gnupg.org>
* rsa.c (rsa_get_info): s/usage/r_usage/ to avoid shadow warnings.
2001-08-24 Werner Koch <wk@gnupg.org>
* md.c (md_write): Made buf arg const.

View File

@ -296,7 +296,7 @@ set_random_seed_file( const char *name )
* and return true if this was successful
*/
static int
read_seed_file()
read_seed_file(void)
{
int fd;
struct stat sb;

View File

@ -446,7 +446,7 @@ rsa_get_nbits( int algo, MPI *pkey )
*/
const char *
rsa_get_info( int algo,
int *npkey, int *nskey, int *nenc, int *nsig, int *usage )
int *npkey, int *nskey, int *nenc, int *nsig, int *r_usage )
{
*npkey = 2;
*nskey = 6;
@ -454,10 +454,12 @@ rsa_get_info( int algo,
*nsig = 1;
switch( algo ) {
case 1: *usage = PUBKEY_USAGE_SIG | PUBKEY_USAGE_ENC; return "RSA";
case 2: *usage = PUBKEY_USAGE_ENC; return "RSA-E";
case 3: *usage = PUBKEY_USAGE_SIG; return "RSA-S";
default:*usage = 0; return NULL;
case 1: *r_usage = PUBKEY_USAGE_SIG | PUBKEY_USAGE_ENC; return "RSA";
case 2: *r_usage = PUBKEY_USAGE_ENC; return "RSA-E";
case 3: *r_usage = PUBKEY_USAGE_SIG; return "RSA-S";
default:*r_usage = 0; return NULL;
}
}

View File

@ -21,7 +21,7 @@ dnl (Process this file with autoconf to produce a configure script.)
AC_REVISION($Revision$)dnl
AC_PREREQ(2.52)
AC_INIT(gnupg,1.0.6a)
AC_INIT(gnupg,1.0.6b)
AC_CONFIG_SRCDIR(g10/g10.c)
AC_CONFIG_AUX_DIR(scripts)
AC_CONFIG_HEADERS(config.h)
@ -449,10 +449,10 @@ fi
dnl Checks for library functions.
AC_FUNC_FSEEKO
AC_FUNC_VPRINTF
AC_CHECK_FUNCS(strerror stpcpy strlwr stricmp tcgetattr rand strtoul mmap)
AC_CHECK_FUNCS(strerror stpcpy strsep strlwr stricmp tcgetattr strtoul mmap)
AC_CHECK_FUNCS(memmove gettimeofday getrusage setrlimit clock_gettime)
AC_CHECK_FUNCS(memicmp atexit raise getpagesize strftime nl_langinfo)
AC_CHECK_FUNCS(waitpid wait4 sigaction sigprocmask)
AC_CHECK_FUNCS(waitpid wait4 sigaction sigprocmask rand)
#
# check for gethrtime and run a testprogram to see whether
@ -794,7 +794,7 @@ esac
if test "$GCC" = yes; then
if test "$MAINTAINER_MODE" = "yes"; then
if test "$USE_MAINTAINER_MODE" = "yes"; then
CFLAGS="$CFLAGS -Wall -Wcast-align -Wshadow -Wstrict-prototypes"
else
CFLAGS="$CFLAGS -Wall"

View File

@ -1,3 +1,23 @@
2001-09-09 Werner Koch <wk@gnupg.org>
* keyedit.c (keyedit_menu): No need to define another p.
* keylist.c (print_capabilities): s/used/use/ so that it
does not shadow a global.
* sign.c (sign_file): Renamed arg encrypt to encryptflag
* keygen.c: Replaced all "usage" by "use".
* misc.c (openpgp_pk_algo_usage): Ditto.
* pubkey-enc.c (get_it): Renamed arg k to enc so that the later
defined k does not shadow it.
* parse-packet.c (parse_gpg_control): No need to define another i.
* getkey.c (get_pubkey_byfprint): Must use the enum values and not
the fprint_len.
* keyring.c (keyring_search): Removed a non-sense break. Both
bugs pointed out by Stefan.
2001-09-07 Werner Koch <wk@gnupg.org>
* status.c, status.h: Added NO_RECP and ALREADY_SIGNED.

View File

@ -911,7 +911,8 @@ get_pubkey_byfprint( PKT_public_key *pk,
ctx.not_allocated = 1;
ctx.kr_handle = keydb_new (0);
ctx.nitems = 1;
ctx.items[0].mode = fprint_len;
ctx.items[0].mode = fprint_len==16? KEYDB_SEARCH_MODE_FPR16
: KEYDB_SEARCH_MODE_FPR20;
memcpy( ctx.items[0].u.fpr, fprint, fprint_len );
rc = lookup( &ctx, &kb, 0 );
if (!rc && pk )

View File

@ -955,7 +955,7 @@ keyedit_menu( const char *username, STRLIST locusr, STRLIST commands,
case cmdUPDPREF:
{
char *p = keygen_get_std_prefs ();
p = keygen_get_std_prefs ();
tty_printf (("Current preference list: %s\n"), p);
m_free (p);
}

View File

@ -124,17 +124,17 @@ write_uid( KBNODE root, const char *s )
}
static void
do_add_key_flags (PKT_signature *sig, unsigned int usage)
do_add_key_flags (PKT_signature *sig, unsigned int use)
{
byte buf[1];
if (!usage)
if (!use)
return;
buf[0] = 0;
if (usage & PUBKEY_USAGE_SIG)
if (use & PUBKEY_USAGE_SIG)
buf[0] |= 0x01 | 0x02;
if (usage & PUBKEY_USAGE_ENC)
if (use & PUBKEY_USAGE_ENC)
buf[0] |= 0x04 | 0x08;
build_sig_subpkt (sig, SIGSUBPKT_KEY_FLAGS, buf, 1);
}
@ -292,7 +292,7 @@ add_feature_mdc (PKT_signature *sig)
return; /* already set */
if (!s || !n) { /* create a new one */
n = 1;
buf = m_alloc (n);
buf = m_alloc_clear (n);
}
else {
buf = m_alloc (n);
@ -358,7 +358,7 @@ keygen_add_std_prefs( PKT_signature *sig, void *opaque )
static int
write_selfsig( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
unsigned int usage )
unsigned int use )
{
PACKET *pkt;
PKT_signature *sig;
@ -380,7 +380,7 @@ write_selfsig( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
if( !node )
BUG();
pk = node->pkt->pkt.public_key;
pk->pubkey_usage = usage;
pk->pubkey_usage = use;
/* we have to cache the key, so that the verification of the signature
* creation is able to retrieve the public key */
cache_public_key (pk);
@ -402,7 +402,7 @@ write_selfsig( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
static int
write_keybinding( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
unsigned int usage )
unsigned int use )
{
PACKET *pkt;
PKT_signature *sig;
@ -433,7 +433,7 @@ write_keybinding( KBNODE root, KBNODE pub_root, PKT_secret_key *sk,
BUG();
/* and make the signature */
oduap.usage = usage;
oduap.usage = use;
oduap.pk = subpk;
rc = make_keysig_packet( &sig, pk, NULL, subpk, sk, 0x18, 0, 0,
keygen_add_key_flags_and_expire, &oduap );
@ -1296,26 +1296,26 @@ parse_parameter_usage (const char *fname,
{
struct para_data_s *r = get_parameter( para, key );
char *p, *pn;
unsigned int usage;
unsigned int use;
if( !r )
return 0; /* none (this is an optional parameter)*/
usage = 0;
use = 0;
pn = r->u.value;
while ( (p = strsep (&pn, " \t,")) ) {
if ( !*p)
;
else if ( !ascii_strcasecmp (p, "sign") )
usage |= PUBKEY_USAGE_SIG;
use |= PUBKEY_USAGE_SIG;
else if ( !ascii_strcasecmp (p, "encrypt") )
usage |= PUBKEY_USAGE_ENC;
use |= PUBKEY_USAGE_ENC;
else {
log_error("%s:%d: invalid usage list\n", fname, r->lnr );
return -1; /* error */
}
}
r->u.usage = usage;
r->u.usage = use;
return 0;
}
@ -1662,7 +1662,7 @@ generate_keypair( const char *fname )
DEK *dek;
STRING2KEY *s2k;
int algo;
unsigned int usage;
unsigned int use;
int both = 0;
u32 expire;
struct para_data_s *para = NULL;
@ -1676,7 +1676,7 @@ generate_keypair( const char *fname )
return;
}
algo = ask_algo( 0, &usage );
algo = ask_algo( 0, &use );
if( !algo ) { /* default: DSA with ElG subkey of the specified size */
both = 1;
r = m_alloc_clear( sizeof *r + 20 );
@ -1705,12 +1705,12 @@ generate_keypair( const char *fname )
r->next = para;
para = r;
if (usage) {
if (use) {
r = m_alloc_clear( sizeof *r + 20 );
r->key = pKEYUSAGE;
sprintf( r->u.value, "%s%s",
(usage & PUBKEY_USAGE_SIG)? "sign ":"",
(usage & PUBKEY_USAGE_ENC)? "encrypt ":"" );
(use & PUBKEY_USAGE_SIG)? "sign ":"",
(use & PUBKEY_USAGE_ENC)? "encrypt ":"" );
r->next = para;
para = r;
}
@ -1977,7 +1977,7 @@ generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock )
KBNODE node;
PKT_secret_key *sk = NULL; /* this is the primary sk */
int algo;
unsigned int usage;
unsigned int use;
u32 expire;
unsigned nbits;
char *passphrase = NULL;
@ -2031,7 +2031,7 @@ generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock )
goto leave;
algo = ask_algo( 1, &usage );
algo = ask_algo( 1, &use );
assert(algo);
nbits = ask_keysize( algo );
expire = ask_expire_interval();
@ -2050,9 +2050,9 @@ generate_subkeypair( KBNODE pub_keyblock, KBNODE sec_keyblock )
rc = do_create( algo, nbits, pub_keyblock, sec_keyblock,
dek, s2k, NULL, expire );
if( !rc )
rc = write_keybinding(pub_keyblock, pub_keyblock, sk, usage);
rc = write_keybinding(pub_keyblock, pub_keyblock, sk, use);
if( !rc )
rc = write_keybinding(sec_keyblock, pub_keyblock, sk, usage);
rc = write_keybinding(sec_keyblock, pub_keyblock, sk, use);
if( !rc ) {
okay = 1;
write_status_text (STATUS_KEY_CREATED, "S");

View File

@ -166,12 +166,12 @@ print_key_data( PKT_public_key *pk, u32 *keyid )
static void
print_capabilities (PKT_public_key *pk, PKT_secret_key *sk, KBNODE keyblock)
{
unsigned int usage = pk? pk->pubkey_usage : sk->pubkey_usage;
unsigned int use = pk? pk->pubkey_usage : sk->pubkey_usage;
if ( usage & PUBKEY_USAGE_ENC ) {
if ( use & PUBKEY_USAGE_ENC ) {
putchar ('e');
}
if ( usage & PUBKEY_USAGE_SIG ) {
if ( use & PUBKEY_USAGE_SIG ) {
putchar ('s');
putchar ('c');
}

View File

@ -795,7 +795,7 @@ keyring_search (KEYRING_HANDLE hd, KEYDB_SEARCH_DESC *desc, size_t ndesc)
&& desc[n].u.kid[1] == aki[1])
goto found;
break;
case KEYDB_SEARCH_MODE_FPR16: break;
case KEYDB_SEARCH_MODE_FPR16:
if ((pk||sk) && !memcmp (desc[n].u.fpr, afp, 16))
goto found;
break;

Binary file not shown.

View File

@ -299,33 +299,32 @@ openpgp_pk_test_algo( int algo, unsigned int usage_flags )
int
openpgp_pk_algo_usage ( int algo )
{
int usage = 0;
int use = 0;
/* they are hardwired in gpg 1.0 */
switch ( algo ) {
case PUBKEY_ALGO_RSA:
usage = PUBKEY_USAGE_SIG | PUBKEY_USAGE_ENC;
use = PUBKEY_USAGE_SIG | PUBKEY_USAGE_ENC;
break;
case PUBKEY_ALGO_RSA_E:
usage = PUBKEY_USAGE_ENC;
use = PUBKEY_USAGE_ENC;
break;
case PUBKEY_ALGO_RSA_S:
usage = PUBKEY_USAGE_SIG;
use = PUBKEY_USAGE_SIG;
break;
case PUBKEY_ALGO_ELGAMAL_E:
usage = PUBKEY_USAGE_ENC;
use = PUBKEY_USAGE_ENC;
break;
case PUBKEY_ALGO_DSA:
usage = PUBKEY_USAGE_SIG;
use = PUBKEY_USAGE_SIG;
break;
case PUBKEY_ALGO_ELGAMAL:
usage = PUBKEY_USAGE_SIG | PUBKEY_USAGE_ENC;
use = PUBKEY_USAGE_SIG | PUBKEY_USAGE_ENC;
break;
default:
break;
}
return usage;
return use;
}

View File

@ -1931,7 +1931,9 @@ parse_gpg_control( IOBUF inp,
skipit:
if ( list_mode ) {
int c, i=0 ;
int c;
i=0;
printf("- private (rest length %lu)\n", pktlen);
if( iobuf_in_block_mode(inp) ) {
while( (c=iobuf_get(inp)) != -1 )

View File

@ -211,7 +211,7 @@ readn ( int fd, void *buf, size_t buflen, size_t *ret_nread )
*/
static int
agent_open ()
agent_open (void)
{
int fd;
char *infostr, *p;

View File

@ -117,7 +117,7 @@ get_session_key( PKT_pubkey_enc *k, DEK *dek )
static int
get_it( PKT_pubkey_enc *k, DEK *dek, PKT_secret_key *sk, u32 *keyid )
get_it( PKT_pubkey_enc *enc, DEK *dek, PKT_secret_key *sk, u32 *keyid )
{
int rc;
MPI plain_dek = NULL;
@ -125,7 +125,7 @@ get_it( PKT_pubkey_enc *k, DEK *dek, PKT_secret_key *sk, u32 *keyid )
unsigned n, nframe;
u16 csum, csum2;
rc = pubkey_decrypt(sk->pubkey_algo, &plain_dek, k->data, sk->skey );
rc = pubkey_decrypt(sk->pubkey_algo, &plain_dek, enc->data, sk->skey );
if( rc )
goto leave;
frame = mpi_get_buffer( plain_dek, &nframe, NULL );

View File

@ -495,7 +495,7 @@ write_signature_packets (SK_LIST sk_list, IOBUF out, MD_HANDLE hash,
* make a detached signature. If FILENAMES->d is NULL read from stdin
* and ignore the detached mode. Sign the file with all secret keys
* which can be taken from LOCUSR, if this is NULL, use the default one
* If ENCRYPT is true, use REMUSER (or ask if it is NULL) to encrypt the
* If ENCRYPTFLAG is true, use REMUSER (or ask if it is NULL) to encrypt the
* signed data for these users.
* If OUTFILE is not NULL; this file is used for output and the function
* does not ask for overwrite permission; output is then always
@ -503,7 +503,7 @@ write_signature_packets (SK_LIST sk_list, IOBUF out, MD_HANDLE hash,
*/
int
sign_file( STRLIST filenames, int detached, STRLIST locusr,
int encrypt, STRLIST remusr, const char *outfile )
int encryptflag, STRLIST remusr, const char *outfile )
{
const char *fname;
armor_filter_context_t afx;
@ -536,7 +536,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
else
fname = NULL;
if( fname && filenames->next && (!detached || encrypt) )
if( fname && filenames->next && (!detached || encryptflag) )
log_bug("multiple files can only be detached signed");
if( (rc=build_sk_list( locusr, &sk_list, 1, PUBKEY_USAGE_SIG )) )
@ -544,7 +544,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
if( !old_style )
old_style = only_old_style( sk_list );
if( encrypt ) {
if( encryptflag ) {
if( (rc=build_pk_list( remusr, &pk_list, PUBKEY_USAGE_ENC )) )
goto leave;
if( !old_style )
@ -586,13 +586,13 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
if( !multifile )
iobuf_push_filter( inp, md_filter, &mfx );
if( detached && !encrypt && !opt.rfc1991 )
if( detached && !encryptflag && !opt.rfc1991 )
afx.what = 2;
if( opt.armor && !outfile )
iobuf_push_filter( out, armor_filter, &afx );
if( encrypt ) {
if( encryptflag ) {
efx.pk_list = pk_list;
/* fixme: set efx.cfx.datalen if known */
iobuf_push_filter( out, encrypt_filter, &efx );
@ -604,7 +604,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
else {
if( old_style
|| compr_algo == 1
|| (compr_algo == -1 && !encrypt) )
|| (compr_algo == -1 && !encryptflag) )
zfx.algo = 1; /* use the non optional algorithm */
iobuf_push_filter( out, compress_filter, &zfx );
}
@ -672,7 +672,7 @@ sign_file( STRLIST filenames, int detached, STRLIST locusr,
iobuf_cancel(out);
else {
iobuf_close(out);
if (encrypt)
if (encryptflag)
write_status( STATUS_END_ENCRYPTION );
}
iobuf_close(inp);

View File

@ -1,3 +1,7 @@
2001-09-07 Werner Koch <wk@gnupg.org>
* util.h: Add strsep().
2001-08-30 Werner Koch <wk@gnupg.org>
* cipher.h (DEK): Added use_mdc.

View File

@ -203,6 +203,9 @@ char *stpcpy(char *a,const char *b);
#ifndef HAVE_STRLWR
char *strlwr(char *a);
#endif
#ifndef HAVE_STRSEP
char *strsep (char **stringp, const char *delim);
#endif
#ifndef HAVE_STRCASECMP
int strcasecmp( const char *, const char *b);
#endif

View File

@ -1,3 +1,7 @@
2001-09-07 Werner Koch <wk@gnupg.org>
* strgutil.c (strsep): New, taken from glibc 2.2.1.
2001-09-03 Werner Koch <wk@gnupg.org>
* miscutil.c (strtimestamp,asctimestamp): Avoid trigraphs.

View File

@ -689,6 +689,56 @@ stpcpy(char *a,const char *b)
}
#endif
#ifndef HAVE_STRSEP
/* code taken from glibc-2.2.1/sysdeps/generic/strsep.c */
char *
strsep (char **stringp, const char *delim)
{
char *begin, *end;
begin = *stringp;
if (begin == NULL)
return NULL;
/* A frequent case is when the delimiter string contains only one
character. Here we don't need to call the expensive `strpbrk'
function and instead work using `strchr'. */
if (delim[0] == '\0' || delim[1] == '\0')
{
char ch = delim[0];
if (ch == '\0')
end = NULL;
else
{
if (*begin == ch)
end = begin;
else if (*begin == '\0')
end = NULL;
else
end = strchr (begin + 1, ch);
}
}
else
/* Find the end of the token. */
end = strpbrk (begin, delim);
if (end)
{
/* Terminate the token and set *STRINGP past NUL character. */
*end++ = '\0';
*stringp = end;
}
else
/* No more delimiters; this is the last token. */
*stringp = NULL;
return begin;
}
#endif /*HAVE_STRSEP*/
#ifndef HAVE_STRLWR
char *
strlwr(char *s)
@ -823,4 +873,3 @@ vasprintf ( char **result, const char *format, va_list args)
#endif /*__MINGW32__*/