chiark / gitweb /
gpg: Fix possible segv when attribute packets are filtered.
authorWerner Koch <wk@gnupg.org>
Fri, 3 Mar 2017 08:50:40 +0000 (09:50 +0100)
committerDaniel Kahn Gillmor <dkg@fifthhorseman.net>
Mon, 18 Sep 2017 20:41:12 +0000 (21:41 +0100)
* g10/import.c (impex_filter_getval): Handle PKT_ATTRIBUTE the same as
PKT_USER_ID
(apply_drop_sig_filter): Ditto.
--

The old code was plainly wrong in that it considered PKT_ATTRIBUTE to
use a PKT_signature object.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 5f6f3f5cae8a95ed469129f9677782c17951dab3)

Gbp-Pq: Name 0047-gpg-Fix-possible-segv-when-attribute-packets-are-fil.patch

g10/import.c

index b6c04dcfc2a6b4375d209fc83f9e7054ab0ee493..4e6f6923defe8e8a54dc2559d47696ca839a9582 100644 (file)
@@ -1173,7 +1173,8 @@ impex_filter_getval (void *cookie, const char *propname)
   static char numbuf[20];
   const char *result;
 
-  if (node->pkt->pkttype == PKT_USER_ID)
+  if (node->pkt->pkttype == PKT_USER_ID
+      || node->pkt->pkttype == PKT_ATTRIBUTE)
     {
       if (!strcmp (propname, "uid"))
         result = node->pkt->pkt.user_id->name;
@@ -1191,8 +1192,7 @@ impex_filter_getval (void *cookie, const char *propname)
       else
         result = NULL;
     }
-  else if (node->pkt->pkttype == PKT_SIGNATURE
-           || node->pkt->pkttype == PKT_ATTRIBUTE)
+  else if (node->pkt->pkttype == PKT_SIGNATURE)
     {
       PKT_signature *sig = node->pkt->pkt.signature;
 
@@ -1313,12 +1313,12 @@ apply_drop_sig_filter (kbnode_t keyblock, recsel_expr_t selector)
       if (node->pkt->pkttype == PKT_PUBLIC_SUBKEY
           || node->pkt->pkttype == PKT_SECRET_SUBKEY)
         break; /* ready.  */
-      if (node->pkt->pkttype == PKT_USER_ID)
+      if (node->pkt->pkttype == PKT_USER_ID
+          || node->pkt->pkttype == PKT_ATTRIBUTE)
         active = 1;
       if (!active)
         continue;
-      if (node->pkt->pkttype != PKT_SIGNATURE
-          && node->pkt->pkttype != PKT_ATTRIBUTE)
+      if (node->pkt->pkttype != PKT_SIGNATURE)
         continue;
 
       sig = node->pkt->pkt.signature;