From 19ca27005331c7a91aa7c035f28984463af71c84 Mon Sep 17 00:00:00 2001 From: schwarze <> Date: Sun, 1 Apr 2018 00:36:28 +0000 Subject: When you replace an element in a sorted array with something arbitrarily different, the array is in general no longer sorted. This commit copies a small hidden bugfix from the OpenSSL commit https://github.com/openssl/openssl/commit/fbb7b33b the rest of which is merely cosmetics. I discovered the bug independently while documenting sk_find(3). Keep the library's idea of when an empty stack or a one-element stack is sorted and when it is not bug-compatible with OpenSSL, even though in fact, empty and one-element stacks are of course always sorted. OK beck@ --- src/lib/libcrypto/stack/stack.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/lib/libcrypto/stack/stack.c') diff --git a/src/lib/libcrypto/stack/stack.c b/src/lib/libcrypto/stack/stack.c index d941f9e6fb..b76a0d7271 100644 --- a/src/lib/libcrypto/stack/stack.c +++ b/src/lib/libcrypto/stack/stack.c @@ -1,4 +1,4 @@ -/* $OpenBSD: stack.c,v 1.19 2015/02/07 13:19:15 doug Exp $ */ +/* $OpenBSD: stack.c,v 1.20 2018/04/01 00:36:28 schwarze Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -312,6 +312,7 @@ sk_set(_STACK *st, int i, void *value) { if (!st || (i < 0) || (i >= st->num)) return NULL; + st->sorted = 0; return (st->data[i] = value); } -- cgit v1.2.3-55-g6feb