aboutsummaryrefslogtreecommitdiffstats
path: root/g10
diff options
context:
space:
mode:
Diffstat (limited to 'g10')
-rw-r--r--g10/ChangeLog15
-rw-r--r--g10/export.c3
-rw-r--r--g10/import.c9
-rw-r--r--g10/misc.c16
-rw-r--r--g10/options.skel7
-rw-r--r--g10/packet.h1
-rw-r--r--g10/parse-packet.c8
-rw-r--r--g10/plaintext.c3
8 files changed, 49 insertions, 13 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog
index 195175aa5..b33a72231 100644
--- a/g10/ChangeLog
+++ b/g10/ChangeLog
@@ -1,3 +1,18 @@
+2002-04-22 David Shaw <[email protected]>
+
+ * parse-packet.c (parse_plaintext), packet.h, plaintext.c
+ (handle_plaintext): Fix bug in handling literal packets with
+ zero-length data (no data was being confused with partial body
+ length).
+
+ * misc.c (pct_expando), options.skel: %t means extension ("jpg").
+ %T means MIME type ("image/jpeg").
+
+ * import.c (import_one): Only trigger trust update if the keyring
+ is actually changed.
+
+ * export.c (do_export_stream): Missing a m_free.
+
2002-04-22 Stefan Bellon <[email protected]>
* keyid.c (expirestr_from_sk, expirestr_from_sig): Added _() to
diff --git a/g10/export.c b/g10/export.c
index c9adc0639..6809232af 100644
--- a/g10/export.c
+++ b/g10/export.c
@@ -116,7 +116,7 @@ do_export_stream( IOBUF out, STRLIST users, int secret, int onlyrfc, int *any )
KBNODE keyblock = NULL;
KBNODE kbctx, node;
int ndesc;
- KEYDB_SEARCH_DESC *desc;
+ KEYDB_SEARCH_DESC *desc = NULL;
KEYDB_HANDLE kdbhd;
STRLIST sl;
@@ -248,6 +248,7 @@ do_export_stream( IOBUF out, STRLIST users, int secret, int onlyrfc, int *any )
rc = 0;
leave:
+ m_free(desc);
keydb_release (kdbhd);
release_kbnode( keyblock );
if( !*any )
diff --git a/g10/import.c b/g10/import.c
index 8281d00e8..e9cd75bb9 100644
--- a/g10/import.c
+++ b/g10/import.c
@@ -467,7 +467,6 @@ import_one( const char *fname, KBNODE keyblock, int fast,
return 0;
}
-
/* do we have this key already in one of our pubrings ? */
pk_orig = m_alloc_clear( sizeof *pk_orig );
rc = get_pubkey( pk_orig, keyid );
@@ -497,7 +496,10 @@ import_one( const char *fname, KBNODE keyblock, int fast,
if (rc)
log_error (_("error writing keyring `%s': %s\n"),
keydb_get_resource_name (hd), g10_errstr(rc));
+ else
+ revalidation_mark ();
keydb_release (hd);
+
/* we are ready */
if( !opt.quiet )
log_info( _("key %08lX: public key imported\n"), (ulong)keyid[1]);
@@ -568,6 +570,9 @@ import_one( const char *fname, KBNODE keyblock, int fast,
if (rc)
log_error (_("error writing keyring `%s': %s\n"),
keydb_get_resource_name (hd), g10_errstr(rc) );
+ else
+ revalidation_mark ();
+
/* we are ready */
if( !opt.quiet ) {
if( n_uids == 1 )
@@ -601,8 +606,6 @@ import_one( const char *fname, KBNODE keyblock, int fast,
}
keydb_release (hd); hd = NULL;
}
- if (!rc)
- revalidation_mark ();
leave:
release_kbnode( keyblock_orig );
diff --git a/g10/misc.c b/g10/misc.c
index 99c6bb7b9..f1afa4a18 100644
--- a/g10/misc.c
+++ b/g10/misc.c
@@ -509,14 +509,22 @@ pct_expando(const char *string,PKT_public_key *pk)
}
break;
- /* photo type. For now, it's always jpeg so this is
+ /* photo types. For now, it's always jpeg so this is
easy! */
case 't':
- if(idx+4>maxlen)
+ if(idx+3>maxlen)
goto fail;
- strcpy(&ret[idx],"jpeg");
- idx+=4;
+ strcpy(&ret[idx],"jpg");
+ idx+=3;
+ break;
+
+ case 'T':
+ if(idx+10>maxlen)
+ goto fail;
+
+ strcpy(&ret[idx],"image/jpeg");
+ idx+=10;
break;
case '%':
diff --git a/g10/options.skel b/g10/options.skel
index e22c6139f..0a24bc32c 100644
--- a/g10/options.skel
+++ b/g10/options.skel
@@ -160,7 +160,8 @@ lock-once
# %I is the same as %i, but the file isn't deleted afterwards by GnuPG.
# %k is expanded to the key ID of the key.
# %K is expanded to the long OpenPGP key ID of the key.
-# %t is expanded to the type of image (e.g. "jpeg").
+# %t is expanded to the extension of the image (e.g. "jpg").
+# %T is expanded to the MIME type of the image (e.g. "image/jpeg").
# %f is expanded to the fingerprint of the key.
# %% is %, of course.
#
@@ -177,10 +178,10 @@ lock-once
# photo-viewer "display -title 'KeyID 0x%k'"
#
# This one saves a copy of the photo ID in your home directory:
-# photo-viewer "cat > ~/photoid-for-key-%k.jpg"
+# photo-viewer "cat > ~/photoid-for-key-%k.%t"
#
# Use your MIME handler to view photos:
-# photo-viewer "metamail -q -d -b -c image/%t -s 'KeyID 0x%k' -f GnuPG"
+# photo-viewer "metamail -q -d -b -c %T -s 'KeyID 0x%k' -f GnuPG"
# Passphrase agent
diff --git a/g10/packet.h b/g10/packet.h
index e98014782..967f0a8c7 100644
--- a/g10/packet.h
+++ b/g10/packet.h
@@ -275,6 +275,7 @@ typedef struct {
u32 len; /* length of encrypted data */
IOBUF buf; /* IOBUF reference */
byte new_ctb;
+ byte is_partial; /* partial length encoded */
int mode;
u32 timestamp;
int namelen;
diff --git a/g10/parse-packet.c b/g10/parse-packet.c
index a4c4403a6..d74ebaf87 100644
--- a/g10/parse-packet.c
+++ b/g10/parse-packet.c
@@ -1928,7 +1928,7 @@ parse_plaintext( IOBUF inp, int pkttype, unsigned long pktlen,
PACKET *pkt, int new_ctb )
{
int rc = 0;
- int mode, namelen;
+ int mode, namelen, partial=0;
PKT_plaintext *pt;
byte *p;
int c, i;
@@ -1938,12 +1938,18 @@ parse_plaintext( IOBUF inp, int pkttype, unsigned long pktlen,
rc = G10ERR_INVALID_PACKET;
goto leave;
}
+ /* A packet length of zero indicates partial body length. A zero
+ data length isn't a zero length packet due to the header (mode,
+ name, etc), so this is accurate. */
+ if(pktlen==0)
+ partial=1;
mode = iobuf_get_noeof(inp); if( pktlen ) pktlen--;
namelen = iobuf_get_noeof(inp); if( pktlen ) pktlen--;
pt = pkt->pkt.plaintext = m_alloc(sizeof *pkt->pkt.plaintext + namelen -1);
pt->new_ctb = new_ctb;
pt->mode = mode;
pt->namelen = namelen;
+ pt->is_partial = partial;
if( pktlen ) {
for( i=0; pktlen > 4 && i < namelen; pktlen--, i++ )
pt->name[i] = iobuf_get_noeof(inp);
diff --git a/g10/plaintext.c b/g10/plaintext.c
index b559a90b2..7f9edb82c 100644
--- a/g10/plaintext.c
+++ b/g10/plaintext.c
@@ -114,7 +114,8 @@ handle_plaintext( PKT_plaintext *pt, md_filter_context_t *mfx,
goto leave;
}
- if( pt->len ) {
+ if( !pt->is_partial ) {
+ /* we have an actual length (which might be zero). */
assert( !clearsig );
if( convert ) { /* text mode */
for( ; pt->len; pt->len-- ) {