[svn] GnuPG - r4402 - branches/STABLE-BRANCH-1-4/keyserver
svn author dshaw
cvs at cvs.gnupg.org
Tue Jan 16 05:31:49 CET 2007
Author: dshaw
Date: 2007-01-16 05:31:49 +0100 (Tue, 16 Jan 2007)
New Revision: 4402
Modified:
branches/STABLE-BRANCH-1-4/keyserver/ChangeLog
branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_hkp.c
Log:
* gpgkeys_hkp.c (send_key): Allow GPG to send any armored key line
length without problems. Reported by Felix von Leitner.
Modified: branches/STABLE-BRANCH-1-4/keyserver/ChangeLog
===================================================================
--- branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2007-01-15 19:31:24 UTC (rev 4401)
+++ branches/STABLE-BRANCH-1-4/keyserver/ChangeLog 2007-01-16 04:31:49 UTC (rev 4402)
@@ -1,3 +1,8 @@
+2007-01-15 David Shaw <dshaw at 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 at jabberwocky.com>
* ksutil.c (classify_ks_search): Try and recognize a key ID even
Modified: branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_hkp.c
===================================================================
--- branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_hkp.c 2007-01-15 19:31:24 UTC (rev 4401)
+++ branches/STABLE-BRANCH-1-4/keyserver/gpgkeys_hkp.c 2007-01-16 04:31:49 UTC (rev 4402)
@@ -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,8 +101,18 @@
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 */
while(fgets(line,MAX_LINE,input)!=NULL)
@@ -133,25 +143,19 @@
}
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 @@
goto fail;
}
- encoded_key=curl_escape(key,keylen);
+ encoded_key=curl_escape(key,keysize);
if(!encoded_key)
{
fprintf(console,"gpgkeys: out of memory\n");
More information about the Gnupg-commits
mailing list