diff --git a/keyserver/ChangeLog b/keyserver/ChangeLog index a85b6181a..0953bd3a5 100644 --- a/keyserver/ChangeLog +++ b/keyserver/ChangeLog @@ -1,3 +1,12 @@ +2005-03-22 David Shaw + + * gpgkeys_ldap.c, ksutil.h, ksutil.c (print_nocr): Moved from + gpgkeys_ldap.c. Print a string, but strip out any CRs. + + * gpgkeys_finger.c (get_key), gpgkeys_hkp.c (get_key), + gpgkeys_http.c (get_key): Use it here when outputting key material + to canonicalize line endings. + 2005-03-19 David Shaw * gpgkeys_ldap.c (main): Fix three wrong calls to fail_all(). diff --git a/keyserver/gpgkeys_finger.c b/keyserver/gpgkeys_finger.c index dab88a727..a16bbe159 100644 --- a/keyserver/gpgkeys_finger.c +++ b/keyserver/gpgkeys_finger.c @@ -323,13 +323,13 @@ get_key (char *getkey) if(gotit) { - fputs (line, output); + print_nocr(output,line); if (!strncmp(line,END,strlen(END))) break; } else if(!strncmp(line,BEGIN,strlen(BEGIN))) { - fputs (line,output); + print_nocr(output,line); gotit=1; } } diff --git a/keyserver/gpgkeys_hkp.c b/keyserver/gpgkeys_hkp.c index 6cdefc6bc..ec715f5cd 100644 --- a/keyserver/gpgkeys_hkp.c +++ b/keyserver/gpgkeys_hkp.c @@ -267,14 +267,14 @@ get_key(char *getkey) if(gotit) { - fputs (line, output); + print_nocr(output,line); if(strncmp(line,END,strlen(END))==0) break; } else if(strncmp(line,BEGIN,strlen(BEGIN))==0) { - fputs (line,output); + print_nocr(output,line); gotit=1; } } diff --git a/keyserver/gpgkeys_http.c b/keyserver/gpgkeys_http.c index b6953347b..ef5d794c2 100644 --- a/keyserver/gpgkeys_http.c +++ b/keyserver/gpgkeys_http.c @@ -92,14 +92,14 @@ get_key(char *getkey) if(gotit) { - fputs(line,output); + print_nocr(output,line); if(strncmp(line,END,strlen(END))==0) break; } else if(strncmp(line,BEGIN,strlen(BEGIN))==0) { - fputs(line,output); + print_nocr(output,line); gotit=1; } } diff --git a/keyserver/gpgkeys_ldap.c b/keyserver/gpgkeys_ldap.c index f96555edd..fd99ae197 100644 --- a/keyserver/gpgkeys_ldap.c +++ b/keyserver/gpgkeys_ldap.c @@ -953,17 +953,6 @@ build_info(const char *certid,LDAPMessage *each) fprintf(output,"INFO %s END\n",certid); } -static void -print_nocr(FILE *stream,const char *str) -{ - while(*str) - { - if(*str!='\r') - fputc(*str,stream); - str++; - } -} - /* Note that key-not-found is not a fatal error */ static int get_key(char *getkey) diff --git a/keyserver/ksutil.c b/keyserver/ksutil.c index 0a5d779e1..78154c377 100644 --- a/keyserver/ksutil.c +++ b/keyserver/ksutil.c @@ -294,3 +294,21 @@ ks_action_to_string(enum ks_action action) return "?"; } + +/* Canonicalize CRLF to just LF by stripping CRs. This actually makes + sense, since on Unix-like machines LF is correct, and on win32-like + machines, our output buffer is opened in textmode and will + re-canonicalize line endings back to CRLF. Since we only need to + handle armored keys, we don't have to worry about odd cases like + CRCRCR and the like. */ + +void +print_nocr(FILE *stream,const char *str) +{ + while(*str) + { + if(*str!='\r') + fputc(*str,stream); + str++; + } +} diff --git a/keyserver/ksutil.h b/keyserver/ksutil.h index 400dc1789..120e15dc2 100644 --- a/keyserver/ksutil.h +++ b/keyserver/ksutil.h @@ -87,5 +87,6 @@ struct ks_options *init_ks_options(void); void free_ks_options(struct ks_options *opt); int parse_ks_options(char *line,struct ks_options *opt); const char *ks_action_to_string(enum ks_action action); +void print_nocr(FILE *stream,const char *str); #endif /* !_KSUTIL_H_ */