On Thu, Sep 29, 2005 at 11:39:41AM +0200, Romain Francoise wrote:
> Package: gnupg
> Version: 1.4.2-1
> Severity: normal
> 
> (I sent this report a few days ago but didn't get an ack from [EMAIL 
> PROTECTED])
> 
> The new version of GnuPG doesn't like my keyring:
> 
> pacem:/tmp$ gpg --check-trustdb                
> gpg: mpi larger than indicated length (2 bytes)
> gpg: keyring_get_keyblock: read error: invalid packet
> gpg: keyring_get_keyblock failed: invalid keyring
> gpg: failed to rebuild keyring cache: invalid keyring
> gpg: 3 marginal(s) needed, 1 complete(s) needed, classic trust model
> gpg: mpi larger than indicated length (2 bytes)
> gpg: keyring_get_keyblock: read error: invalid packet
> gpg: keydb_get_keyblock failed: invalid keyring
> gpg: validate_key_list failed
> zsh: exit 2     gpg --check-trustdb
> pacem:/tmp$

Please try the attached patch to 1.4.2.

David
Index: mpi/mpicoder.c
===================================================================
--- mpi/mpicoder.c      (revision 3878)
+++ mpi/mpicoder.c      (working copy)
@@ -80,16 +80,20 @@
     mpi_limb_t a;
     MPI val = MPI_NULL;
 
+    if (nread == nmax)
+        goto overflow;
     if( (c = iobuf_get(inp)) == -1 )
        goto leave;
-    if (++nread >= nmax)
+    nread++;
+    nbits = c << 8;
+
+    if (nread == nmax)
         goto overflow;
-    nbits = c << 8;
     if( (c = iobuf_get(inp)) == -1 )
        goto leave;
-    if (++nread >= nmax)
-        goto overflow;
+    nread++;
     nbits |= c;
+
     if( nbits > MAX_EXTERN_MPI_BITS ) {
        log_error("mpi too large for this implementation (%u bits)\n", nbits);
        goto leave;
@@ -112,7 +116,7 @@
     for( ; j > 0; j-- ) {
        a = 0;
        for(; i < BYTES_PER_MPI_LIMB; i++ ) {
-            if (nread >= nmax) {
+            if (nread == nmax) {
 #ifdef M_DEBUG
                 mpi_debug_free (val);
 #else

Reply via email to