Make the old sk_* functions into full functions

Due to b/290792019 and b/290785937, we need them to actually exist at
the original symbols. For all of Rust's language-level safety benefits,
the ecosystem seems determined to undo it with patterns that are even
less safe than C.

This is not great and the bugs need to be fixed, but do this for now to
unblock the Android update.

Change-Id: Ia883336879779f652e7320cecdd5ca843996f6a3
Reviewed-on: https://boringssl-review.googlesource.com/c/boringssl/+/61525
Reviewed-by: Bob Beck <bbe@google.com>
Commit-Queue: Bob Beck <bbe@google.com>
Auto-Submit: David Benjamin <davidben@google.com>
chromium-stable
David Benjamin 1 year ago committed by Boringssl LUCI CQ
parent 00e3ffb10b
commit 690dcdf5c9
  1. 14
      crypto/stack/stack.c
  2. 29
      include/openssl/stack.h
  3. 7
      rust/bssl-sys/src/lib.rs

@ -518,3 +518,17 @@ OPENSSL_STACK *OPENSSL_sk_deep_copy(const OPENSSL_STACK *sk,
return ret;
}
OPENSSL_STACK *sk_new_null(void) { return OPENSSL_sk_new_null(); }
size_t sk_num(const OPENSSL_STACK *sk) { return OPENSSL_sk_num(sk); }
void *sk_value(const OPENSSL_STACK *sk, size_t i) {
return OPENSSL_sk_value(sk, i);
}
void sk_free(OPENSSL_STACK *sk) { OPENSSL_sk_free(sk); }
size_t sk_push(OPENSSL_STACK *sk, void *p) { return OPENSSL_sk_push(sk, p); }
void *sk_pop(OPENSSL_STACK *sk) { return OPENSSL_sk_pop(sk); }

@ -330,28 +330,19 @@ OPENSSL_EXPORT OPENSSL_STACK *OPENSSL_sk_deep_copy(
//
// TODO(crbug.com/boringssl/499): Migrate callers to the typed wrappers, or at
// least the new names and remove the old ones.
//
// TODO(b/290792019, b/290785937): Ideally these would at least be inline
// functions, so we do not squat the symbols.
typedef OPENSSL_STACK _STACK;
OPENSSL_INLINE OPENSSL_STACK *sk_new_null(void) {
return OPENSSL_sk_new_null();
}
OPENSSL_INLINE size_t sk_num(const OPENSSL_STACK *sk) {
return OPENSSL_sk_num(sk);
}
OPENSSL_INLINE void *sk_value(const OPENSSL_STACK *sk, size_t i) {
return OPENSSL_sk_value(sk, i);
}
OPENSSL_INLINE void sk_free(OPENSSL_STACK *sk) { OPENSSL_sk_free(sk); }
OPENSSL_INLINE size_t sk_push(OPENSSL_STACK *sk, void *p) {
return OPENSSL_sk_push(sk, p);
}
OPENSSL_INLINE void *sk_pop(OPENSSL_STACK *sk) { return OPENSSL_sk_pop(sk); }
// The following functions call the corresponding |OPENSSL_sk_*| function.
OPENSSL_EXPORT OPENSSL_STACK *sk_new_null(void);
OPENSSL_EXPORT size_t sk_num(const OPENSSL_STACK *sk);
OPENSSL_EXPORT void *sk_value(const OPENSSL_STACK *sk, size_t i);
OPENSSL_EXPORT void sk_free(OPENSSL_STACK *sk);
OPENSSL_EXPORT size_t sk_push(OPENSSL_STACK *sk, void *p);
OPENSSL_EXPORT void *sk_pop(OPENSSL_STACK *sk);
// sk_pop_free behaves like |sk_pop_free_ex| but performs an invalid function
// pointer cast. It exists because some existing callers called |sk_pop_free|

@ -18,13 +18,6 @@ pub fn ERR_GET_FUNC(packed_error: u32) -> i32 {
unsafe { ERR_GET_FUNC_RUST(packed_error) }
}
pub use OPENSSL_sk_free as sk_free;
pub use OPENSSL_sk_new_null as sk_new_null;
pub use OPENSSL_sk_num as sk_num;
pub use OPENSSL_sk_pop as sk_pop;
pub use OPENSSL_sk_push as sk_push;
pub use OPENSSL_sk_value as sk_value;
pub fn init() {
unsafe {
CRYPTO_library_init();

Loading…
Cancel
Save