embed bio_dgram_data inside bio_dgram_sctp_data
authorNeil Horman <nhorman@openssl.org>
Wed, 4 Oct 2023 13:48:37 +0000 (09:48 -0400)
committerTomas Mraz <tomas@openssl.org>
Thu, 5 Oct 2023 17:09:06 +0000 (19:09 +0200)
commit4bad474746472f08b0247b5afa81ddc71df98d5f
tree15624af2719248ac411aaae52cd00b9fa459d645
parent31fc8a83bc9aa435ae40c3eff713ced441eaa011
embed bio_dgram_data inside bio_dgram_sctp_data

the sctp BIO implementation uses the generic BIO dgram implementation
under the covers for some operations.  However, the private data for
each bio is incongruous, leading to segfaults when doing things like
passing a dgram_sctp_ctrl operation to the underlying dgram_ctrl method.

Fix this by removing the common fields between the two strcutres and
embedding a bio_dgram_data as the first member of the
bio_dgram_sctp_data struct.  This allows implicit casting when that call
path is taken, avoiding any memory mis-use

Fixes #20643

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/22278)
crypto/bio/bss_dgram.c