aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2021-02-17 14:27:30 +0000
committerWerner Koch <[email protected]>2021-02-17 15:15:59 +0000
commitcdc828f6902667196eb3870f9287045afe7144d5 (patch)
tree95726626a0a1cab5f88662265f346eb725f2d0d6
parentcommon: Fix compiler warning (diff)
downloadgnupg-cdc828f6902667196eb3870f9287045afe7144d5.tar.gz
gnupg-cdc828f6902667196eb3870f9287045afe7144d5.zip
dirmngr: Rewrite a weird function by straighter code.
* dirmngr/ldap-parse-uri.c (ldap_uri_p): Use ascii-memcasecmp. -- Note that the first test on ldaps or ldaps in the original code did not worked at all so that the Mixed Case part took over there. Signed-off-by: Werner Koch <[email protected]>
-rw-r--r--dirmngr/ldap-parse-uri.c20
1 files changed, 5 insertions, 15 deletions
diff --git a/dirmngr/ldap-parse-uri.c b/dirmngr/ldap-parse-uri.c
index 4d9272cc0..86f6ce032 100644
--- a/dirmngr/ldap-parse-uri.c
+++ b/dirmngr/ldap-parse-uri.c
@@ -36,26 +36,16 @@ int
ldap_uri_p (const char *url)
{
char *colon = strchr (url, ':');
- if (! colon)
+
+ if (!colon)
return 0;
else
{
int offset = (uintptr_t) colon - (uintptr_t) url;
- if (/* All lower case. */
- (offset == 4 && memcmp (url, "ldap", 4) == 0)
- || (offset == 5
- && (memcmp (url, "ldaps", 5) == 0
- && memcmp (url, "ldapi", 5) == 0))
- /* Mixed case. */
- || ((url[0] == 'l' || url[0] == 'L')
- && (url[1] == 'd' || url[1] == 'D')
- && (url[2] == 'a' || url[2] == 'A')
- && (url[3] == 'p' || url[3] == 'P')
- && (url[4] == ':'
- || ((url[4] == 's' || url[4] == 'S'
- || url[4] == 'i' || url[4] == 'I')
- && url[5] == ':'))))
+ if ( (offset == 4 && !ascii_memcasecmp (url, "ldap", 4))
+ || (offset == 5 && (!ascii_memcasecmp (url, "ldaps", 5)
+ || !ascii_memcasecmp (url, "ldapi", 5))))
return 1;
return 0;
}