4538af
diff -up gnupg-2.2.20/common/server-help.c.coverity gnupg-2.2.20/common/server-help.c
4538af
--- gnupg-2.2.20/common/server-help.c.coverity	2019-02-11 10:59:34.000000000 +0100
4538af
+++ gnupg-2.2.20/common/server-help.c	2020-05-04 12:00:01.085945639 +0200
4538af
@@ -156,7 +156,7 @@ get_option_value (char *line, const char
4538af
   *pend = 0;
4538af
   *r_value = xtrystrdup (p);
4538af
   *pend = c;
4538af
-  if (!p)
4538af
+  if (!*r_value)
4538af
     return my_error_from_syserror ();
4538af
   return 0;
4538af
 }
4538af
diff -up gnupg-2.2.20/dirmngr/dns.c.coverity gnupg-2.2.20/dirmngr/dns.c
4538af
--- gnupg-2.2.20/dirmngr/dns.c.coverity	2019-07-09 11:08:45.000000000 +0200
4538af
+++ gnupg-2.2.20/dirmngr/dns.c	2020-05-04 18:04:12.285521661 +0200
4538af
@@ -10106,9 +10106,8 @@ static const struct {
4538af
 	{ "AR",         DNS_S_ADDITIONAL },
4538af
 };
4538af
 
4538af
-const char *(dns_strsection)(enum dns_section section) {
4538af
-	char _dst[DNS_STRMAXLEN + 1] = { 0 };
4538af
-	struct dns_buf dst = DNS_B_INTO(_dst, sizeof _dst);
4538af
+const char *(dns_strsection)(enum dns_section section, void *_dst, size_t lim) {
4538af
+	struct dns_buf dst = DNS_B_INTO(_dst, lim);
4538af
 	unsigned i;
4538af
 
4538af
 	for (i = 0; i < lengthof(dns_sections); i++) {
4538af
@@ -10156,9 +10155,8 @@ static const struct {
4538af
 	{ "IN", DNS_C_IN },
4538af
 };
4538af
 
4538af
-const char *(dns_strclass)(enum dns_class type) {
4538af
-	char _dst[DNS_STRMAXLEN + 1] = { 0 };
4538af
-	struct dns_buf dst = DNS_B_INTO(_dst, sizeof _dst);
4538af
+const char *(dns_strclass)(enum dns_class type, void *_dst, size_t lim) {
4538af
+	struct dns_buf dst = DNS_B_INTO(_dst, lim);
4538af
 	unsigned i;
4538af
 
4538af
 	for (i = 0; i < lengthof(dns_classes); i++) {
4538af
@@ -10193,9 +10191,8 @@ enum dns_class dns_iclass(const char *na
4538af
 } /* dns_iclass() */
4538af
 
4538af
 
4538af
-const char *(dns_strtype)(enum dns_type type) {
4538af
-	char _dst[DNS_STRMAXLEN + 1] = { 0 };
4538af
-	struct dns_buf dst = DNS_B_INTO(_dst, sizeof _dst);
4538af
+const char *(dns_strtype)(enum dns_type type, void *_dst, size_t lim) {
4538af
+	struct dns_buf dst = DNS_B_INTO(_dst, lim);
4538af
 	unsigned i;
4538af
 
4538af
 	for (i = 0; i < lengthof(dns_rrtypes); i++) {
4538af
diff -up gnupg-2.2.20/dirmngr/dns.h.coverity gnupg-2.2.20/dirmngr/dns.h
4538af
--- gnupg-2.2.20/dirmngr/dns.h.coverity	2019-03-07 13:03:26.000000000 +0100
4538af
+++ gnupg-2.2.20/dirmngr/dns.h	2020-05-04 18:04:12.287521625 +0200
4538af
@@ -272,15 +272,25 @@ enum dns_rcode {
4538af
  */
4538af
 #define DNS_STRMAXLEN 47 /* "QUESTION|ANSWER|AUTHORITY|ADDITIONAL" */
4538af
 
4538af
-DNS_PUBLIC const char *dns_strsection(enum dns_section);
4538af
+DNS_PUBLIC const char *dns_strsection(enum dns_section, void *, size_t);
4538af
+#define dns_strsection3(a, b, c) \
4538af
+				dns_strsection((a), (b), (c))
4538af
+#define dns_strsection1(a)	dns_strsection((a), (char [DNS_STRMAXLEN + 1]){ 0 }, DNS_STRMAXLEN + 1)
4538af
+#define dns_strsection(...)	DNS_PP_CALL(DNS_PP_XPASTE(dns_strsection, DNS_PP_NARG(__VA_ARGS__)), __VA_ARGS__)
4538af
 
4538af
 DNS_PUBLIC enum dns_section dns_isection(const char *);
4538af
 
4538af
-DNS_PUBLIC const char *dns_strclass(enum dns_class);
4538af
+DNS_PUBLIC const char *dns_strclass(enum dns_class, void *, size_t);
4538af
+#define dns_strclass3(a, b, c)	dns_strclass((a), (b), (c))
4538af
+#define dns_strclass1(a)	dns_strclass((a), (char [DNS_STRMAXLEN + 1]){ 0 }, DNS_STRMAXLEN + 1)
4538af
+#define dns_strclass(...)	DNS_PP_CALL(DNS_PP_XPASTE(dns_strclass, DNS_PP_NARG(__VA_ARGS__)), __VA_ARGS__)
4538af
 
4538af
 DNS_PUBLIC enum dns_class dns_iclass(const char *);
4538af
 
4538af
-DNS_PUBLIC const char *dns_strtype(enum dns_type);
4538af
+DNS_PUBLIC const char *dns_strtype(enum dns_type, void *, size_t);
4538af
+#define dns_strtype3(a, b, c)	dns_strtype((a), (b), (c))
4538af
+#define dns_strtype1(a)		dns_strtype((a), (char [DNS_STRMAXLEN + 1]){ 0 }, DNS_STRMAXLEN + 1)
4538af
+#define dns_strtype(...)	DNS_PP_CALL(DNS_PP_XPASTE(dns_strtype, DNS_PP_NARG(__VA_ARGS__)), __VA_ARGS__)
4538af
 
4538af
 DNS_PUBLIC enum dns_type dns_itype(const char *);
4538af
 
4538af
diff -up gnupg-2.2.20/dirmngr/domaininfo.c.coverity gnupg-2.2.20/dirmngr/domaininfo.c
4538af
--- gnupg-2.2.20/dirmngr/domaininfo.c.coverity	2019-07-09 11:08:45.000000000 +0200
4538af
+++ gnupg-2.2.20/dirmngr/domaininfo.c	2020-05-04 17:54:30.800899152 +0200
4538af
@@ -193,6 +193,7 @@ insert_or_update (const char *domain,
4538af
           log_error ("domaininfo: error allocating helper array: %s\n",
4538af
                      gpg_strerror (gpg_err_code_from_syserror ()));
4538af
           drop_extra = bucket;
4538af
+          xfree (di_new);
4538af
           goto leave;
4538af
         }
4538af
       narray = 0;
4538af
@@ -258,6 +259,8 @@ insert_or_update (const char *domain,
4538af
        * sensible strategy.  */
4538af
       drop_extra = domainbuckets[hash];
4538af
       domainbuckets[hash] = keep;
4538af
+
4538af
+      xfree (array);
4538af
     }
4538af
 
4538af
   /* Insert */
4538af
diff -up gnupg-2.2.20/dirmngr/http.c.coverity gnupg-2.2.20/dirmngr/http.c
4538af
--- gnupg-2.2.20/dirmngr/http.c.coverity	2019-11-18 18:44:33.000000000 +0100
4538af
+++ gnupg-2.2.20/dirmngr/http.c	2020-05-04 17:00:47.826878715 +0200
4538af
@@ -3656,7 +3656,6 @@ http_prepare_redirect (http_redir_info_t
4538af
       if (!newurl)
4538af
         {
4538af
           err = gpg_error_from_syserror ();
4538af
-          http_release_parsed_uri (locuri);
4538af
           return err;
4538af
         }
4538af
     }
4538af
@@ -3675,7 +3674,6 @@ http_prepare_redirect (http_redir_info_t
4538af
       if (!newurl)
4538af
         {
4538af
           err = gpg_error_from_syserror ();
4538af
-          http_release_parsed_uri (locuri);
4538af
           return err;
4538af
         }
4538af
     }
4538af
diff -up gnupg-2.2.20/dirmngr/ks-engine-hkp.c.coverity gnupg-2.2.20/dirmngr/ks-engine-hkp.c
4538af
--- gnupg-2.2.20/dirmngr/ks-engine-hkp.c.coverity	2019-11-18 18:44:33.000000000 +0100
4538af
+++ gnupg-2.2.20/dirmngr/ks-engine-hkp.c	2020-05-04 12:39:49.970920664 +0200
4538af
@@ -1426,7 +1426,7 @@ ks_hkp_search (ctrl_t ctrl, parsed_uri_t
4538af
   int reselect;
4538af
   unsigned int httpflags;
4538af
   char *httphost = NULL;
4538af
-  unsigned int http_status;
4538af
+  unsigned int http_status = 0;
4538af
   unsigned int tries = SEND_REQUEST_RETRIES;
4538af
   unsigned int extra_tries = SEND_REQUEST_EXTRA_RETRIES;
4538af
 
4538af
diff -up gnupg-2.2.20/g10/card-util.c.coverity gnupg-2.2.20/g10/card-util.c
4538af
--- gnupg-2.2.20/g10/card-util.c.coverity	2020-03-03 13:33:22.000000000 +0100
4538af
+++ gnupg-2.2.20/g10/card-util.c	2020-05-04 16:56:47.788157786 +0200
4538af
@@ -704,7 +704,7 @@ card_status (ctrl_t ctrl, estream_t fp,
4538af
 {
4538af
   int err;
4538af
   strlist_t card_list, sl;
4538af
-  char *serialno0, *serialno1;
4538af
+  char *serialno0, *serialno1 = NULL;
4538af
   int all_cards = 0;
4538af
   int any_card = 0;
4538af
 
4538af
@@ -749,6 +749,7 @@ card_status (ctrl_t ctrl, estream_t fp,
4538af
 
4538af
       current_card_status (ctrl, fp, NULL, 0);
4538af
       xfree (serialno1);
4538af
+      serialno1 = NULL;
4538af
 
4538af
       if (!all_cards)
4538af
         goto leave;
4538af
diff -up gnupg-2.2.20/g10/import.c.coverity gnupg-2.2.20/g10/import.c
4538af
--- gnupg-2.2.20/g10/import.c.coverity	2020-05-04 12:34:39.820379830 +0200
4538af
+++ gnupg-2.2.20/g10/import.c	2020-05-04 12:34:55.366106195 +0200
4538af
@@ -1888,7 +1888,7 @@ import_one_real (ctrl_t ctrl,
4538af
 
4538af
   if (opt.interactive && !silent)
4538af
     {
4538af
-      if (is_status_enabled())
4538af
+      if (uidnode && is_status_enabled())
4538af
         print_import_check (pk, uidnode->pkt->pkt.user_id);
4538af
       merge_keys_and_selfsig (ctrl, keyblock);
4538af
       tty_printf ("\n");
4538af
diff -up gnupg-2.2.20/g10/keygen.c.coverity gnupg-2.2.20/g10/keygen.c
4538af
--- gnupg-2.2.20/g10/keygen.c.coverity	2020-05-04 12:23:04.852613017 +0200
4538af
+++ gnupg-2.2.20/g10/keygen.c	2020-05-04 17:33:18.923891110 +0200
4538af
@@ -3075,7 +3075,7 @@ parse_key_parameter_part (ctrl_t ctrl,
4538af
   char *endp;
4538af
   const char *curve = NULL;
4538af
   int ecdh_or_ecdsa = 0;
4538af
-  unsigned int size;
4538af
+  unsigned int size = 0;
4538af
   int keyuse;
4538af
   int i;
4538af
   const char *s;
4538af
@@ -5719,12 +5719,20 @@ gen_card_key (int keyno, int algo, int i
4538af
      the self-signatures. */
4538af
   err = agent_readkey (NULL, 1, keyid, &public);
4538af
   if (err)
4538af
-    return err;
4538af
+    {
4538af
+      xfree (pkt);
4538af
+      xfree (pk);
4538af
+      return err;
4538af
+    }
4538af
   err = gcry_sexp_sscan (&s_key, NULL, public,
4538af
                          gcry_sexp_canon_len (public, 0, NULL, NULL));
4538af
   xfree (public);
4538af
   if (err)
4538af
-    return err;
4538af
+    {
4538af
+      xfree (pkt);
4538af
+      xfree (pk);
4538af
+      return err;
4538af
+    }
4538af
 
4538af
   if (algo == PUBKEY_ALGO_RSA)
4538af
     err = key_from_sexp (pk->pkey, s_key, "public-key", "ne");
4538af
@@ -5739,6 +5747,7 @@ gen_card_key (int keyno, int algo, int i
4538af
   if (err)
4538af
     {
4538af
       log_error ("key_from_sexp failed: %s\n", gpg_strerror (err) );
4538af
+      xfree (pkt);
4538af
       free_public_key (pk);
4538af
       return err;
4538af
     }
4538af
diff -up gnupg-2.2.20/g10/sig-check.c.coverity gnupg-2.2.20/g10/sig-check.c
4538af
--- gnupg-2.2.20/g10/sig-check.c.coverity	2020-05-04 12:18:18.515653963 +0200
4538af
+++ gnupg-2.2.20/g10/sig-check.c	2020-05-04 12:18:33.599388425 +0200
4538af
@@ -902,6 +902,7 @@ check_signature_over_key_or_uid (ctrl_t
4538af
                 {
4538af
                   /* Issued by a subkey.  */
4538af
                   signer = subk;
4538af
+                  *is_selfsig = 1;
4538af
                   break;
4538af
                 }
4538af
             }
4538af
diff -up gnupg-2.2.20/g10/sign.c.coverity gnupg-2.2.20/g10/sign.c
4538af
--- gnupg-2.2.20/g10/sign.c.coverity	2020-04-30 11:56:43.909360043 +0200
4538af
+++ gnupg-2.2.20/g10/sign.c	2020-05-04 12:08:56.651544958 +0200
4538af
@@ -823,7 +823,7 @@ write_signature_packets (ctrl_t ctrl,
4538af
       PKT_public_key *pk;
4538af
       PKT_signature *sig;
4538af
       gcry_md_hd_t md;
4538af
-      gpg_error_t err;
4538af
+      gpg_error_t err = 0;
4538af
 
4538af
       pk = sk_rover->pk;
4538af
 
4538af
diff -up gnupg-2.2.20/kbx/keybox-dump.c.coverity gnupg-2.2.20/kbx/keybox-dump.c
4538af
--- gnupg-2.2.20/kbx/keybox-dump.c.coverity	2019-08-23 15:59:06.000000000 +0200
4538af
+++ gnupg-2.2.20/kbx/keybox-dump.c	2020-05-04 17:25:53.365946213 +0200
4538af
@@ -786,11 +786,15 @@ _keybox_dump_cut_records (const char *fi
4538af
   while ( !(rc = _keybox_read_blob (&blob, fp, NULL)) )
4538af
     {
4538af
       if (recno > to)
4538af
-        break; /* Ready.  */
4538af
+        {
4538af
+          _keybox_release_blob (blob);
4538af
+          break; /* Ready.  */
4538af
+        }
4538af
       if (recno >= from)
4538af
         {
4538af
           if ((rc = _keybox_write_blob (blob, outfp)))
4538af
             {
4538af
+              _keybox_release_blob (blob);
4538af
               fprintf (stderr, "error writing output: %s\n",
4538af
                        gpg_strerror (rc));
4538af
               goto leave;
4538af
diff -up gnupg-2.2.20/tools/gpg-wks-server.c.coverity gnupg-2.2.20/tools/gpg-wks-server.c
4538af
--- gnupg-2.2.20/tools/gpg-wks-server.c.coverity	2020-02-10 16:12:13.000000000 +0100
4538af
+++ gnupg-2.2.20/tools/gpg-wks-server.c	2020-05-04 11:52:42.547643198 +0200
4538af
@@ -890,15 +890,18 @@ store_key_as_pending (const char *dir, e
4538af
     }
4538af
 
4538af
  leave:
4538af
-  if (err)
4538af
+  if (fname)
4538af
     {
4538af
-      es_fclose (outfp);
4538af
-      gnupg_remove (fname);
4538af
-    }
4538af
-  else if (es_fclose (outfp))
4538af
-    {
4538af
-      err = gpg_error_from_syserror ();
4538af
-      log_error ("error closing '%s': %s\n", fname, gpg_strerror (err));
4538af
+      if (err)
4538af
+        {
4538af
+          es_fclose (outfp);
4538af
+          gnupg_remove (fname);
4538af
+        }
4538af
+      else if (es_fclose (outfp))
4538af
+        {
4538af
+          err = gpg_error_from_syserror ();
4538af
+          log_error ("error closing '%s': %s\n", fname, gpg_strerror (err));
4538af
+        }
4538af
     }
4538af
 
4538af
   if (!err)
4538af
diff -up gnupg-2.2.20/tools/wks-util.c.coverity gnupg-2.2.20/tools/wks-util.c
4538af
--- gnupg-2.2.20/tools/wks-util.c.coverity	2020-05-04 12:02:21.839475031 +0200
4538af
+++ gnupg-2.2.20/tools/wks-util.c	2020-05-04 17:23:19.552726949 +0200
4538af
@@ -948,7 +948,7 @@ ensure_policy_file (const char *addrspec
4538af
 static gpg_error_t
4538af
 install_key_from_spec_file (const char *fname)
4538af
 {
4538af
-  gpg_error_t err;
4538af
+  gpg_error_t err = 0;
4538af
   estream_t fp;
4538af
   char *line = NULL;
4538af
   size_t linelen = 0;
4538af
@@ -1195,10 +1195,8 @@ wks_cmd_print_wkd_hash (const char *user
4538af
   char *addrspec, *fname;
4538af
 
4538af
   err = wks_fname_from_userid (userid, 1, &fname, &addrspec);
4538af
-  if (err)
4538af
-    return err;
4538af
-
4538af
-  es_printf ("%s %s\n", fname, addrspec);
4538af
+  if (!err)
4538af
+    es_printf ("%s %s\n", fname, addrspec);
4538af
 
4538af
   xfree (fname);
4538af
   xfree (addrspec);
4538af
@@ -1216,7 +1214,10 @@ wks_cmd_print_wkd_url (const char *useri
4538af
 
4538af
   err = wks_fname_from_userid (userid, 1, &fname, &addrspec);
4538af
   if (err)
4538af
-    return err;
4538af
+    {
4538af
+      xfree (addrspec);
4538af
+      return err;
4538af
+    }
4538af
 
4538af
   domain = strchr (addrspec, '@');
4538af
   if (domain)