From f8bf0c9998ca7f33c6afa6e457b89c480ae75b64 Mon Sep 17 00:00:00 2001 From: Tim Kosse Date: Thu, 15 Nov 2012 19:57:01 +0100 Subject: [PATCH] Don't read past the last list entry in _add_priority, doing so adds algorithms that shouldn't be added and can even lead to a segfault. Signed-off-by: Nikos Mavrogiannopoulos --- lib/gnutls_priority.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/gnutls_priority.c b/lib/gnutls_priority.c index b6649ca67..03ef83bf3 100644 --- a/lib/gnutls_priority.c +++ b/lib/gnutls_priority.c @@ -89,11 +89,11 @@ _set_priority (priority_st * st, const int *list) inline static void _add_priority (priority_st * st, const int *list) { - int num = 0, i, j, init; + int num, i, j, init; init = i = st->algorithms; - while (list[num] != 0) + for (num=0;list[num]!=0;++num) { if (i+1 > MAX_ALGOS) { @@ -104,14 +104,15 @@ _add_priority (priority_st * st, const int *list) { if (st->priority[j] == (unsigned)list[num]) { - num++; - continue; + break; } } - st->priority[i++] = list[num]; - st->algorithms++; - num++; + if (j == init) + { + st->priority[i++] = list[num]; + st->algorithms++; + } } return; -- 2.11.4.GIT