diff options
author | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2013-07-03 08:29:26 +0200 |
---|---|---|
committer | Nikos Mavrogiannopoulos <nmav@gnutls.org> | 2013-07-19 09:21:50 +0200 |
commit | b91ba116261bffaedeee754486e6304543968b37 (patch) | |
tree | 5116b107695713de3ac1b87d39e491dc3eddf087 | |
parent | 92af59e90a50abcd140eae6df4da11be5707b612 (diff) | |
download | gnutls-b91ba116261bffaedeee754486e6304543968b37.tar.gz |
when removing a cipher priority, make sure the order is kept
-rw-r--r-- | lib/gnutls_priority.c | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/lib/gnutls_priority.c b/lib/gnutls_priority.c index fca4a59377..3795b79d38 100644 --- a/lib/gnutls_priority.c +++ b/lib/gnutls_priority.c @@ -558,21 +558,17 @@ typedef void (rmadd_func) (priority_st * priority_list, unsigned int alg); static void prio_remove (priority_st * priority_list, unsigned int algo) { - int i = 0; - int pos = -1; /* the position of the cipher to remove */ + unsigned int i; - while (priority_list->priority[i] != 0) + for (i=0;i<priority_list->algorithms;i++) { - if (priority_list->priority[i] == algo) - pos = i; - i++; - } - - if (pos >= 0) - { - priority_list->priority[pos] = priority_list->priority[i - 1]; - priority_list->priority[i - 1] = 0; - priority_list->algorithms--; + if (priority_list->priority[i] == algo) + { + priority_list->algorithms--; + if (priority_list->algorithms-i) > 0) + memmove(&priority_list->priority[i], &priority_list->priority[i+1], (priority_list->algorithms-i)*sizeof(priority_list->priority[0])); + break; + } } return; |