From 45d9c5e8b80d3a4047d2b0610cca05fba6b023de Mon Sep 17 00:00:00 2001 From: tb Date: Mon, 28 Nov 2022 07:50:00 +0000 Subject: [PATCH] Retire prev_bio While BIO chains are doubly linked lists, nothing has ever made use of this fact internally. Even libssl has failed to maintain prev_bio properly in two places for a long time. When BIO was made opaque, the opportunity to fix that was missed. Instead, BIO_set_next() now allows breaking the lists from outside the library, which freerdp has long done. Problem found by schwarze while trying to document BIO_set_next(). schwarze likes the idea ok jsing --- lib/libcrypto/bio/bio_lib.c | 11 +---------- lib/libcrypto/bio/bio_local.h | 3 +-- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/lib/libcrypto/bio/bio_lib.c b/lib/libcrypto/bio/bio_lib.c index 2ac0abd82e4..92c0d5eb1c3 100644 --- a/lib/libcrypto/bio/bio_lib.c +++ b/lib/libcrypto/bio/bio_lib.c @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_lib.c,v 1.36 2022/08/15 10:48:45 tb Exp $ */ +/* $OpenBSD: bio_lib.c,v 1.37 2022/11/28 07:50:00 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -161,7 +161,6 @@ BIO_set(BIO *bio, const BIO_METHOD *method) bio->retry_reason = 0; bio->num = 0; bio->ptr = NULL; - bio->prev_bio = NULL; bio->next_bio = NULL; bio->references = 1; bio->num_read = 0L; @@ -623,8 +622,6 @@ BIO_push(BIO *b, BIO *bio) while (lb->next_bio != NULL) lb = lb->next_bio; lb->next_bio = bio; - if (bio != NULL) - bio->prev_bio = lb; /* called to do internal processing */ BIO_ctrl(b, BIO_CTRL_PUSH, 0, lb); return (b); @@ -642,13 +639,7 @@ BIO_pop(BIO *b) BIO_ctrl(b, BIO_CTRL_POP, 0, b); - if (b->prev_bio != NULL) - b->prev_bio->next_bio = b->next_bio; - if (b->next_bio != NULL) - b->next_bio->prev_bio = b->prev_bio; - b->next_bio = NULL; - b->prev_bio = NULL; return (ret); } diff --git a/lib/libcrypto/bio/bio_local.h b/lib/libcrypto/bio/bio_local.h index 7e1885f393e..94dd460bc5f 100644 --- a/lib/libcrypto/bio/bio_local.h +++ b/lib/libcrypto/bio/bio_local.h @@ -1,4 +1,4 @@ -/* $OpenBSD: bio_local.h,v 1.3 2022/01/14 08:40:57 tb Exp $ */ +/* $OpenBSD: bio_local.h,v 1.4 2022/11/28 07:50:00 tb Exp $ */ /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) * All rights reserved. * @@ -87,7 +87,6 @@ struct bio_st { int num; void *ptr; struct bio_st *next_bio; /* used by filter BIOs */ - struct bio_st *prev_bio; /* used by filter BIOs */ int references; unsigned long num_read; unsigned long num_write; -- 2.20.1