From f77fd572db658959fa40aa8c181be919e688b707 Mon Sep 17 00:00:00 2001 From: NIIBE Yutaka Date: Thu, 30 Apr 2015 17:02:42 +0900 Subject: g10: fix cmp_public_key. * g10/free-packet.c (cmp_public_keys): Compare opaque data at the first entry of the array when it's unknown algo. -- (forwardported from 2.0 commit 43429c7869152f301157e4b24790b3801dce0f0a) GnuPG-bug-id: 1962 --- g10/free-packet.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/g10/free-packet.c b/g10/free-packet.c index 49d54f419..670f2565e 100644 --- a/g10/free-packet.c +++ b/g10/free-packet.c @@ -434,11 +434,14 @@ cmp_public_keys( PKT_public_key *a, PKT_public_key *b ) return -1; n = pubkey_get_npkey( b->pubkey_algo ); - if( !n ) - return -1; /* can't compare due to unknown algorithm */ - for(i=0; i < n; i++ ) { - if( mpi_cmp( a->pkey[i], b->pkey[i] ) ) - return -1; + if( !n ) { /* unknown algorithm, rest is in opaque MPI */ + if( mpi_cmp( a->pkey[0], b->pkey[0] ) ) + return -1; /* can't compare due to unknown algorithm */ + } else { + for(i=0; i < n; i++ ) { + if( mpi_cmp( a->pkey[i], b->pkey[i] ) ) + return -1; + } } return 0; -- cgit v1.2.3