diff options
author | David Shaw <[email protected]> | 2002-06-12 18:56:36 +0000 |
---|---|---|
committer | David Shaw <[email protected]> | 2002-06-12 18:56:36 +0000 |
commit | 8ce53a679a79a0962efc9588166e742382f3cc20 (patch) | |
tree | bbae14f5db4ea19627e1f65aa832f1ee2f934d4a | |
parent | * configure.ac: Move -lsocket and -lnsl checks before LDAP link tests so (diff) | |
download | gnupg-8ce53a679a79a0962efc9588166e742382f3cc20.tar.gz gnupg-8ce53a679a79a0962efc9588166e742382f3cc20.zip |
* keyserver.c (keyserver_spawn): Handle CRLF endings from keyserver
helpers. Also don't leak the last line worth of memory from the keyserver
response.
* main.h, misc.c (deprecated_warning): New function to warn about
deprecated options and commands.
* g10.c (main), keyserver-internal.h, keyserver.c (parse_keyserver_uri):
Use new deprecated function to warn about honor-http-proxy,
auto-key-retrieve, and x-broken-hkp.
-rw-r--r-- | g10/ChangeLog | 13 | ||||
-rw-r--r-- | g10/g10.c | 23 | ||||
-rw-r--r-- | g10/keyserver-internal.h | 3 | ||||
-rw-r--r-- | g10/keyserver.c | 47 | ||||
-rw-r--r-- | g10/main.h | 2 | ||||
-rw-r--r-- | g10/misc.c | 21 |
6 files changed, 77 insertions, 32 deletions
diff --git a/g10/ChangeLog b/g10/ChangeLog index b5e928682..890b01900 100644 --- a/g10/ChangeLog +++ b/g10/ChangeLog @@ -1,3 +1,16 @@ +2002-06-12 David Shaw <[email protected]> + + * keyserver.c (keyserver_spawn): Handle CRLF endings from + keyserver helpers. Also don't leak the last line worth of memory + from the keyserver response. + + * main.h, misc.c (deprecated_warning): New function to warn about + deprecated options and commands. + + * g10.c (main), keyserver-internal.h, keyserver.c + (parse_keyserver_uri): Use new deprecated function to warn about + honor-http-proxy, auto-key-retrieve, and x-broken-hkp. + 2002-06-11 David Shaw <[email protected]> * Makefile.am: link gpg with NETLIBS for the built-in HKP access. @@ -1328,7 +1328,7 @@ main( int argc, char **argv ) #endif /* __riscos__ */ break; case oKeyServer: - if(parse_keyserver_uri(pargs.r.ret_str)) + if(parse_keyserver_uri(pargs.r.ret_str,configname,configlineno)) log_error(_("could not parse keyserver URI\n")); break; case oKeyServerOptions: @@ -1372,10 +1372,10 @@ main( int argc, char **argv ) case oSetFilesize: opt.set_filesize = pargs.r.ret_ulong; break; case oHonorHttpProxy: opt.keyserver_options.honor_http_proxy = 1; - log_info(_("WARNING: %s is a deprecated option.\n"), - "--honor-http-proxy"); - log_info(_("please use \"--keyserver-options %s\" instead\n"), - "honor-http-proxy"); + deprecated_warning(configname,configlineno, + "--honor-http-proxy", + "--keyserver-options ", + "honor-http-proxy"); break; case oFastListMode: opt.fast_list_mode = 1; break; case oFixedListMode: opt.fixed_list_mode = 1; break; @@ -1388,13 +1388,12 @@ main( int argc, char **argv ) case oNoAutoKeyRetrieve: opt.keyserver_options.auto_key_retrieve= (pargs.r_opt==oAutoKeyRetrieve); - log_info(_("WARNING: %s is a deprecated option.\n"), - pargs.r_opt==oAutoKeyRetrieve? - "--auto-key-retrieve":"--no-auto-key-retrieve"); - log_info(_("please use \"--keyserver-options %s\" instead\n"), - pargs.r_opt==oAutoKeyRetrieve? - "auto-key-retrieve":"no-auto-key-retrieve"); - break; + deprecated_warning(configname,configlineno, + pargs.r_opt==oAutoKeyRetrieve?"--auto-key-retrieve": + "--no-auto-key-retrieve","--keyserver-options ", + pargs.r_opt==oAutoKeyRetrieve?"auto-key-retrieve": + "no-auto-key-retrieve"); + break; case oShowSessionKey: opt.show_session_key = 1; break; case oOverrideSessionKey: opt.override_session_key = pargs.r.ret_str; diff --git a/g10/keyserver-internal.h b/g10/keyserver-internal.h index 9165491b4..9f0d2e8c0 100644 --- a/g10/keyserver-internal.h +++ b/g10/keyserver-internal.h @@ -9,7 +9,8 @@ #include "types.h" void parse_keyserver_options(char *options); -int parse_keyserver_uri(char *uri); +int parse_keyserver_uri(char *uri, + const char *configname,unsigned int configlineno); int keyserver_export(STRLIST users); int keyserver_import(STRLIST users); int keyserver_import_fprint(const byte *fprint,size_t fprint_len); diff --git a/g10/keyserver.c b/g10/keyserver.c index d84e14644..833ec05c1 100644 --- a/g10/keyserver.c +++ b/g10/keyserver.c @@ -117,7 +117,7 @@ parse_keyserver_options(char *options) } int -parse_keyserver_uri(char *uri) +parse_keyserver_uri(char *uri,const char *configname,unsigned int configlineno) { /* Get the scheme */ @@ -130,10 +130,8 @@ parse_keyserver_uri(char *uri) if(ascii_strcasecmp(opt.keyserver_scheme,"x-broken-hkp")==0) { - log_info(_("WARNING: %s is a deprecated option.\n"), - "x-broken-hkp"); - log_info(_("please use \"--keyserver-options %s\" instead\n"), - "broken-http-proxy"); + deprecated_warning(configname,configlineno,"x-broken-hkp", + "--keyserver-options ","broken-http-proxy"); opt.keyserver_scheme="hkp"; opt.keyserver_options.broken_http_proxy=1; } @@ -491,39 +489,50 @@ keyserver_spawn(int action,STRLIST list, /* Now handle the response */ - do + for(;;) { + char *ptr; + if(iobuf_read_line(spawn->fromchild,&line,&buflen,&maxlen)==0) { ret=G10ERR_READ_FILE; goto fail; /* i.e. EOF */ } - if(ascii_memcasecmp(line,"VERSION ",8)==0) + ptr=line; + + if(*ptr=='\r') + ptr++; + + if(*ptr=='\n') + ptr++; + + if(*ptr=='\0') + break; + + if(ascii_memcasecmp(ptr,"VERSION ",8)==0) { gotversion=1; - if(atoi(&line[8])!=KEYSERVER_PROTO_VERSION) + if(atoi(&ptr[8])!=KEYSERVER_PROTO_VERSION) { log_error(_("invalid keyserver protocol (us %d!=handler %d)\n"), - KEYSERVER_PROTO_VERSION,atoi(&line[8])); + KEYSERVER_PROTO_VERSION,atoi(&ptr[8])); goto fail; } } - - if(ascii_memcasecmp(line,"PROGRAM ",8)==0) + else if(ascii_memcasecmp(ptr,"PROGRAM ",8)==0) { - line[strlen(line)-1]='\0'; - if(ascii_strcasecmp(&line[8],VERSION)!=0) + ptr[strlen(ptr)-1]='\0'; + if(ascii_strcasecmp(&ptr[8],VERSION)!=0) log_info(_("Warning: keyserver handler from a different " - "version of GnuPG (%s)\n"),&line[8]); + "version of GnuPG (%s)\n"),&ptr[8]); } - - /* Currently the only OPTION */ - if(ascii_memcasecmp(line,"OPTION OUTOFBAND",16)==0) - outofband=1; + else if(ascii_memcasecmp(ptr,"OPTION OUTOFBAND",16)==0) + outofband=1; /* Currently the only OPTION */ } - while(line[0]!='\n'); + + m_free(line); if(!gotversion) { diff --git a/g10/main.h b/g10/main.h index aad27b8fd..6946362f4 100644 --- a/g10/main.h +++ b/g10/main.h @@ -83,6 +83,8 @@ struct expando_args char *pct_expando(const char *string,struct expando_args *args); int hextobyte( const char *s ); +void deprecated_warning(const char *configname,unsigned int configlineno, + const char *option,const char *repl1,const char *repl2); /*-- helptext.c --*/ void display_online_help( const char *keyword ); diff --git a/g10/misc.c b/g10/misc.c index f97db523e..8e541905d 100644 --- a/g10/misc.c +++ b/g10/misc.c @@ -637,3 +637,24 @@ hextobyte( const char *s ) return -1; return c; } + +void +deprecated_warning(const char *configname,unsigned int configlineno, + const char *option,const char *repl1,const char *repl2) +{ + if(configname) + { + if(strncmp("--",option,2)==0) + option+=2; + + if(strncmp("--",repl1,2)==0) + repl1+=2; + + log_info(_("%s:%d: deprecated option \"%s\"\n"), + configname,configlineno,option); + } + else + log_info(_("WARNING: \"%s\" is a deprecated option\n"),option); + + log_info(_("please use \"%s%s\" instead\n"),repl1,repl2); +} |