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

cvs user dshaw cvs at cvs.gnupg.org
Sun Jun 5 00:48:04 CEST 2005


    Date: Sunday, June 5, 2005 @ 01:09:27
  Author: dshaw
    Path: /cvs/gnupg/gnupg/keyserver

Modified: ChangeLog gpgkeys_hkp.c gpgkeys_oldhkp.c

* gpgkeys_hkp.c, gpgkeys_oldhkp.c: Add support for HKP servers that
aren't at the root path.  Suggested by Jack Bates.


------------------+
 ChangeLog        |    5 +++++
 gpgkeys_hkp.c    |   24 ++++++++++++++++--------
 gpgkeys_oldhkp.c |   28 +++++++++++++++++++---------
 3 files changed, 40 insertions(+), 17 deletions(-)


Index: gnupg/keyserver/ChangeLog
diff -u gnupg/keyserver/ChangeLog:1.129 gnupg/keyserver/ChangeLog:1.130
--- gnupg/keyserver/ChangeLog:1.129	Wed Jun  1 21:08:56 2005
+++ gnupg/keyserver/ChangeLog	Sun Jun  5 01:09:27 2005
@@ -1,3 +1,8 @@
+2005-06-04  David Shaw  <dshaw at jabberwocky.com>
+
+	* gpgkeys_hkp.c, gpgkeys_oldhkp.c: Add support for HKP servers
+	that aren't at the root path.  Suggested by Jack Bates.
+
 2005-06-01  David Shaw  <dshaw at jabberwocky.com>
 
 	* ksutil.c [HAVE_DOSISH_SYSTEM]: Fix warnings on mingw32.  Noted
Index: gnupg/keyserver/gpgkeys_hkp.c
diff -u gnupg/keyserver/gpgkeys_hkp.c:1.53 gnupg/keyserver/gpgkeys_hkp.c:1.54
--- gnupg/keyserver/gpgkeys_hkp.c:1.53	Tue May 31 10:39:15 2005
+++ gnupg/keyserver/gpgkeys_hkp.c	Sun Jun  5 01:09:27 2005
@@ -73,7 +73,7 @@
 send_key(int *eof)
 {
   CURLcode res;
-  char request[MAX_URL];
+  char request[MAX_URL+15];
   int begin=0,end=0,ret=KEYSERVER_INTERNAL_ERROR;
   char keyid[17];
   char line[MAX_LINE];
@@ -162,6 +162,10 @@
     strcat(request,opt->port);
   else
     strcat(request,"11371");
+  if(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");
 
   if(opt->verbose>2)
@@ -197,7 +201,7 @@
 get_key(char *getkey)
 {
   CURLcode res;
-  char request[MAX_URL+100];
+  char request[MAX_URL+60];
   char *offset;
   struct curl_writer_ctx ctx;
 
@@ -218,9 +222,6 @@
       return KEYSERVER_NOT_SUPPORTED;
     }
 
-  /* Note that the size of request is MAX_URL which already implies a
-     1024 byte PATH.  MAX_URL+100 is absurdly safe. */
-
   strcpy(request,"http://");
   strcat(request,opt->host);
   strcat(request,":");
@@ -228,6 +229,11 @@
     strcat(request,opt->port);
   else
     strcat(request,"11371");
+  if(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");
 
   /* fingerprint or long key id.  Take the last 8 characters and treat
@@ -278,9 +284,7 @@
 
   searchkey_encoded=curl_escape(searchkey,0);
 
-  /* Note that MAX_URL already implies a 1024 byte PATH, so this is
-     safe. */
-  request=malloc(MAX_URL+strlen(searchkey_encoded));
+  request=malloc(MAX_URL+50+strlen(searchkey_encoded));
   if(!request)
     {
       fprintf(console,"gpgkeys: out of memory\n");
@@ -297,6 +301,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,searchkey_encoded);
 
@@ -593,6 +599,8 @@
       fprintf(console,"Host:\t\t%s\n",opt->host);
       if(opt->port)
 	fprintf(console,"Port:\t\t%s\n",opt->port);
+      if(opt->path)
+	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.3 gnupg/keyserver/gpgkeys_oldhkp.c:1.4
--- gnupg/keyserver/gpgkeys_oldhkp.c:1.3	Tue May 31 10:39:15 2005
+++ gnupg/keyserver/gpgkeys_oldhkp.c	Sun Jun  5 01:09:27 2005
@@ -47,7 +47,8 @@
 
 static int verbose=0,include_revoked=0,include_disabled=0;
 static unsigned int http_flags=0;
-static char host[MAX_HOST+1]={'\0'},proxy[MAX_PROXY+1]={'\0'},port[MAX_PORT+1]={'\0'};
+static char host[MAX_HOST+1]={'\0'},proxy[MAX_PROXY+1]={'\0'},
+  port[MAX_PORT+1]={'\0'},path[URLMAX_PATH+1];
 static FILE *input=NULL,*output=NULL,*console=NULL;
 
 int
@@ -89,7 +90,7 @@
 
   memset(&hd,0,sizeof(hd));
 
-  request=malloc(strlen(host)+100);
+  request=malloc(strlen(host)+strlen(port)+strlen(path)+100);
   if(!request)
     {
       fprintf(console,"gpgkeys: out of memory\n");
@@ -141,7 +142,8 @@
 
   iobuf_flush_temp(temp);
 
-  sprintf(request,"hkp://%s%s%s/pks/add",host,port[0]?":":"",port[0]?port:"");
+  sprintf(request,"hkp://%s%s%s%s/pks/add",
+	  host,port[0]?":":"",port[0]?port:"",path);
 
   if(verbose>2)
     fprintf(console,"gpgkeys: HTTP URL is `%s'\n",request);
@@ -237,15 +239,15 @@
 
   fprintf(output,"KEY 0x%s BEGIN\n",getkey);
 
-  request=malloc(strlen(host)+100);
+  request=malloc(strlen(host)+strlen(port)+strlen(path)+100);
   if(!request)
     {
       fprintf(console,"gpgkeys: out of memory\n");
       return KEYSERVER_NO_MEMORY;
     }
 
-  sprintf(request,"hkp://%s%s%s/pks/lookup?op=get&options=mr&search=%s",
-	  host,port[0]?":":"",port[0]?port:"", search);
+  sprintf(request,"hkp://%s%s%s%s/pks/lookup?op=get&options=mr&search=%s",
+	  host,port[0]?":":"",port[0]?port:"",path,search);
 
   if(verbose>2)
     fprintf(console,"gpgkeys: HTTP URL is `%s'\n",request);
@@ -659,7 +661,7 @@
 
   search[len]='\0';
 
-  request=malloc(strlen(host)+100+strlen(search));
+  request=malloc(strlen(host)+strlen(port)+strlen(path)+100+strlen(search));
   if(!request)
     {
       fprintf(console,"gpgkeys: out of memory\n");
@@ -667,8 +669,8 @@
       goto fail;
     }
 
-  sprintf(request,"hkp://%s%s%s/pks/lookup?op=index&options=mr&search=%s",
-	  host,port[0]?":":"",port[0]?port:"",search);
+  sprintf(request,"hkp://%s%s%s%s/pks/lookup?op=index&options=mr&search=%s",
+	  host,port[0]?":":"",port[0]?port:"",path,search);
 
   if(verbose>2)
     fprintf(console,"gpgkeys: HTTP URL is `%s'\n",request);
@@ -856,6 +858,12 @@
 	  continue;
 	}
 
+      if(sscanf(line,"PATH %" MKSTRING(URLMAX_PATH) "s\n",path)==1)
+	{
+	  path[URLMAX_PATH]='\0';
+	  continue;
+	}
+
       if(sscanf(line,"VERSION %d\n",&version)==1)
 	{
 	  if(version!=KEYSERVER_PROTO_VERSION)
@@ -1020,6 +1028,8 @@
       fprintf(console,"Host:\t\t%s\n",host);
       if(port[0])
 	fprintf(console,"Port:\t\t%s\n",port);
+      if(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