summaryrefslogtreecommitdiffstats
path: root/dirmngr/ldap-parse-uri.c
diff options
context:
space:
mode:
authorWerner Koch <wk@gnupg.org>2015-03-25 19:33:59 +0100
committerWerner Koch <wk@gnupg.org>2015-03-25 19:33:59 +0100
commit6c701af121782c2feb4ee51e559a7420df00471f (patch)
treef79e65da4b951b07ab54ce4dcc9964a2f3421111 /dirmngr/ldap-parse-uri.c
parentcommon: Add macro GNUPG_GCC_A_USED. (diff)
downloadgnupg2-6c701af121782c2feb4ee51e559a7420df00471f.tar.xz
gnupg2-6c701af121782c2feb4ee51e559a7420df00471f.zip
dirmngr: Minor cleanups.
* dirmngr/ks-engine-ldap.c [__riscos__]: Remove doubled util.h. (ldap_to_gpg_err): s/GPG_ERR_GENERAL/GPG_ERR_INTERNAL/. (tm2ldaptime): Use snprintf. (ldap_connect): Get error code prior to log_error and and use modern function. Use xfree, xtrustrdup etc. (modlist_lookup): Use GNUPG_GCC_A_USED. (modlist_free): Use xfree. -- sprintf has been replaced by snprintf to avoid warnings on some platforms. xfree et al. is required so that replacement functions are used if defined. For example the Libgcrypt functions which may not be fully compatible with standard free. Impossible conditions should use GPG_ERR_INTERNAL. Signed-off-by: Werner Koch <wk@gnupg.org>
Diffstat (limited to 'dirmngr/ldap-parse-uri.c')
-rw-r--r--dirmngr/ldap-parse-uri.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/dirmngr/ldap-parse-uri.c b/dirmngr/ldap-parse-uri.c
index 2a341adf1..9a6d6199a 100644
--- a/dirmngr/ldap-parse-uri.c
+++ b/dirmngr/ldap-parse-uri.c
@@ -127,7 +127,7 @@ ldap_parse_uri (parsed_uri_t *purip, const char *uri)
len = 0;
-#define add(s) { if (s) len += strlen (s) + 1; }
+#define add(s) do { if (s) len += strlen (s) + 1; } while (0)
add (scheme);
add (host);
@@ -166,6 +166,11 @@ ldap_parse_uri (parsed_uri_t *purip, const char *uri)
if (password)
{
puri->query = calloc (sizeof (*puri->query), 1);
+ if (!puri->query)
+ {
+ err = gpg_err_code_from_syserror ();
+ goto out;
+ }
puri->query->name = "password";
copy (puri->query->value, password);
puri->query->valuelen = strlen (password) + 1;
@@ -221,7 +226,8 @@ ldap_escape_filter (const char *filter)
case ')':
case '\\':
case '/':
- sprintf (&escaped[escaped_i], "%%%02x", filter[filter_i]);
+ snprintf (&escaped[escaped_i], 4, "%%%02x",
+ ((const unsigned char *)filter)[filter_i]);
escaped_i += 3;
break;