diff options
author | tb <> | 2022-11-28 07:50:00 +0000 |
---|---|---|
committer | tb <> | 2022-11-28 07:50:00 +0000 |
commit | 7691347e2fda8b7c237410d949d999ac011d4f51 (patch) | |
tree | 9c55c20172856df5e0781972a2ba2bb13e99f7af | |
parent | ff87c2bb70b531cb0565d09034121e93cedc0e17 (diff) | |
download | openbsd-7691347e2fda8b7c237410d949d999ac011d4f51.tar.gz openbsd-7691347e2fda8b7c237410d949d999ac011d4f51.tar.bz2 openbsd-7691347e2fda8b7c237410d949d999ac011d4f51.zip |
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
-rw-r--r-- | src/lib/libcrypto/bio/bio_lib.c | 11 | ||||
-rw-r--r-- | src/lib/libcrypto/bio/bio_local.h | 3 |
2 files changed, 2 insertions, 12 deletions
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c index 2ac0abd82e..92c0d5eb1c 100644 --- a/src/lib/libcrypto/bio/bio_lib.c +++ b/src/lib/libcrypto/bio/bio_lib.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bio_lib.c,v 1.36 2022/08/15 10:48:45 tb Exp $ */ | 1 | /* $OpenBSD: bio_lib.c,v 1.37 2022/11/28 07:50:00 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -161,7 +161,6 @@ BIO_set(BIO *bio, const BIO_METHOD *method) | |||
161 | bio->retry_reason = 0; | 161 | bio->retry_reason = 0; |
162 | bio->num = 0; | 162 | bio->num = 0; |
163 | bio->ptr = NULL; | 163 | bio->ptr = NULL; |
164 | bio->prev_bio = NULL; | ||
165 | bio->next_bio = NULL; | 164 | bio->next_bio = NULL; |
166 | bio->references = 1; | 165 | bio->references = 1; |
167 | bio->num_read = 0L; | 166 | bio->num_read = 0L; |
@@ -623,8 +622,6 @@ BIO_push(BIO *b, BIO *bio) | |||
623 | while (lb->next_bio != NULL) | 622 | while (lb->next_bio != NULL) |
624 | lb = lb->next_bio; | 623 | lb = lb->next_bio; |
625 | lb->next_bio = bio; | 624 | lb->next_bio = bio; |
626 | if (bio != NULL) | ||
627 | bio->prev_bio = lb; | ||
628 | /* called to do internal processing */ | 625 | /* called to do internal processing */ |
629 | BIO_ctrl(b, BIO_CTRL_PUSH, 0, lb); | 626 | BIO_ctrl(b, BIO_CTRL_PUSH, 0, lb); |
630 | return (b); | 627 | return (b); |
@@ -642,13 +639,7 @@ BIO_pop(BIO *b) | |||
642 | 639 | ||
643 | BIO_ctrl(b, BIO_CTRL_POP, 0, b); | 640 | BIO_ctrl(b, BIO_CTRL_POP, 0, b); |
644 | 641 | ||
645 | if (b->prev_bio != NULL) | ||
646 | b->prev_bio->next_bio = b->next_bio; | ||
647 | if (b->next_bio != NULL) | ||
648 | b->next_bio->prev_bio = b->prev_bio; | ||
649 | |||
650 | b->next_bio = NULL; | 642 | b->next_bio = NULL; |
651 | b->prev_bio = NULL; | ||
652 | return (ret); | 643 | return (ret); |
653 | } | 644 | } |
654 | 645 | ||
diff --git a/src/lib/libcrypto/bio/bio_local.h b/src/lib/libcrypto/bio/bio_local.h index 7e1885f393..94dd460bc5 100644 --- a/src/lib/libcrypto/bio/bio_local.h +++ b/src/lib/libcrypto/bio/bio_local.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bio_local.h,v 1.3 2022/01/14 08:40:57 tb Exp $ */ | 1 | /* $OpenBSD: bio_local.h,v 1.4 2022/11/28 07:50:00 tb Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -87,7 +87,6 @@ struct bio_st { | |||
87 | int num; | 87 | int num; |
88 | void *ptr; | 88 | void *ptr; |
89 | struct bio_st *next_bio; /* used by filter BIOs */ | 89 | struct bio_st *next_bio; /* used by filter BIOs */ |
90 | struct bio_st *prev_bio; /* used by filter BIOs */ | ||
91 | int references; | 90 | int references; |
92 | unsigned long num_read; | 91 | unsigned long num_read; |
93 | unsigned long num_write; | 92 | unsigned long num_write; |