diff options
author | Daiki Ueno <dueno@redhat.com> | 2017-01-23 10:02:56 +0100 |
---|---|---|
committer | Daiki Ueno <ueno@gnu.org> | 2017-02-02 11:25:33 +0100 |
commit | 77913af71be81208b4e9af68cd10bc55669543e1 (patch) | |
tree | 96316dd911c9d90b6770737f30257daed034b93d | |
parent | cfa9fefb2b4c4d8c1d38284817c61dcf5d3f4716 (diff) |
uri: Relax pin-* parsing for compatibility
While 'pin-source' and 'pin-value' are defined as query atttribute, they
were defined as path attribute in earlier drafts, and some
implementations still stick to it.
For backward compatibility, accept those in path attributes when
parsing (but not when formatting).
Reported by Andreas Metzler in:
https://lists.freedesktop.org/archives/p11-glue/2017-January/000637.html
-rw-r--r-- | p11-kit/uri.c | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/p11-kit/uri.c b/p11-kit/uri.c index 7641677..5a3e19e 100644 --- a/p11-kit/uri.c +++ b/p11-kit/uri.c @@ -1390,9 +1390,9 @@ parse_module_info (const char *name_start, const char *name_end, } static int -parse_extra_info (const char *name_start, const char *name_end, - const char *start, const char *end, - P11KitUri *uri) +parse_pin_query (const char *name_start, const char *name_end, + const char *start, const char *end, + P11KitUri *uri) { unsigned char *value; @@ -1414,7 +1414,22 @@ parse_extra_info (const char *name_start, const char *name_end, free (uri->pin_value); uri->pin_value = (char*)value; return 1; - } else if (str_range_equal ("module-name", name_start, name_end)) { + } + + return 0; +} + +static int +parse_module_query (const char *name_start, const char *name_end, + const char *start, const char *end, + P11KitUri *uri) +{ + unsigned char *value; + + assert (name_start <= name_end); + assert (start <= end); + + if (str_range_equal ("module-name", name_start, name_end)) { value = p11_url_decode (start, end, P11_URL_WHITESPACE, NULL); if (value == NULL) return P11_KIT_URI_BAD_ENCODING; @@ -1536,6 +1551,10 @@ p11_kit_uri_parse (const char *string, P11KitUriType uri_type, ret = parse_module_info (string, epos, epos + 1, spos, uri); if (ret == 0 && (uri_type & P11_KIT_URI_FOR_MODULE_WITH_VERSION) == P11_KIT_URI_FOR_MODULE_WITH_VERSION) ret = parse_module_version_info (string, epos, epos + 1, spos, uri); + /* Accept 'pin-source' and 'pin-value' in path + * attributes for backward compatibility. */ + if (ret == 0) + ret = parse_pin_query (string, epos, epos + 1, spos, uri); if (ret < 0) { free (allocated); @@ -1571,7 +1590,9 @@ p11_kit_uri_parse (const char *string, P11KitUriType uri_type, return P11_KIT_URI_BAD_SYNTAX; } - ret = parse_extra_info (string, epos, epos + 1, spos, uri); + ret = parse_pin_query (string, epos, epos + 1, spos, uri); + if (ret == 0) + ret = parse_module_query (string, epos, epos + 1, spos, uri); if (ret < 0) { free (allocated); return ret; |