1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-23 10:29:58 +01:00

* gpgkeys_hkp.c (send_key): Allow GPG to send any armored key line

length without problems.  Reported by Felix von Leitner.
This commit is contained in:
David Shaw 2007-01-16 04:31:49 +00:00
parent 9e4a5071a6
commit a15b16a356
2 changed files with 29 additions and 20 deletions

View File

@ -1,3 +1,8 @@
2007-01-15 David Shaw <dshaw@jabberwocky.com>
* gpgkeys_hkp.c (send_key): Allow GPG to send any armored key line
length without problems. Reported by Felix von Leitner.
2006-12-03 David Shaw <dshaw@jabberwocky.com> 2006-12-03 David Shaw <dshaw@jabberwocky.com>
* ksutil.c (classify_ks_search): Try and recognize a key ID even * ksutil.c (classify_ks_search): Try and recognize a key ID even

View File

@ -1,6 +1,6 @@
/* gpgkeys_hkp.c - talk to an HKP keyserver /* gpgkeys_hkp.c - talk to an HKP keyserver
* Copyright (C) 2001, 2002, 2003, 2004, 2005 * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
* 2006 Free Software Foundation, Inc. * 2007 Free Software Foundation, Inc.
* *
* This file is part of GnuPG. * This file is part of GnuPG.
* *
@ -101,7 +101,17 @@ send_key(int *eof)
char keyid[17],state[6]; char keyid[17],state[6];
char line[MAX_LINE]; char line[MAX_LINE];
char *key=NULL,*encoded_key=NULL; char *key=NULL,*encoded_key=NULL;
size_t keylen=0,keymax=0; size_t keysize=1;
key=malloc(1);
if(!key)
{
fprintf(console,"gpgkeys: unable to allocate memory for key\n");
ret=KEYSERVER_NO_MEMORY;
goto fail;
}
key[0]='\0';
/* Read and throw away input until we see the BEGIN */ /* Read and throw away input until we see the BEGIN */
@ -133,25 +143,19 @@ send_key(int *eof)
} }
else else
{ {
if(strlen(line)+keylen>keymax) char *tempkey;
keysize+=strlen(line);
tempkey=realloc(key,keysize);
if(tempkey==NULL)
{ {
char *tmp; fprintf(console,"gpgkeys: unable to reallocate for key\n");
keymax+=200;
tmp=realloc(key,keymax+1);
if(!tmp)
{
free(key);
fprintf(console,"gpgkeys: out of memory\n");
ret=KEYSERVER_NO_MEMORY; ret=KEYSERVER_NO_MEMORY;
goto fail; goto fail;
} }
else
key=tempkey;
key=tmp; strcat(key,line);
}
strcpy(&key[keylen],line);
keylen+=strlen(line);
} }
if(!end) if(!end)
@ -162,7 +166,7 @@ send_key(int *eof)
goto fail; goto fail;
} }
encoded_key=curl_escape(key,keylen); encoded_key=curl_escape(key,keysize);
if(!encoded_key) if(!encoded_key)
{ {
fprintf(console,"gpgkeys: out of memory\n"); fprintf(console,"gpgkeys: out of memory\n");