mirror of
git://git.gnupg.org/gnupg.git
synced 2025-02-21 19:48:05 +01:00
* gpgkeys_ldap.c (search_key, main): Fix bug where searching for foo
bar (no quotes) on the command line resulted in searching for "foo\2Abar" due to LDAP quoting. The proper search is "foo*bar".
This commit is contained in:
parent
73f9238d93
commit
8898e869a2
@ -1,3 +1,9 @@
|
|||||||
|
2007-07-27 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
|
* gpgkeys_ldap.c (search_key, main): Fix bug where searching for
|
||||||
|
foo bar (no quotes) on the command line resulted in searching for
|
||||||
|
"foo\2Abar" due to LDAP quoting. The proper search is "foo*bar".
|
||||||
|
|
||||||
2007-04-16 David Shaw <dshaw@jabberwocky.com>
|
2007-04-16 David Shaw <dshaw@jabberwocky.com>
|
||||||
|
|
||||||
* gpgkeys_hkp.c (main): Show curl or fake-curl version string.
|
* gpgkeys_hkp.c (main): Show curl or fake-curl version string.
|
||||||
|
@ -1291,18 +1291,25 @@ printquoted(FILE *stream,char *string,char delim)
|
|||||||
static int
|
static int
|
||||||
search_key(const char *searchkey)
|
search_key(const char *searchkey)
|
||||||
{
|
{
|
||||||
char **vals;
|
char **vals,*search;
|
||||||
LDAPMessage *res,*each;
|
LDAPMessage *res,*each;
|
||||||
int err,count=0;
|
int err,count=0;
|
||||||
struct keylist *dupelist=NULL;
|
struct keylist *dupelist=NULL;
|
||||||
/* The maximum size of the search, including the optional stuff and
|
/* The maximum size of the search, including the optional stuff and
|
||||||
the trailing \0 */
|
the trailing \0 */
|
||||||
char search[2+1+9+1+3+(MAX_LINE*3)+3+1+15+14+1+1+20];
|
|
||||||
char *attrs[]={"pgpcertid","pgpuserid","pgprevoked","pgpdisabled",
|
char *attrs[]={"pgpcertid","pgpuserid","pgprevoked","pgpdisabled",
|
||||||
"pgpkeycreatetime","pgpkeyexpiretime","modifytimestamp",
|
"pgpkeycreatetime","pgpkeyexpiretime","modifytimestamp",
|
||||||
"pgpkeysize","pgpkeytype",NULL};
|
"pgpkeysize","pgpkeytype",NULL};
|
||||||
enum ks_search_type search_type;
|
enum ks_search_type search_type;
|
||||||
|
|
||||||
|
search=malloc(2+1+9+1+3+strlen(searchkey)+3+1+15+14+1+1+20);
|
||||||
|
if(!search)
|
||||||
|
{
|
||||||
|
fprintf(console,"gpgkeys: out of memory when building search list\n");
|
||||||
|
fprintf(output,"SEARCH %s FAILED %d\n",searchkey,KEYSERVER_NO_MEMORY);
|
||||||
|
return KEYSERVER_NO_MEMORY;
|
||||||
|
}
|
||||||
|
|
||||||
fprintf(output,"SEARCH %s BEGIN\n",searchkey);
|
fprintf(output,"SEARCH %s BEGIN\n",searchkey);
|
||||||
|
|
||||||
search_type=classify_ks_search(&searchkey);
|
search_type=classify_ks_search(&searchkey);
|
||||||
@ -1357,7 +1364,7 @@ search_key(const char *searchkey)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ldap_quote(search,searchkey);
|
strcat(search,searchkey);
|
||||||
|
|
||||||
switch(search_type)
|
switch(search_type)
|
||||||
{
|
{
|
||||||
@ -1395,6 +1402,7 @@ search_key(const char *searchkey)
|
|||||||
|
|
||||||
err=ldap_search_s(ldap,basekeyspacedn,
|
err=ldap_search_s(ldap,basekeyspacedn,
|
||||||
LDAP_SCOPE_SUBTREE,search,attrs,0,&res);
|
LDAP_SCOPE_SUBTREE,search,attrs,0,&res);
|
||||||
|
free(search);
|
||||||
if(err!=LDAP_SUCCESS && err!=LDAP_SIZELIMIT_EXCEEDED)
|
if(err!=LDAP_SUCCESS && err!=LDAP_SIZELIMIT_EXCEEDED)
|
||||||
{
|
{
|
||||||
int errtag=ldap_err_to_gpg_err(err);
|
int errtag=ldap_err_to_gpg_err(err);
|
||||||
@ -2311,7 +2319,7 @@ main(int argc,char *argv[])
|
|||||||
keyptr=keyptr->next;
|
keyptr=keyptr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
searchkey=malloc(len+1);
|
searchkey=malloc((len*3)+1);
|
||||||
if(searchkey==NULL)
|
if(searchkey==NULL)
|
||||||
{
|
{
|
||||||
ret=KEYSERVER_NO_MEMORY;
|
ret=KEYSERVER_NO_MEMORY;
|
||||||
@ -2324,7 +2332,7 @@ main(int argc,char *argv[])
|
|||||||
keyptr=keylist;
|
keyptr=keylist;
|
||||||
while(keyptr!=NULL)
|
while(keyptr!=NULL)
|
||||||
{
|
{
|
||||||
strcat(searchkey,keyptr->str);
|
ldap_quote(searchkey,keyptr->str);
|
||||||
strcat(searchkey,"*");
|
strcat(searchkey,"*");
|
||||||
keyptr=keyptr->next;
|
keyptr=keyptr->next;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user