]> git.ipfire.org Git - thirdparty/openssl.git/commit
Ensure that empty or 1 element stacks are always sorted.
authorBob Beck <beck@openssl.org>
Wed, 10 Sep 2025 17:43:01 +0000 (11:43 -0600)
committerPauli <paul.dale@oracle.com>
Wed, 17 Sep 2025 08:09:39 +0000 (18:09 +1000)
commitd88c43a64408616572941e5d0b127194d80f562f
tree5047c7118c6d6ca0aa820b1d7fe45aa911c86355
parenta5eaa0e1e35117904e8b21a994f03d25f3558a2a
Ensure that empty or 1 element stacks are always sorted.

Matt noticed "It's kind of weird that we are forced to call sort on
a newly created and empty stack. It feels like an empty stack should
have the "sorted" flag by default on creation"

I am incluined to agree. This change ensures tht empty or 1 element
stacks are marked as sorted, as per the existing comment in the
file.

Since this involved changing the various duplication routines to
also ensure that sorted was preserved for such stacks, I also
noticed the duplication code was largely duplicated. I
took the opportunity to deduplicate the duplication code while
making these changes.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <ppzgs1@gmail.com>
(Merged from https://github.com/openssl/openssl/pull/28509)
crypto/stack/stack.c
test/stack_test.c