summaryrefslogtreecommitdiff
path: root/p11-kit/uri.c
diff options
context:
space:
mode:
authorDaiki Ueno <dueno@redhat.com>2018-05-24 11:12:21 +0200
committerDaiki Ueno <ueno@gnu.org>2018-05-25 12:50:54 +0200
commit258da75cd606a3653bc414a6ace01c8bfdfabca6 (patch)
tree25f83668a6f19f9208d0b8893e0e689f3d5f4975 /p11-kit/uri.c
parent117b35db99af4331daad4279eadfb9280e0c1325 (diff)
uri: Make scheme comparison case-insensitive
RFC 3986 suggests that implementations should accept uppercase letters as equivalent to lowercase in scheme names.
Diffstat (limited to 'p11-kit/uri.c')
-rw-r--r--p11-kit/uri.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/p11-kit/uri.c b/p11-kit/uri.c
index 9743a45..450a11e 100644
--- a/p11-kit/uri.c
+++ b/p11-kit/uri.c
@@ -1628,7 +1628,7 @@ p11_kit_uri_parse (const char *string, P11KitUriType uri_type,
{
const char *spos, *epos;
int ret;
- size_t length;
+ size_t length, i;
char *allocated = NULL;
assert (string);
@@ -1648,8 +1648,14 @@ p11_kit_uri_parse (const char *string, P11KitUriType uri_type,
free (allocated);
return P11_KIT_URI_BAD_SCHEME;
}
- ret = strncmp (string, P11_KIT_URI_SCHEME, strlen (P11_KIT_URI_SCHEME));
- if (ret != 0) {
+ if (epos - string != P11_KIT_URI_SCHEME_LEN) {
+ free (allocated);
+ return P11_KIT_URI_BAD_SCHEME;
+ }
+ for (i = 0; i < P11_KIT_URI_SCHEME_LEN; i++)
+ if (p11_ascii_tolower (string[i]) != P11_KIT_URI_SCHEME[i])
+ break;
+ if (i != P11_KIT_URI_SCHEME_LEN) {
free (allocated);
return P11_KIT_URI_BAD_SCHEME;
}