[svn] GnuPG - r4990 - branches/STABLE-BRANCH-1-4/g10

svn author wk cvs at cvs.gnupg.org
Tue May 5 11:30:35 CEST 2009


Author: wk
Date: 2009-05-05 11:30:34 +0200 (Tue, 05 May 2009)
New Revision: 4990

Modified:
   branches/STABLE-BRANCH-1-4/g10/ChangeLog
   branches/STABLE-BRANCH-1-4/g10/parse-packet.c
   branches/STABLE-BRANCH-1-4/g10/tdbio.c
Log:
Fix bug#931.
Silent a compiler warning.


Modified: branches/STABLE-BRANCH-1-4/g10/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-1-4/g10/ChangeLog	2009-05-05 03:29:56 UTC (rev 4989)
+++ branches/STABLE-BRANCH-1-4/g10/ChangeLog	2009-05-05 09:30:34 UTC (rev 4990)
@@ -1,3 +1,12 @@
+2009-05-05  Werner Koch  <wk at g10code.com>
+
+	* tdbio.c (lookup_hashtable): Add const to function args.
+	(cmp_trec_fpr): Ditto.
+	(tdbio_search_trust_byfpr): Remove cast.
+
+	* parse-packet.c (parse): Remove special treatment for compressed
+	new style packets.  Fixes bug#931.
+	
 2009-04-03  Werner Koch  <wk at g10code.com>
 
 	* gpgv.c (main): Pass readonly flag to keydb_add_resource.

Modified: branches/STABLE-BRANCH-1-4/g10/parse-packet.c
===================================================================
--- branches/STABLE-BRANCH-1-4/g10/parse-packet.c	2009-05-05 03:29:56 UTC (rev 4989)
+++ branches/STABLE-BRANCH-1-4/g10/parse-packet.c	2009-05-05 09:30:34 UTC (rev 4990)
@@ -346,12 +346,19 @@
 	    rc = G10ERR_INVALID_PACKET;
 	    goto leave;
 	}
-        if (pkttype == PKT_COMPRESSED) {
-             iobuf_set_partial_block_mode(inp, c & 0xff);
-             pktlen = 0;/* to indicate partial length */
-	     partial=1;
-        }
-        else {
+/* The follwing code has been here for ages (2002-08-30) but it is
+   clearly wrong: For example passing a 0 as second argument to
+   iobuf_set_partial_block_mode stops the partial block mode which we
+   definitely do not want.  Also all values < 224 or 255 are not
+   valid.  Let's disable it and put PKT_COMPRESSED into the list of
+   allowed packets with partial header until someone complains. */
+/*         if (pkttype == PKT_COMPRESSED) { */
+/*              iobuf_set_partial_block_mode(inp, c & 0xff); */
+/*              pktlen = 0;/\* to indicate partial length *\/ */
+/* 	     partial=1; */
+/*         } */
+/*         else { */
+        {
              hdr[hdrlen++] = c;
              if( c < 192 )
 	       pktlen = c;
@@ -384,20 +391,22 @@
 	       }
              else
 	       {
-		 /* Partial body length.  Note that we handled
-		    PKT_COMPRESSED earlier. */
-		 if(pkttype==PKT_PLAINTEXT || pkttype==PKT_ENCRYPTED
-		    || pkttype==PKT_ENCRYPTED_MDC)
-		   {
-		     iobuf_set_partial_block_mode(inp, c & 0xff);
-		     pktlen = 0;/* to indicate partial length */
-		     partial=1;
-		   }
-		 else
-		   {
-		     log_error("%s: partial length for invalid"
-			       " packet type %d\n",iobuf_where(inp),pkttype);
-		     rc=G10ERR_INVALID_PACKET;
+		 /* Partial body length.  */
+		 switch (pkttype)
+                   {
+                   case PKT_PLAINTEXT:
+                   case PKT_ENCRYPTED:
+                   case PKT_ENCRYPTED_MDC:
+                   case PKT_COMPRESSED:
+		     iobuf_set_partial_block_mode (inp, (c & 0xff));
+		     pktlen = 0; /* Indicate partial length.  */
+		     partial= 1;
+		     break;
+
+                   default:
+		     log_error ("%s: partial length for invalid"
+                                " packet type %d\n", iobuf_where(inp),pkttype);
+		     rc = G10ERR_INVALID_PACKET;
 		     goto leave;
 		   }
 	       }

Modified: branches/STABLE-BRANCH-1-4/g10/tdbio.c
===================================================================
--- branches/STABLE-BRANCH-1-4/g10/tdbio.c	2009-05-05 03:29:56 UTC (rev 4989)
+++ branches/STABLE-BRANCH-1-4/g10/tdbio.c	2009-05-05 09:30:34 UTC (rev 4990)
@@ -1007,8 +1007,8 @@
  */
 static int
 lookup_hashtable( ulong table, const byte *key, size_t keylen,
-		  int (*cmpfnc)(void*, const TRUSTREC *), void *cmpdata,
-						TRUSTREC *rec )
+		  int (*cmpfnc)(const void*, const TRUSTREC *), 
+                  const void *cmpdata, TRUSTREC *rec )
 {
     int rc;
     ulong hashrec, item;
@@ -1464,10 +1464,10 @@
 
 
 static int
-cmp_trec_fpr ( void *fpr, const TRUSTREC *rec )
+cmp_trec_fpr (const void *fpr, const TRUSTREC *rec )
 {
-    return rec->rectype == RECTYPE_TRUST
-	   && !memcmp( rec->r.trust.fingerprint, fpr, 20);
+    return (rec->rectype == RECTYPE_TRUST
+            && !memcmp( rec->r.trust.fingerprint, fpr, 20));
 }
 
 
@@ -1476,9 +1476,9 @@
 {
     int rc;
 
-    /* locate the trust record using the hash table */
-    rc = lookup_hashtable( get_trusthashrec(), fingerprint, 20,
-			   cmp_trec_fpr, (void*)fingerprint, rec );
+    /* Locate the trust record using the hash table.  */
+    rc = lookup_hashtable (get_trusthashrec(), fingerprint, 20,
+			   cmp_trec_fpr, fingerprint, rec);
     return rc;
 }
 




More information about the Gnupg-commits mailing list