summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authortb <>2022-12-02 19:44:04 +0000
committertb <>2022-12-02 19:44:04 +0000
commit1443fca68ffae5ceceac8fd474f197973e87d300 (patch)
tree5794ade176b91bfa4582fc50d6870cb255dba4ef /src
parent491dd78777dac52aaab51fc26e3b929046e5005e (diff)
downloadopenbsd-1443fca68ffae5ceceac8fd474f197973e87d300.tar.gz
openbsd-1443fca68ffae5ceceac8fd474f197973e87d300.tar.bz2
openbsd-1443fca68ffae5ceceac8fd474f197973e87d300.zip
Revert bio_prev removal
As schwarze points out, you can pop any BIO in a chain, not just the first one (bonus points for a great name for this API). The internal doubly linked was used to fix up the BIO chain bio was part of when you BIO_pop() a bio that wasn't in the first position, which is explicitly allowed in our documentation and implied by OpenSSL's.
Diffstat (limited to 'src')
-rw-r--r--src/lib/libcrypto/bio/bio_lib.c11
-rw-r--r--src/lib/libcrypto/bio/bio_local.h3
2 files changed, 12 insertions, 2 deletions
diff --git a/src/lib/libcrypto/bio/bio_lib.c b/src/lib/libcrypto/bio/bio_lib.c
index b33ebe167b..c09ad8fe8e 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.38 2022/11/30 01:56:18 jsing Exp $ */ 1/* $OpenBSD: bio_lib.c,v 1.39 2022/12/02 19:44:04 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,6 +161,7 @@ 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;
164 bio->next_bio = NULL; 165 bio->next_bio = NULL;
165 bio->references = 1; 166 bio->references = 1;
166 bio->num_read = 0L; 167 bio->num_read = 0L;
@@ -636,6 +637,8 @@ BIO_push(BIO *b, BIO *bio)
636 while (lb->next_bio != NULL) 637 while (lb->next_bio != NULL)
637 lb = lb->next_bio; 638 lb = lb->next_bio;
638 lb->next_bio = bio; 639 lb->next_bio = bio;
640 if (bio != NULL)
641 bio->prev_bio = lb;
639 /* called to do internal processing */ 642 /* called to do internal processing */
640 BIO_ctrl(b, BIO_CTRL_PUSH, 0, lb); 643 BIO_ctrl(b, BIO_CTRL_PUSH, 0, lb);
641 return (b); 644 return (b);
@@ -653,7 +656,13 @@ BIO_pop(BIO *b)
653 656
654 BIO_ctrl(b, BIO_CTRL_POP, 0, b); 657 BIO_ctrl(b, BIO_CTRL_POP, 0, b);
655 658
659 if (b->prev_bio != NULL)
660 b->prev_bio->next_bio = b->next_bio;
661 if (b->next_bio != NULL)
662 b->next_bio->prev_bio = b->prev_bio;
663
656 b->next_bio = NULL; 664 b->next_bio = NULL;
665 b->prev_bio = NULL;
657 return (ret); 666 return (ret);
658} 667}
659 668
diff --git a/src/lib/libcrypto/bio/bio_local.h b/src/lib/libcrypto/bio/bio_local.h
index 94dd460bc5..4eecf7e04a 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.4 2022/11/28 07:50:00 tb Exp $ */ 1/* $OpenBSD: bio_local.h,v 1.5 2022/12/02 19:44:04 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,6 +87,7 @@ 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 */
90 int references; 91 int references;
91 unsigned long num_read; 92 unsigned long num_read;
92 unsigned long num_write; 93 unsigned long num_write;