aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Shaw <[email protected]>2006-04-11 03:13:46 +0000
committerDavid Shaw <[email protected]>2006-04-11 03:13:46 +0000
commitaf0a0ae6ee4f1097fa9010210ecfb436e9367f39 (patch)
tree6a40efaac99494705009edc22503b6fdf1d0d47f
parent* ksutil.h, ksutil.c (classify_ks_search): Add KS_SEARCH_KEYID_SHORT (diff)
downloadgnupg-af0a0ae6ee4f1097fa9010210ecfb436e9367f39.tar.gz
gnupg-af0a0ae6ee4f1097fa9010210ecfb436e9367f39.zip
* gpgkeys_ldap.c (get_name): Build strings with strcat rather than
using sprintf which is harder to read and modify.
Diffstat (limited to '')
-rw-r--r--keyserver/ChangeLog3
-rw-r--r--keyserver/gpgkeys_ldap.c27
2 files changed, 22 insertions, 8 deletions
diff --git a/keyserver/ChangeLog b/keyserver/ChangeLog
index 972a3255b..0b2b0ca79 100644
--- a/keyserver/ChangeLog
+++ b/keyserver/ChangeLog
@@ -1,5 +1,8 @@
2006-04-10 David Shaw <[email protected]>
+ * gpgkeys_ldap.c (get_name): Build strings with strcat rather than
+ using sprintf which is harder to read and modify.
+
* ksutil.h, ksutil.c (classify_ks_search): Add
KS_SEARCH_KEYID_SHORT and KS_SEARCH_KEYID_LONG to search for a key
ID.
diff --git a/keyserver/gpgkeys_ldap.c b/keyserver/gpgkeys_ldap.c
index 59984b113..02ea07882 100644
--- a/keyserver/gpgkeys_ldap.c
+++ b/keyserver/gpgkeys_ldap.c
@@ -1162,7 +1162,7 @@ get_name(char *getkey)
char *expanded_search;
/* The maximum size of the search, including the optional stuff and
the trailing \0 */
- char search[2+11+3+MAX_LINE+2+15+14+1+1+20];
+ char search[2+12+(MAX_LINE*3)+2+15+14+1+1+20];
/* This ordering is significant - specifically, "pgpcertid" needs to
be the second item in the list, since everything after it may be
discarded if the user isn't in verbose mode. */
@@ -1184,12 +1184,23 @@ get_name(char *getkey)
/* Build the search string */
- sprintf(search,"%s(pgpuserid=*%s*)%s%s%s",
- (!(opt->flags.include_disabled&&opt->flags.include_revoked))?"(&":"",
- expanded_search,
- opt->flags.include_disabled?"":"(pgpdisabled=0)",
- opt->flags.include_revoked?"":"(pgprevoked=0)",
- !(opt->flags.include_disabled&&opt->flags.include_revoked)?")":"");
+ search[0]='\0';
+
+ if(!opt->flags.include_disabled || !opt->flags.include_revoked)
+ strcat(search,"(&");
+
+ strcat(search,"(pgpUserID=*");
+ strcat(search,expanded_search);
+ strcat(search,"*)");
+
+ if(!opt->flags.include_disabled)
+ strcat(search,"(pgpDisabled=0)");
+
+ if(!opt->flags.include_revoked)
+ strcat(search,"(pgpRevoked=0)");
+
+ if(!opt->flags.include_disabled || !opt->flags.include_revoked)
+ strcat(search,")");
free(expanded_search);
@@ -1291,7 +1302,7 @@ search_key(const char *searchkey)
char *expanded_search;
/* The maximum size of the search, including the optional stuff and
the trailing \0 */
- char search[2+1+9+1+3+(MAX_LINE*3)+3+1+15+1+1];
+ char search[2+1+9+1+3+(MAX_LINE*3)+3+1+15+14+1+1+20];
char *attrs[]={"pgpcertid","pgpuserid","pgprevoked","pgpdisabled",
"pgpkeycreatetime","pgpkeyexpiretime","modifytimestamp",
"pgpkeysize","pgpkeytype",NULL};