1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

* 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.
This commit is contained in:
David Shaw 2006-07-14 16:07:01 +00:00
parent 5476afe1b4
commit 2dc880aa9e
3 changed files with 27 additions and 11 deletions

View file

@ -86,7 +86,7 @@ send_key(int *eof)
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 @@ send_key(int *eof)
/* 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 @@ send_key(int *eof)
/* 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 @@ send_key(int *eof)
{
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);