[svn] GnuPG - r4194 - trunk/keyserver

svn author dshaw cvs at cvs.gnupg.org
Fri Jul 14 18:07:02 CEST 2006


Author: dshaw
Date: 2006-07-14 18:07:01 +0200 (Fri, 14 Jul 2006)
New Revision: 4194

Modified:
   trunk/keyserver/ChangeLog
   trunk/keyserver/gpgkeys_hkp.c
   trunk/keyserver/gpgkeys_ldap.c
Log:
* gpgkeys_hkp.c (send_key), gpgkeys_ldap.c (send_key, send_key_keyserver):
Fix string matching problem when the ascii armored form of the key happens
to match "KEY" at the beginning of the line.


Modified: trunk/keyserver/ChangeLog
===================================================================
--- trunk/keyserver/ChangeLog	2006-07-12 21:16:57 UTC (rev 4193)
+++ trunk/keyserver/ChangeLog	2006-07-14 16:07:01 UTC (rev 4194)
@@ -1,3 +1,10 @@
+2006-07-14  David Shaw  <dshaw at jabberwocky.com>
+
+	* gpgkeys_hkp.c (send_key), gpgkeys_ldap.c (send_key,
+	send_key_keyserver): Fix string matching problem when the ascii
+	armored form of the key happens to match "KEY" at the beginning of
+	the line.
+
 2006-07-12  David Shaw  <dshaw at jabberwocky.com>
 
 	* gpgkeys_ldap.c (printquoted), curl-shim.c (curl_escape): Fix bad

Modified: trunk/keyserver/gpgkeys_hkp.c
===================================================================
--- trunk/keyserver/gpgkeys_hkp.c	2006-07-12 21:16:57 UTC (rev 4193)
+++ trunk/keyserver/gpgkeys_hkp.c	2006-07-14 16:07:01 UTC (rev 4194)
@@ -86,7 +86,7 @@
   CURLcode res;
   char request[MAX_URL+15];
   int begin=0,end=0,ret=KEYSERVER_INTERNAL_ERROR;
-  char keyid[17];
+  char keyid[17],state[6];
   char line[MAX_LINE];
   char *key=NULL,*encoded_key=NULL;
   size_t keylen=0,keymax=0;
@@ -94,7 +94,8 @@
   /* Read and throw away input until we see the BEGIN */
 
   while(fgets(line,MAX_LINE,input)!=NULL)
-    if(sscanf(line,"KEY %16s BEGIN\n",keyid)==1)
+    if(sscanf(line,"KEY %16s %5s\n",keyid,state)==2
+       && strcmp(state,"BEGIN")==0)
       {
 	begin=1;
 	break;
@@ -112,7 +113,8 @@
   /* Now slurp up everything until we see the END */
 
   while(fgets(line,MAX_LINE,input))
-    if(sscanf(line,"KEY %16s END\n",keyid)==1)
+    if(sscanf(line,"KEY %16s %3s\n",keyid,state)==2
+       && strcmp(state,"END")==0)
       {
 	end=1;
 	break;
@@ -194,6 +196,7 @@
     {
       fprintf(console,"gpgkeys: HTTP post error %d: %s\n",res,errorbuffer);
       ret=curl_err_to_gpg_err(res);
+      goto fail;
     }
   else
     fprintf(output,"\nKEY %s SENT\n",keyid);

Modified: trunk/keyserver/gpgkeys_ldap.c
===================================================================
--- trunk/keyserver/gpgkeys_ldap.c	2006-07-12 21:16:57 UTC (rev 4193)
+++ trunk/keyserver/gpgkeys_ldap.c	2006-07-14 16:07:01 UTC (rev 4194)
@@ -567,7 +567,7 @@
 {
   int err,begin=0,end=0,keysize=1,ret=KEYSERVER_INTERNAL_ERROR;
   char *dn=NULL,line[MAX_LINE],*key=NULL;
-  char keyid[17];
+  char keyid[17],state[6];
   LDAPMod **modlist,**addlist,**ml;
 
   modlist=malloc(sizeof(LDAPMod *));
@@ -608,7 +608,8 @@
   /* Assemble the INFO stuff into LDAP attributes */
 
   while(fgets(line,MAX_LINE,input)!=NULL)
-    if(sscanf(line,"INFO %16s BEGIN\n",keyid)==1)
+    if(sscanf(line,"INFO %16s %5s\n",keyid,state)==2
+       && strcmp(state,"BEGIN")==0)
       {
 	begin=1;
 	break;
@@ -653,7 +654,8 @@
   /* Now parse each line until we see the END */
 
   while(fgets(line,MAX_LINE,input)!=NULL)
-    if(sscanf(line,"INFO %16s END\n",keyid)==1)
+    if(sscanf(line,"INFO %16s %3s\n",keyid,state)==2
+       && strcmp(state,"END")==0)
       {
 	end=1;
 	break;
@@ -674,7 +676,8 @@
   /* Read and throw away stdin until we see the BEGIN */
 
   while(fgets(line,MAX_LINE,input)!=NULL)
-    if(sscanf(line,"KEY %16s BEGIN\n",keyid)==1)
+    if(sscanf(line,"KEY %16s %5s\n",keyid,state)==2
+       && strcmp(state,"BEGIN")==0)
       {
 	begin=1;
 	break;
@@ -692,7 +695,8 @@
   /* Now slurp up everything until we see the END */
 
   while(fgets(line,MAX_LINE,input)!=NULL)
-    if(sscanf(line,"KEY %16s END\n",keyid)==1)
+    if(sscanf(line,"KEY %16s %3s\n",keyid,state)==2
+       && strcmp(state,"END")==0)
       {
 	end=1;
 	break;
@@ -778,7 +782,7 @@
 {
   int err,begin=0,end=0,keysize=1,ret=KEYSERVER_INTERNAL_ERROR;
   char *dn=NULL,line[MAX_LINE],*key[2]={NULL,NULL};
-  char keyid[17];
+  char keyid[17],state[6];
   LDAPMod mod, *attrs[2];
 
   memset(&mod,0,sizeof(mod));
@@ -812,7 +816,8 @@
   /* Read and throw away stdin until we see the BEGIN */
 
   while(fgets(line,MAX_LINE,input)!=NULL)
-    if(sscanf(line,"KEY %16s BEGIN\n",keyid)==1)
+    if(sscanf(line,"KEY %16s %5s\n",keyid,state)==2
+       && strcmp(state,"BEGIN")==0)
       {
 	begin=1;
 	break;
@@ -830,7 +835,8 @@
   /* Now slurp up everything until we see the END */
 
   while(fgets(line,MAX_LINE,input)!=NULL)
-    if(sscanf(line,"KEY %16s END\n",keyid)==1)
+    if(sscanf(line,"KEY %16s %3s\n",keyid,state)==2
+       && strcmp(state,"END")==0)
       {
 	end=1;
 	break;




More information about the Gnupg-commits mailing list