From: Nikos Mavrogiannopoulos Date: Wed, 3 Jul 2013 06:29:26 +0000 (+0200) Subject: when removing a cipher priority, make sure the order is kept X-Git-Tag: gnutls_3_2_2~35 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7b60341daebd8d9cd3c293358f695bb841f12714;p=thirdparty%2Fgnutls.git when removing a cipher priority, make sure the order is kept --- diff --git a/lib/gnutls_priority.c b/lib/gnutls_priority.c index e07afd3e1d..ed4565aa9f 100644 --- a/lib/gnutls_priority.c +++ b/lib/gnutls_priority.c @@ -556,21 +556,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;ialgorithms;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;