diff options
author | Werner Koch <[email protected]> | 2017-03-30 08:35:20 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2017-03-30 08:49:41 +0000 |
commit | 2975eee420007557a138445d0505f1d590d88d7e (patch) | |
tree | b516b340d646dc3d74b15b518c24d420e0adeeda | |
parent | scd: Support OpenPGP card V3 for RSA. (diff) | |
download | gnupg-2975eee420007557a138445d0505f1d590d88d7e.tar.gz gnupg-2975eee420007557a138445d0505f1d590d88d7e.zip |
gpg: Fix export porting of zero length user ID packets.
* g10/build-packet.c (do_user_id): Avoid indeterminate length header.
--
We are able to import such user ids but when exporting them the
exported data could not be imported again because the parser bails out
on invalid keyrings. This is now fixed and should be backported.
Note that in 2.0 this is only an issue for attribute packets. In 2.1
user IDs were also affected.a
Signed-off-by: Werner Koch <[email protected]>
-rw-r--r-- | g10/build-packet.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/g10/build-packet.c b/g10/build-packet.c index 5cc03cf65..d7f2291f2 100644 --- a/g10/build-packet.c +++ b/g10/build-packet.c @@ -233,12 +233,17 @@ do_user_id( IOBUF out, int ctb, PKT_user_id *uid ) if( uid->attrib_data ) { - write_header(out, ctb, uid->attrib_len); + /* We need to take special care of a user ID with a length of 0: + * Without forcing HDRLEN to 2 in this case an indeterminate length + * packet would be written which is not allowed. Note that we are + * always called with a CTB indicating an old packet header format, + * so that forcing a 2 octet header works. */ + write_header2 (out, ctb, uid->attrib_len, (uid->attrib_len? 0 : 2)); rc = iobuf_write( out, uid->attrib_data, uid->attrib_len ); } else { - write_header2( out, ctb, uid->len, 2 ); + write_header2 (out, ctb, uid->len, 2); rc = iobuf_write( out, uid->name, uid->len ); } return rc; |