diff options
Diffstat (limited to '')
-rw-r--r-- | g10/ChangeLog | 12 | ||||
-rw-r--r-- | g10/mainproc.c | 4 | ||||
-rw-r--r-- | g10/pkclist.c | 40 | ||||
-rw-r--r-- | g10/plaintext.c | 92 |
4 files changed, 92 insertions, 56 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog index 10f889312..30d2c6b5e 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,15 @@ +Fri Sep 3 10:04:45 CEST 1999 Werner Koch <[email protected]> + + + * pkclist.c (build_pk_list): Skip keys set with --encrypt-to also + when asking for a key. + + * plaintext.c (handle_plaintext): Make sure that we don't read a + second EOF in the read loop for partial length packets. + + * mainproc.c (check_sig_and_print): print user ID as utf-8. + + Thu Sep 2 16:40:55 CEST 1999 Werner Koch <[email protected]> diff --git a/g10/mainproc.c b/g10/mainproc.c index 4553253bb..d19bbb965 100644 --- a/g10/mainproc.c +++ b/g10/mainproc.c @@ -1058,8 +1058,8 @@ check_sig_and_print( CTX c, KBNODE node ) : _("Good signature from \"")); else log_info( _(" aka \"")); - print_string( log_stream(), un->pkt->pkt.user_id->name, - un->pkt->pkt.user_id->len, '\"' ); + print_utf8_string( log_stream(), un->pkt->pkt.user_id->name, + un->pkt->pkt.user_id->len ); fputs("\"\n", log_stream() ); if( rc ) break; /* print only one id in this case */ diff --git a/g10/pkclist.c b/g10/pkclist.c index fb0d3cd41..fab2f13a7 100644 --- a/g10/pkclist.c +++ b/g10/pkclist.c @@ -751,11 +751,18 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use ) tty_printf(_("No such user ID.\n")); else if( !(rc=check_pubkey_algo2(pk->pubkey_algo, use)) ) { if( have_def_rec ) { - PK_LIST r = m_alloc( sizeof *r ); - r->pk = pk; pk = NULL; - r->next = pk_list; - r->mark = 0; - pk_list = r; + if (key_present_in_pk_list(pk_list, pk) == 0) { + free_public_key(pk); pk = NULL; + log_info(_("skipped: public key " + "already set as default recipient\n") ); + } + else { + PK_LIST r = m_alloc( sizeof *r ); + r->pk = pk; pk = NULL; + r->next = pk_list; + r->mark = 0; + pk_list = r; + } any_recipients = 1; break; } @@ -771,13 +778,22 @@ build_pk_list( STRLIST remusr, PK_LIST *ret_pk_list, unsigned use ) tty_printf(_("Public key is disabled.\n") ); } else if( do_we_trust_pre( pk, trustlevel ) ) { - PK_LIST r; - - r = m_alloc( sizeof *r ); - r->pk = pk; pk = NULL; - r->next = pk_list; - r->mark = 0; - pk_list = r; + /* Skip the actual key if the key is already present + * in the list */ + if (key_present_in_pk_list(pk_list, pk) == 0) { + free_public_key(pk); pk = NULL; + log_info(_("skipped: public key " + "already set with --encrypt-to\n") ); + } + else { + PK_LIST r; + + r = m_alloc( sizeof *r ); + r->pk = pk; pk = NULL; + r->next = pk_list; + r->mark = 0; + pk_list = r; + } any_recipients = 1; break; } diff --git a/g10/plaintext.c b/g10/plaintext.c index 7411a4b16..f8f4dcaf7 100644 --- a/g10/plaintext.c +++ b/g10/plaintext.c @@ -166,10 +166,19 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, } else { /* binary mode */ byte *buffer = m_alloc( 32768 ); - for( ;; ) { + int eof; + for( eof=0; !eof; ) { + /* Why do we check for len < 32768: + * If we won� we would practically read 2 EOFS but + * the first one has already popped the block_filter + * off and therefore we don't catch the boundary. + * Always assume EOF if iobuf_read returns less bytes + * then requested */ int len = iobuf_read( pt->buf, buffer, 32768 ); if( len == -1 ) break; + if( len < 32768 ) + eof = 1; if( mfx->md ) md_write( mfx->md, buffer, len ); if( fp ) { @@ -243,6 +252,46 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx, return rc; } +static void +do_hash( MD_HANDLE md, MD_HANDLE md2, IOBUF fp, int textmode ) +{ + text_filter_context_t tfx; + int c; + + if( textmode ) { + memset( &tfx, 0, sizeof tfx); + iobuf_push_filter( fp, text_filter, &tfx ); + } + if( md2 ) { /* work around a strange behaviour in pgp2 */ + /* It seems that at least PGP5 converts a single CR to a CR,LF too */ + int lc = -1; + while( (c = iobuf_get(fp)) != -1 ) { + if( c == '\n' && lc == '\r' ) + md_putc(md2, c); + else if( c == '\n' ) { + md_putc(md2, '\r'); + md_putc(md2, c); + } + else if( c != '\n' && lc == '\r' ) { + md_putc(md2, '\n'); + md_putc(md2, c); + } + else + md_putc(md2, c); + + if( md ) + md_putc(md, c ); + lc = c; + } + } + else { + while( (c = iobuf_get(fp)) != -1 ) { + if( md ) + md_putc(md, c ); + } + } +} + /**************** * Ask for the detached datafile and calculate the digest from it. @@ -255,7 +304,6 @@ ask_for_detached_datafile( MD_HANDLE md, MD_HANDLE md2, char *answer = NULL; IOBUF fp; int rc = 0; - int c; fp = open_sigfile( inname ); /* open default file */ if( !fp && !opt.batch ) { @@ -299,46 +347,6 @@ ask_for_detached_datafile( MD_HANDLE md, MD_HANDLE md2, } -static void -do_hash( MD_HANDLE md, MD_HANDLE md2, IOBUF fp, int textmode ) -{ - text_filter_context_t tfx; - int c; - - if( textmode ) { - memset( &tfx, 0, sizeof tfx); - iobuf_push_filter( fp, text_filter, &tfx ); - } - if( md2 ) { /* work around a strange behaviour in pgp2 */ - /* It seems that at least PGP5 converts a single CR to a CR,LF too */ - int lc = -1; - while( (c = iobuf_get(fp)) != -1 ) { - if( c == '\n' && lc == '\r' ) - md_putc(md2, c); - else if( c == '\n' ) { - md_putc(md2, '\r'); - md_putc(md2, c); - } - else if( c != '\n' && lc == '\r' ) { - md_putc(md2, '\n'); - md_putc(md2, c); - } - else - md_putc(md2, c); - - if( md ) - md_putc(md, c ); - lc = c; - } - } - else { - while( (c = iobuf_get(fp)) != -1 ) { - if( md ) - md_putc(md, c ); - } - } -} - /**************** * Hash the given files and append the hash to hash context md. |