diff options
author | 2018-04-01 00:36:28 +0000 | |
---|---|---|
committer | 2018-04-01 00:36:28 +0000 | |
commit | 10b27f3e64d08ebf55127b2cb72a2043b3a3e590 (patch) | |
tree | 56f48485dedcffcc9d7ea60df141124a6bec6c81 /lib | |
parent | Change ci_dev.dv_xname to ci_dev->dv_xname in debugging printf() (diff) | |
download | wireguard-openbsd-10b27f3e64d08ebf55127b2cb72a2043b3a3e590.tar.xz wireguard-openbsd-10b27f3e64d08ebf55127b2cb72a2043b3a3e590.zip |
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@
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libcrypto/man/OPENSSL_sk_new.3 | 16 | ||||
-rw-r--r-- | lib/libcrypto/stack/stack.c | 3 |
2 files changed, 6 insertions, 13 deletions
diff --git a/lib/libcrypto/man/OPENSSL_sk_new.3 b/lib/libcrypto/man/OPENSSL_sk_new.3 index 748411bf15c..47b19cb4e80 100644 --- a/lib/libcrypto/man/OPENSSL_sk_new.3 +++ b/lib/libcrypto/man/OPENSSL_sk_new.3 @@ -1,4 +1,4 @@ -.\" $OpenBSD: OPENSSL_sk_new.3,v 1.8 2018/03/27 17:35:50 schwarze Exp $ +.\" $OpenBSD: OPENSSL_sk_new.3,v 1.9 2018/04/01 00:36:28 schwarze Exp $ .\" .\" Copyright (c) 2018 Ingo Schwarze <schwarze@openbsd.org> .\" @@ -14,7 +14,7 @@ .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. .\" -.Dd $Mdocdate: March 27 2018 $ +.Dd $Mdocdate: April 1 2018 $ .Dt OPENSSL_SK_NEW 3 .Os .Sh NAME @@ -279,8 +279,9 @@ or successfuly calling .Fn sk_push , .Fn sk_unshift , -or .Fn sk_insert , +or +.Fn sk_set , or changing the comparison function sets the state to unsorted. If a comparison function is installed, calling .Fn sk_sort , @@ -564,15 +565,6 @@ first appeared in OpenSSL 0.9.7e and has been available since first appeared in OpenSSL 0.9.8 and has been available since .Ox 4.5 . .Sh BUGS -.Fn sk_set -does not set the state of the -.Fa stack -to unsorted. -This can cause wrong results from subsequent -.Fn sk_find -and -.Fn sk_find_ex . -.Pp Even if a comparison function is installed, empty stacks and stacks containing a single pointer are sometimes considered sorted and sometimes considered unsorted. diff --git a/lib/libcrypto/stack/stack.c b/lib/libcrypto/stack/stack.c index d941f9e6fb8..b76a0d7271c 100644 --- a/lib/libcrypto/stack/stack.c +++ b/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); } |