gnupg/keyserver (ChangeLog gpgkeys_hkp.c gpgkeys_oldhkp.c)

cvs user dshaw cvs at cvs.gnupg.org
Tue Jun 21 06:01:06 CEST 2005


    Date: Tuesday, June 21, 2005 @ 06:24:10
  Author: dshaw
    Path: /cvs/gnupg/gnupg/keyserver

Modified: ChangeLog gpgkeys_hkp.c gpgkeys_oldhkp.c

* gpgkeys_hkp.c (append_path, send_key, get_key, search_key, main),
gpgkeys_oldhkp.c (main): Properly handle double slashes in paths.


------------------+
 ChangeLog        |    6 ++++++
 gpgkeys_hkp.c    |   29 +++++++++++++++++++----------
 gpgkeys_oldhkp.c |    8 +++++++-
 3 files changed, 32 insertions(+), 11 deletions(-)


Index: gnupg/keyserver/ChangeLog
diff -u gnupg/keyserver/ChangeLog:1.131 gnupg/keyserver/ChangeLog:1.132
--- gnupg/keyserver/ChangeLog:1.131	Sun Jun  5 16:34:47 2005
+++ gnupg/keyserver/ChangeLog	Tue Jun 21 06:24:10 2005
@@ -1,3 +1,9 @@
+2005-06-20  David Shaw  <dshaw at jabberwocky.com>
+
+	* gpgkeys_hkp.c (append_path, send_key, get_key, search_key,
+	main), gpgkeys_oldhkp.c (main): Properly handle double slashes in
+	paths.
+
 2005-06-05  David Shaw  <dshaw at jabberwocky.com>
 
 	* ksutil.c (init_ks_options, parse_ks_options): Provide a default
Index: gnupg/keyserver/gpgkeys_hkp.c
diff -u gnupg/keyserver/gpgkeys_hkp.c:1.54 gnupg/keyserver/gpgkeys_hkp.c:1.55
--- gnupg/keyserver/gpgkeys_hkp.c:1.54	Sun Jun  5 01:09:27 2005
+++ gnupg/keyserver/gpgkeys_hkp.c	Tue Jun 21 06:24:10 2005
@@ -69,6 +69,18 @@
     return 0;
 }
 
+/* Append but avoid creating a double slash // in the path. */
+static char *
+append_path(char *dest,const char *src)
+{
+  size_t n=strlen(dest);
+
+  if(src[0]=='/' && n>0 && dest[n-1]=='/')
+    dest[n-1]='\0';
+
+  return strcat(dest,src);
+}
+
 int
 send_key(int *eof)
 {
@@ -162,11 +174,10 @@
     strcat(request,opt->port);
   else
     strcat(request,"11371");
-  if(opt->path)
-    strcat(request,opt->path);
+  strcat(request,opt->path);
   /* request is MAX_URL+15 bytes long - MAX_URL covers the whole URL,
      including any supplied path.  The 15 covers /pks/add. */
-  strcat(request,"/pks/add");
+  append_path(request,"/pks/add");
 
   if(opt->verbose>2)
     fprintf(console,"gpgkeys: HTTP URL is `%s'\n",request);
@@ -229,12 +240,11 @@
     strcat(request,opt->port);
   else
     strcat(request,"11371");
-  if(opt->path)
-    strcat(request,opt->path);
+  strcat(request,opt->path);
   /* request is MAX_URL+55 bytes long - MAX_URL covers the whole URL,
      including any supplied path.  The 60 overcovers this /pks/... etc
      string plus the 8 bytes of key id */
-  strcat(request,"/pks/lookup?op=get&options=mr&search=0x");
+  append_path(request,"/pks/lookup?op=get&options=mr&search=0x");
 
   /* fingerprint or long key id.  Take the last 8 characters and treat
      it like a short key id */
@@ -301,9 +311,8 @@
     strcat(request,opt->port);
   else
     strcat(request,"11371");
-  if(opt->path)
-    strcat(request,opt->path);
-  strcat(request,"/pks/lookup?op=index&options=mr&search=");
+  strcat(request,opt->path);
+  append_path(request,"/pks/lookup?op=index&options=mr&search=");
   strcat(request,searchkey_encoded);
 
   if(opt->verbose>2)
@@ -599,7 +608,7 @@
       fprintf(console,"Host:\t\t%s\n",opt->host);
       if(opt->port)
 	fprintf(console,"Port:\t\t%s\n",opt->port);
-      if(opt->path)
+      if(strcmp(opt->path,"/")!=0)
 	fprintf(console,"Path:\t\t%s\n",opt->path);
       fprintf(console,"Command:\t%s\n",ks_action_to_string(opt->action));
     }
Index: gnupg/keyserver/gpgkeys_oldhkp.c
diff -u gnupg/keyserver/gpgkeys_oldhkp.c:1.4 gnupg/keyserver/gpgkeys_oldhkp.c:1.5
--- gnupg/keyserver/gpgkeys_oldhkp.c:1.4	Sun Jun  5 01:09:27 2005
+++ gnupg/keyserver/gpgkeys_oldhkp.c	Tue Jun 21 06:24:10 2005
@@ -761,6 +761,7 @@
   int failed=0;
   struct keylist *keylist=NULL,*keyptr=NULL;
   unsigned int timeout=DEFAULT_KEYSERVER_TIMEOUT;
+  size_t n;
 
   console=stderr;
 
@@ -956,6 +957,11 @@
 	}
     }
 
+  /* Avoid the double slash // in a path */
+  n=strlen(path);
+  if(n>0 && path[n-1]=='/')
+    path[n-1]='\0';
+
   if(timeout && register_timeout()==-1)
     {
       fprintf(console,"gpgkeys: unable to register timeout handler\n");
@@ -1028,7 +1034,7 @@
       fprintf(console,"Host:\t\t%s\n",host);
       if(port[0])
 	fprintf(console,"Port:\t\t%s\n",port);
-      if(path[0])
+      if(strcmp(path,"/")!=0)
 	fprintf(console,"Path:\t\t%s\n",path);
       fprintf(console,"Command:\t%s\n",action==GET?"GET":
 	      action==SEND?"SEND":"SEARCH");




More information about the Gnupg-commits mailing list