From f76dc1d602d3bfe8f7c1a59ce42e5d6f7b96798f Mon Sep 17 00:00:00 2001 From: David Shaw Date: Thu, 19 Sep 2002 16:51:59 +0000 Subject: [PATCH] * gpgkeys_hkp.c (get_key, search_key): Properly handle line truncation. --- keyserver/ChangeLog | 5 +++++ keyserver/gpgkeys_hkp.c | 16 +++++++++++----- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/keyserver/ChangeLog b/keyserver/ChangeLog index ece289a58..646df8c9a 100644 --- a/keyserver/ChangeLog +++ b/keyserver/ChangeLog @@ -1,3 +1,8 @@ +2002-09-19 David Shaw + + * gpgkeys_hkp.c (get_key, search_key): Properly handle line + truncation. + 2002-09-16 David Shaw * gpgkeys_mailto.in: Add quasi-RFC-2368 mailto:email@addr?from= diff --git a/keyserver/gpgkeys_hkp.c b/keyserver/gpgkeys_hkp.c index c316bb1ea..3194d1cc8 100644 --- a/keyserver/gpgkeys_hkp.c +++ b/keyserver/gpgkeys_hkp.c @@ -185,11 +185,9 @@ int send_key(void) int get_key(char *getkey) { int rc,gotit=0; - unsigned int maxlen=1024,buflen=0; char search[29]; char *request; struct http_context hd; - byte *line=NULL; /* Build the search string. HKP only uses the short key IDs. */ @@ -249,8 +247,13 @@ int get_key(char *getkey) } else { + unsigned int maxlen=1024,buflen; + byte *line=NULL; + while(iobuf_read_line(hd.fp_read,&line,&buflen,&maxlen)) { + maxlen=1024; + if(gotit) { fprintf(output,line); @@ -272,9 +275,10 @@ int get_key(char *getkey) fprintf(console,"gpgkeys: key %s not found on keyserver\n",getkey); fprintf(output,"KEY 0x%s FAILED\n",getkey); } + + m_free(line); } - m_free(line); free(request); return 0; @@ -529,7 +533,6 @@ int search_key(char *searchkey) int max=0,len=0,ret=-1,rc; struct http_context hd; char *search=NULL,*request=searchkey; - byte *line=NULL; fprintf(output,"SEARCH %s BEGIN\n",searchkey); @@ -587,9 +590,10 @@ int search_key(char *searchkey) } else { - unsigned int maxlen=1024,buflen=0; + unsigned int buflen; int count=1; IOBUF buffer; + byte *line=NULL; buffer=iobuf_temp(); @@ -597,6 +601,8 @@ int search_key(char *searchkey) while(rc!=0) { + unsigned int maxlen=1024; + /* This is a judgement call. Is it better to slurp up all the results before prompting the user? On the one hand, it probably makes the keyserver happier to not be blocked