mirror of
git://git.gnupg.org/gnupg.git
synced 2025-04-13 22:21:09 +02:00
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 <wk@gnupg.org>
This commit is contained in:
parent
3c7b1f3f5f
commit
cdc828f690
@ -36,26 +36,16 @@ int
|
|||||||
ldap_uri_p (const char *url)
|
ldap_uri_p (const char *url)
|
||||||
{
|
{
|
||||||
char *colon = strchr (url, ':');
|
char *colon = strchr (url, ':');
|
||||||
if (! colon)
|
|
||||||
|
if (!colon)
|
||||||
return 0;
|
return 0;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int offset = (uintptr_t) colon - (uintptr_t) url;
|
int offset = (uintptr_t) colon - (uintptr_t) url;
|
||||||
|
|
||||||
if (/* All lower case. */
|
if ( (offset == 4 && !ascii_memcasecmp (url, "ldap", 4))
|
||||||
(offset == 4 && memcmp (url, "ldap", 4) == 0)
|
|| (offset == 5 && (!ascii_memcasecmp (url, "ldaps", 5)
|
||||||
|| (offset == 5
|
|| !ascii_memcasecmp (url, "ldapi", 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] == ':'))))
|
|
||||||
return 1;
|
return 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user