aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2007-01-16 04:31:49 +0000
committerDavid Shaw <[email protected]>2007-01-16 04:31:49 +0000
commita15b16a356094733505c6941dd8fc4b2e7800542 (patch)
tree4a0d15a6b811e85a12fc4cf4ab0433207818b125
parent * parse-packet.c (read_protected_v3_mpi): Make sure to stop (diff)
downloadgnupg-a15b16a356094733505c6941dd8fc4b2e7800542.tar.gz
gnupg-a15b16a356094733505c6941dd8fc4b2e7800542.zip
* gpgkeys_hkp.c (send_key): Allow GPG to send any armored key line
length without problems. Reported by Felix von Leitner.
-rw-r--r--keyserver/ChangeLog5
-rw-r--r--keyserver/gpgkeys_hkp.c44
2 files changed, 29 insertions, 20 deletions
diff --git a/keyserver/ChangeLog b/keyserver/ChangeLog
index b720aeeac..c84e8b0ce 100644
--- a/keyserver/ChangeLog
+++ b/keyserver/ChangeLog
@@ -1,3 +1,8 @@
+2007-01-15 David Shaw <[email protected]>
+
+ * 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 <[email protected]>
* ksutil.c (classify_ks_search): Try and recognize a key ID even
diff --git a/keyserver/gpgkeys_hkp.c b/keyserver/gpgkeys_hkp.c
index e393b856c..5e12a71dc 100644
--- a/keyserver/gpgkeys_hkp.c
+++ b/keyserver/gpgkeys_hkp.c
@@ -1,6 +1,6 @@
/* gpgkeys_hkp.c - talk to an HKP keyserver
- * Copyright (C) 2001, 2002, 2003, 2004, 2005
- * 2006 Free Software Foundation, Inc.
+ * Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006
+ * 2007 Free Software Foundation, Inc.
*
* This file is part of GnuPG.
*
@@ -101,7 +101,17 @@ send_key(int *eof)
char keyid[17],state[6];
char line[MAX_LINE];
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 */
@@ -133,25 +143,19 @@ send_key(int *eof)
}
else
{
- if(strlen(line)+keylen>keymax)
+ char *tempkey;
+ keysize+=strlen(line);
+ tempkey=realloc(key,keysize);
+ if(tempkey==NULL)
{
- char *tmp;
-
- keymax+=200;
- tmp=realloc(key,keymax+1);
- if(!tmp)
- {
- free(key);
- fprintf(console,"gpgkeys: out of memory\n");
- ret=KEYSERVER_NO_MEMORY;
- goto fail;
- }
-
- key=tmp;
+ fprintf(console,"gpgkeys: unable to reallocate for key\n");
+ ret=KEYSERVER_NO_MEMORY;
+ goto fail;
}
+ else
+ key=tempkey;
- strcpy(&key[keylen],line);
- keylen+=strlen(line);
+ strcat(key,line);
}
if(!end)
@@ -162,7 +166,7 @@ send_key(int *eof)
goto fail;
}
- encoded_key=curl_escape(key,keylen);
+ encoded_key=curl_escape(key,keysize);
if(!encoded_key)
{
fprintf(console,"gpgkeys: out of memory\n");