BIO_F_READBUFFER(3ossl)

πŸ’– BIO_F_READBUFFER πŸ’–

okay bestie, gather round β€” this is the BIO_F_READBUFFER page from the OpenSSL manuals, and it's giving "buffering but make it seekable". Let's get into it πŸ¦‹


✨ NAME ✨

BIO_f_readbuffer β€” a read only buffering BIO that supports BIO_tell() and BIO_seek() πŸŽ€


✨ SYNOPSIS ✨

#include <openssl/bio.h>

const BIO_METHOD *BIO_f_readbuffer(void);

✨ DESCRIPTION ✨

BIO_f_readbuffer() returns the read buffering BIO method. That's the whole vibe πŸ’…

This BIO filter can be inserted on top of BIO's that do not support BIO_tell() or BIO_seek() β€” like, for example, a file BIO that uses stdin. iykyk 🫢

Data read from a read buffering BIO comes from an internal buffer, and that buffer gets filled from the next BIO in the chain. Chain energy, literally ✨

BIO_gets() is supported for read buffering BIOs. Slay. But writing data to a read buffering BIO is not supported β€” it's read only, bestie, respect the boundary 😭

Also lowkey important: calling BIO_reset() on a read buffering BIO does not clear any buffered data. The buffer stays. It's committed πŸ’€


✨ NOTES ✨

Read buffering BIOs implement BIO_read_ex() by using BIO_read_ex() operations on the next BIO (e.g. a file BIO) in the chain, and storing the result in an internal buffer β€” from which bytes are given back to the caller as appropriate for the call. Efficient? Yes. Iconic? Also yes. 🧚

BIO_read_ex() is guaranteed to give the caller the number of bytes it asks for, unless there's an error or end of communication is reached in the next BIO. So basically: you get what you asked for, or something went sideways πŸ™ˆ

The internal buffer can grow to cache the entire contents of the next BIO in the chain. Main character buffer energy. πŸ‘‘

BIO_seek() uses the internal buffer, so it can only seek into data that is already read. No time travel, no seeking into the future, periodt πŸ’…


✨ RETURN VALUES ✨

BIO_f_readbuffer() returns the read buffering BIO method. Same as above, fr fr 🌸


✨ SEE ALSO ✨


Copyright 2021 The OpenSSL Project Authors. All Rights Reserved. πŸ’œ

Licensed under the Apache License 2.0 (the "License"). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html. 🌈

Friendly reminder bestie: read the license, it's not a vibe-killer, it's just the rules πŸŽ€

And that's the whole page!! This was version 3.5.9, dated 2026-09-29, from the BIO_F_READBUFFER(3ossl) manual. Go forth and buffer, you absolute icon πŸ¦‹βœ¨πŸ’–

πŸ“¦ where this page comes from