From 6c701af121782c2feb4ee51e559a7420df00471f Mon Sep 17 00:00:00 2001 From: Werner Koch Date: Wed, 25 Mar 2015 19:33:59 +0100 Subject: 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 --- dirmngr/ldap-parse-uri.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'dirmngr/ldap-parse-uri.c') 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; -- cgit v1.2.3