g10: fix cmp_public_key.
authorNIIBE Yutaka <gniibe@fsij.org>
Thu, 30 Apr 2015 08:02:42 +0000 (17:02 +0900)
committerNIIBE Yutaka <gniibe@fsij.org>
Fri, 1 May 2015 04:58:18 +0000 (13:58 +0900)
* 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

index 49d54f4..670f256 100644 (file)
@@ -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;