From: Tomas Mraz Date: Mon, 4 Dec 2023 10:16:45 +0000 (+0100) Subject: Make OPENSSL_sk_push return only 0 or 1 X-Git-Tag: openssl-3.3.0-alpha1~356 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=98d6016afec4c0bc7bb8f33b5061beb8528cc74a;p=thirdparty%2Fopenssl.git Make OPENSSL_sk_push return only 0 or 1 Most of the callers do not actually check for the special -1 return condition because they do not pass NULL to it. It is also extremely improbable that any code depends on this -1 return value in this condition so it can be safely changed to 0 return. Reviewed-by: Matt Caswell Reviewed-by: Ben Kaduk (Merged from https://github.com/openssl/openssl/pull/22930) --- diff --git a/CHANGES.md b/CHANGES.md index 43f874ff9c5..625eacb6d40 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -41,6 +41,11 @@ OpenSSL 3.3 *Neil Horman* + * OPENSSL_sk_push() and sk__push() functions now return 0 instead of -1 + if called with a NULL stack argument. + + *Tomáš Mráz* + * In `openssl speed`, changed the default hash function used with `hmac` from `md5` to `sha256`. diff --git a/crypto/stack/stack.c b/crypto/stack/stack.c index 72e3087e89b..05a37ed87d1 100644 --- a/crypto/stack/stack.c +++ b/crypto/stack/stack.c @@ -397,7 +397,7 @@ int OPENSSL_sk_find_all(OPENSSL_STACK *st, const void *data, int *pnum) int OPENSSL_sk_push(OPENSSL_STACK *st, const void *data) { if (st == NULL) - return -1; + return 0; return OPENSSL_sk_insert(st, data, st->num); } diff --git a/doc/man3/DEFINE_STACK_OF.pod b/doc/man3/DEFINE_STACK_OF.pod index 06a0256bacf..7b3c724af21 100644 --- a/doc/man3/DEFINE_STACK_OF.pod +++ b/doc/man3/DEFINE_STACK_OF.pod @@ -270,7 +270,6 @@ on error. B_insert>(), B_push>() and B_unshift>() return the total number of elements in the stack and 0 if an error occurred. -B_push>() further returns -1 if I is NULL. B_set>() returns a pointer to the replacement element or NULL on error. @@ -297,6 +296,9 @@ and B_find_all>() calls are read-only and do not sort the stack. To avoid any performance implications this change introduces, B_sort>() should be called before these find operations. +Before OpenSSL 3.3.0 B_push>() returned -1 if I was NULL. It +was changed to return 0 in this condition as for other errors. + =head1 COPYRIGHT Copyright 2000-2023 The OpenSSL Project Authors. All Rights Reserved.