DESERIALIZER: Make OSSL_DESERIALIZER_from_{bio,fp} use BIO_tell() / BIO_seek()
authorRichard Levitte <levitte@openssl.org>
Mon, 27 Jul 2020 20:02:07 +0000 (22:02 +0200)
committerPauli <paul.dale@oracle.com>
Sat, 1 Aug 2020 01:51:20 +0000 (11:51 +1000)
commit1dbf4537738d86d8078b74c89e38b6ed0b2b1196
tree43e414c0958f6dbd04050b1cc8deb34e39f3a74a
parent3c033c5bfed214b02c0f041239d1cb8a4e27fd82
DESERIALIZER: Make OSSL_DESERIALIZER_from_{bio,fp} use BIO_tell() / BIO_seek()

Depending on the BIO used, using BIO_reset() may lead to "interesting"
results.  For example, a BIO_f_buffer() on top of another BIO that
handles BIO_reset() as a BIO_seek(bio, 0), the deserialization process
may find itself with a file that's rewound more than expected.

Therefore, OSSL_DESERIALIZER_from_{bio,fp}'s behaviour is changed to
rely purely on BIO_tell() / BIO_seek(), and since BIO_s_mem() is used
internally, it's changed to handle BIO_tell() and BIO_seek() better.

This does currently mean that OSSL_DESERIALIZER can't be easily used
with streams that don't support BIO_tell() / BIO_seek().

Fixes #12541

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/12544)
crypto/bio/bss_mem.c
crypto/serializer/deserializer_lib.c