[git] GnuPG - branch, master, updated. gnupg-2.1.21-103-gb231959

by Justus Winter cvs at cvs.gnupg.org
Tue Jul 18 13:57:04 CEST 2017


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "The GNU Privacy Guard".

The branch, master has been updated
       via  b231959728a0056094134e0fca8cc916c24ef37e (commit)
       via  ebb35ed7110d1a29061dfb4ccb9038645b20d7f4 (commit)
       via  3d670fa973a03ea88b5f9459b3222a951136dd7a (commit)
      from  a149afe338d61d86985c533cde5e7dbcd31e8698 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit b231959728a0056094134e0fca8cc916c24ef37e
Author: Justus Winter <justus at g10code.com>
Date:   Tue Jul 18 12:53:55 2017 +0200

    dirmngr: Honor http keyserver URLs.
    
    * dirmngr/http.c (parse_uri): Keep an unmodified copy of the URI.
    * dirmngr/http.h (struct parsed_uri_s): New field 'original'.
    * dirmngr/ks-action.c (ks_action_get): Properly handle http and https
    URLs.
    --
    
    If a key has a http or https URL as preferred keyserver, fetch the key
    from there.  Previously, dirmngr unconditionally interpreted these
    URLs as hkp servers.
    
    GnuPG-bug-id: 2924
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/dirmngr/http.c b/dirmngr/http.c
index 7c9a682..0cb2708 100644
--- a/dirmngr/http.c
+++ b/dirmngr/http.c
@@ -1219,10 +1219,12 @@ parse_uri (parsed_uri_t *ret_uri, const char *uri,
 {
   gpg_err_code_t ec;
 
-  *ret_uri = xtrycalloc (1, sizeof **ret_uri + strlen (uri));
+  *ret_uri = xtrycalloc (1, sizeof **ret_uri + 2 * strlen (uri) + 1);
   if (!*ret_uri)
     return gpg_err_make (default_errsource, gpg_err_code_from_syserror ());
   strcpy ((*ret_uri)->buffer, uri);
+  strcpy ((*ret_uri)->buffer + strlen (uri) + 1, uri);
+  (*ret_uri)->original = (*ret_uri)->buffer + strlen (uri) + 1;
   ec = do_parse_uri (*ret_uri, 0, no_scheme_check, force_tls);
   if (ec)
     {
diff --git a/dirmngr/http.h b/dirmngr/http.h
index 448cd04..9fa462c 100644
--- a/dirmngr/http.h
+++ b/dirmngr/http.h
@@ -47,6 +47,7 @@ typedef struct uri_tuple_s *uri_tuple_t;
 struct parsed_uri_s
 {
   /* All these pointers point into BUFFER; most stuff is not escaped. */
+  char *original;       /* Unmodified copy of the parsed URI.  */
   char *scheme;	        /* Pointer to the scheme string (always lowercase). */
   unsigned int is_http:1; /* This is a HTTP style URI.   */
   unsigned int use_tls:1; /* Whether TLS should be used. */
diff --git a/dirmngr/ks-action.c b/dirmngr/ks-action.c
index 1087bb5..857aab1 100644
--- a/dirmngr/ks-action.c
+++ b/dirmngr/ks-action.c
@@ -232,7 +232,10 @@ ks_action_get (ctrl_t ctrl, uri_item_t keyservers,
      Need to think about a better strategy.  */
   for (uri = keyservers; !err && uri; uri = uri->next)
     {
-      int is_http = uri->parsed_uri->is_http;
+      int is_hkp_s = (strcmp (uri->parsed_uri->scheme, "hkp") == 0
+                      || strcmp (uri->parsed_uri->scheme, "hkps") == 0);
+      int is_http_s = (strcmp (uri->parsed_uri->scheme, "http") == 0
+                       || strcmp (uri->parsed_uri->scheme, "https") == 0);
       int is_ldap = 0;
 
 #if USE_LDAP
@@ -241,7 +244,7 @@ ks_action_get (ctrl_t ctrl, uri_item_t keyservers,
 		 || strcmp (uri->parsed_uri->scheme, "ldapi") == 0);
 #endif
 
-      if (is_http || is_ldap)
+      if (is_hkp_s || is_http_s || is_ldap)
         {
           any_server = 1;
           for (sl = patterns; !err && sl; sl = sl->next)
@@ -251,9 +254,12 @@ ks_action_get (ctrl_t ctrl, uri_item_t keyservers,
 		err = ks_ldap_get (ctrl, uri->parsed_uri, sl->d, &infp);
 	      else
 #endif
-		{
-	          err = ks_hkp_get (ctrl, uri->parsed_uri, sl->d, &infp);
-	        }
+              if (is_hkp_s)
+                err = ks_hkp_get (ctrl, uri->parsed_uri, sl->d, &infp);
+              else if (is_http_s)
+                err = ks_http_fetch (ctrl, uri->parsed_uri->original, &infp);
+              else
+                BUG ();
 
               if (err)
                 {

commit ebb35ed7110d1a29061dfb4ccb9038645b20d7f4
Author: Justus Winter <justus at g10code.com>
Date:   Tue Jul 18 13:47:53 2017 +0200

    dirmngr: Fix memory leak.
    
    * dirmngr/http.c (parse_uri): Properly free partial results.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/dirmngr/http.c b/dirmngr/http.c
index 3baa53a..7c9a682 100644
--- a/dirmngr/http.c
+++ b/dirmngr/http.c
@@ -1226,7 +1226,7 @@ parse_uri (parsed_uri_t *ret_uri, const char *uri,
   ec = do_parse_uri (*ret_uri, 0, no_scheme_check, force_tls);
   if (ec)
     {
-      xfree (*ret_uri);
+      http_release_parsed_uri (*ret_uri);
       *ret_uri = NULL;
     }
   return gpg_err_make (default_errsource, ec);

commit 3d670fa973a03ea88b5f9459b3222a951136dd7a
Author: Justus Winter <justus at g10code.com>
Date:   Tue Jul 18 13:39:29 2017 +0200

    dirmngr: Fix memory leak.
    
    * dirmngr/http.c (http_release_parsed_uri): Free 'params'.
    
    Signed-off-by: Justus Winter <justus at g10code.com>

diff --git a/dirmngr/http.c b/dirmngr/http.c
index 0544c9b..3baa53a 100644
--- a/dirmngr/http.c
+++ b/dirmngr/http.c
@@ -1255,6 +1255,11 @@ http_release_parsed_uri (parsed_uri_t uri)
     {
       uri_tuple_t r, r2;
 
+      for (r = uri->params; r; r = r2)
+	{
+	  r2 = r->next;
+	  xfree (r);
+	}
       for (r = uri->query; r; r = r2)
 	{
 	  r2 = r->next;

-----------------------------------------------------------------------

Summary of changes:
 dirmngr/http.c      | 11 +++++++++--
 dirmngr/http.h      |  1 +
 dirmngr/ks-action.c | 16 +++++++++++-----
 3 files changed, 21 insertions(+), 7 deletions(-)


hooks/post-receive
-- 
The GNU Privacy Guard
http://git.gnupg.org




More information about the Gnupg-commits mailing list