diff options
author | Nikos Mavrogiannopoulos <nmav@redhat.com> | 2018-07-16 14:04:01 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2018-07-19 05:55:14 +0200 |
commit | 96c9c1fc4af3cc3196f26e2a02110f0829a2ce61 (patch) | |
tree | 5ce8f433b570a2c69c10e3851177cb8e077dac5e /lib/priority.c | |
parent | 3a580d35a07ed35c4c69173db486049a16949895 (diff) | |
download | gnutls-96c9c1fc4af3cc3196f26e2a02110f0829a2ce61.tar.gz |
gnutls_priority_init: fix err_pos on invalid strings
When the provided string would be resolved (e.g., due to a @ priority
being used), to a different string, then do not attempt to
detect the right location of the error. It will not be useful to the caller.
This addresses the issue of test suite failure when --with-system-priority-file
and --with-default-priority-string are provided. It also enhances the test suite
with these options being active.
Resolves #517
Signed-off-by: Nikos Mavrogiannopoulos <nmav@redhat.com>
Diffstat (limited to 'lib/priority.c')
-rw-r--r-- | lib/priority.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/lib/priority.c b/lib/priority.c index 1b954cfb96..0a6b41ca50 100644 --- a/lib/priority.c +++ b/lib/priority.c @@ -40,6 +40,7 @@ /* This function is used by the test suite */ char *_gnutls_resolve_priorities(const char* priorities); +const char *_gnutls_default_priority_string = DEFAULT_PRIORITY_STRING; static void prio_remove(priority_st * priority_list, unsigned int algo); static void prio_add(priority_st * priority_list, unsigned int algo); @@ -1510,7 +1511,7 @@ gnutls_priority_init2(gnutls_priority_t * priority_cache, _gnutls_buffer_init(&buf); - ret = _gnutls_buffer_append_str(&buf, DEFAULT_PRIORITY_STRING); + ret = _gnutls_buffer_append_str(&buf, _gnutls_default_priority_string); if (ret < 0) { _gnutls_buffer_clear(&buf); return gnutls_assert_val(ret); @@ -1531,7 +1532,7 @@ gnutls_priority_init2(gnutls_priority_t * priority_cache, ret = gnutls_priority_init(priority_cache, (const char*)buf.data, &ep); if (ret < 0 && ep != (const char*)buf.data && ep != NULL) { ptrdiff_t diff = (ptrdiff_t)ep-(ptrdiff_t)buf.data; - unsigned hlen = strlen(DEFAULT_PRIORITY_STRING)+1; + unsigned hlen = strlen(_gnutls_default_priority_string)+1; if (err_pos && diff > hlen) { *err_pos = priorities + diff - hlen; @@ -1578,6 +1579,7 @@ gnutls_priority_init(gnutls_priority_t * priority_cache, bulk_rmadd_func *bulk_fn; bulk_rmadd_func *bulk_given_fn; const cipher_entry_st *centry; + unsigned resolved_match = 1; if (err_pos) *err_pos = priorities; @@ -1596,8 +1598,10 @@ gnutls_priority_init(gnutls_priority_t * priority_cache, (*priority_cache)->min_record_version = 1; gnutls_atomic_init(&(*priority_cache)->usage_cnt); - if (priorities == NULL) - priorities = DEFAULT_PRIORITY_STRING; + if (priorities == NULL) { + priorities = _gnutls_default_priority_string; + resolved_match = 0; + } darg = _gnutls_resolve_priorities(priorities); if (darg == NULL) { @@ -1605,6 +1609,9 @@ gnutls_priority_init(gnutls_priority_t * priority_cache, goto error; } + if (strcmp(darg, priorities) != 0) + resolved_match = 0; + break_list(darg, broken_list, &broken_list_size); /* This is our default set of protocol version, certificate types. */ @@ -1805,7 +1812,7 @@ gnutls_priority_init(gnutls_priority_t * priority_cache, return 0; error: - if (err_pos != NULL && i < broken_list_size) { + if (err_pos != NULL && i < broken_list_size && resolved_match) { *err_pos = priorities; for (j = 0; j < i; j++) { (*err_pos) += strlen(broken_list[j]) + 1; |