1
0
mirror of git://git.gnupg.org/gnupg.git synced 2025-02-22 19:58:29 +01:00

* gpgkeys_hkp.c (send_key), gpgkeys_ldap.c (send_key): Properly handle an

input file that does not include any key data at all.
This commit is contained in:
David Shaw 2002-11-04 13:49:31 +00:00
parent 23d943d015
commit 66c458f954
3 changed files with 21 additions and 16 deletions

View File

@ -1,3 +1,8 @@
2002-11-04 David Shaw <dshaw@jabberwocky.com>
* gpgkeys_hkp.c (send_key), gpgkeys_ldap.c (send_key): Properly
handle an input file that does not include any key data at all.
2002-10-28 Stefan Bellon <sbellon@sbellon.de> 2002-10-28 Stefan Bellon <sbellon@sbellon.de>
* gpgkeys_hkp.c: Tidied up RISC OS initializations. * gpgkeys_hkp.c: Tidied up RISC OS initializations.

View File

@ -79,7 +79,7 @@ urlencode_filter( void *opaque, int control,
/* Returns 0 on success, -1 on failure, and 1 on eof */ /* Returns 0 on success, -1 on failure, and 1 on eof */
int send_key(void) int send_key(void)
{ {
int rc,gotit=0,ret=-1; int rc,begin=0,end=0,ret=-1;
char keyid[17]; char keyid[17];
char *request; char *request;
struct http_context hd; struct http_context hd;
@ -87,6 +87,8 @@ int send_key(void)
IOBUF temp = iobuf_temp(); IOBUF temp = iobuf_temp();
char line[MAX_LINE]; char line[MAX_LINE];
memset(&hd,0,sizeof(hd));
request=malloc(strlen(host)+100); request=malloc(strlen(host)+100);
if(!request) if(!request)
{ {
@ -101,25 +103,23 @@ int send_key(void)
while(fgets(line,MAX_LINE,input)!=NULL) while(fgets(line,MAX_LINE,input)!=NULL)
if(sscanf(line,"KEY %16s BEGIN\n",keyid)==1) if(sscanf(line,"KEY %16s BEGIN\n",keyid)==1)
{ {
gotit=1; begin=1;
break; break;
} }
if(!gotit) if(!begin)
{ {
/* i.e. eof before the KEY BEGIN was found */ /* i.e. eof before the KEY BEGIN was found */
ret=1; ret=1;
goto fail; goto fail;
} }
gotit=0;
/* Now slurp up everything until we see the END */ /* Now slurp up everything until we see the END */
while(fgets(line,MAX_LINE,input)) while(fgets(line,MAX_LINE,input))
if(sscanf(line,"KEY %16s END\n",keyid)==1) if(sscanf(line,"KEY %16s END\n",keyid)==1)
{ {
gotit=1; end=1;
break; break;
} }
else else
@ -129,7 +129,7 @@ int send_key(void)
goto fail; goto fail;
} }
if(!gotit) if(!end)
{ {
fprintf(console,"gpgkeys: no KEY %s END found\n",keyid); fprintf(console,"gpgkeys: no KEY %s END found\n",keyid);
goto fail; goto fail;
@ -172,7 +172,6 @@ int send_key(void)
if((status/100)!=2) if((status/100)!=2)
{ {
fprintf(console,"gpgkeys: remote server returned error %d\n",status); fprintf(console,"gpgkeys: remote server returned error %d\n",status);
fprintf(output,"KEY %s FAILED\n",keyid);
goto fail; goto fail;
} }
@ -183,6 +182,9 @@ int send_key(void)
iobuf_close(temp); iobuf_close(temp);
http_close(&hd); http_close(&hd);
if(ret!=0 && begin)
fprintf(output,"KEY %s FAILED\n",keyid);
return ret; return ret;
} }

View File

@ -61,7 +61,7 @@ RISCOS_GLOBAL_STATICS("LDAP Keyfetcher Heap")
/* Returns 0 on success, -1 on failure, and 1 on eof */ /* Returns 0 on success, -1 on failure, and 1 on eof */
int send_key(void) int send_key(void)
{ {
int err,gotit=0,keysize=1,ret=-1; int err,begin=0,end=0,keysize=1,ret=-1;
char *dn=NULL; char *dn=NULL;
char line[MAX_LINE]; char line[MAX_LINE];
char *key[2]={0,0}; char *key[2]={0,0};
@ -99,25 +99,23 @@ int send_key(void)
while(fgets(line,MAX_LINE,input)!=NULL) while(fgets(line,MAX_LINE,input)!=NULL)
if(sscanf(line,"KEY %16s BEGIN\n",keyid)==1) if(sscanf(line,"KEY %16s BEGIN\n",keyid)==1)
{ {
gotit=1; begin=1;
break; break;
} }
if(!gotit) if(!begin)
{ {
/* i.e. eof before the KEY BEGIN was found */ /* i.e. eof before the KEY BEGIN was found */
ret=1; ret=1;
goto fail; goto fail;
} }
gotit=0;
/* Now slurp up everything until we see the END */ /* Now slurp up everything until we see the END */
while(fgets(line,MAX_LINE,input)!=NULL) while(fgets(line,MAX_LINE,input)!=NULL)
if(sscanf(line,"KEY %16s END\n",keyid)==1) if(sscanf(line,"KEY %16s END\n",keyid)==1)
{ {
gotit=1; end=1;
break; break;
} }
else else
@ -133,7 +131,7 @@ int send_key(void)
strcat(key[0],line); strcat(key[0],line);
} }
if(!gotit) if(!end)
{ {
fprintf(console,"gpgkeys: no KEY %s END found\n",keyid); fprintf(console,"gpgkeys: no KEY %s END found\n",keyid);
goto fail; goto fail;
@ -154,7 +152,7 @@ int send_key(void)
free(key[0]); free(key[0]);
free(dn); free(dn);
if(ret!=0) if(ret!=0 && begin)
fprintf(output,"KEY %s FAILED\n",keyid); fprintf(output,"KEY %s FAILED\n",keyid);
return ret; return ret;