Commit d516d7a9 authored by Matt Caswell's avatar Matt Caswell
Browse files

Fix BIO_eof() for BIO pairs



BIO_eof() was always returning true when using a BIO pair. It should only
be true if the peer BIO is empty and has been shutdown.

RT#1215

Reviewed-by: default avatarRichard Levitte <levitte@openssl.org>
(cherry picked from commit 3105d695)
parent 2b4825d0
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -655,15 +655,14 @@ static long bio_ctrl(BIO *bio, int cmd, long num, void *ptr)
        break;

    case BIO_CTRL_EOF:
        {
            BIO *other_bio = ptr;

            if (other_bio) {
                struct bio_bio_st *other_b = other_bio->ptr;
        if (b->peer != NULL) {
            struct bio_bio_st *peer_b = b->peer->ptr;

                assert(other_b != NULL);
                ret = other_b->len == 0 && other_b->closed;
            } else
            if (peer_b->len == 0 && peer_b->closed)
                ret = 1;
            else
                ret = 0;
        } else {
            ret = 1;
        }
        break;
+3 −0
Original line number Diff line number Diff line
@@ -120,6 +120,9 @@ the application then waits for data to be available on the underlying transport
before flushing the write buffer it will never succeed because the request was
never sent!

BIO_eof() is true if no data is in the peer BIO and the peer BIO has been
shutdown.

=head1 RETURN VALUES

BIO_new_bio_pair() returns 1 on success, with the new BIOs available in