avformat/sctp: add size check in sctp_read() matching sctp_write()
authorbird <6666242+bird@users.noreply.github.com>
Sun, 5 Apr 2026 05:52:03 +0000 (05:52 +0000)
committerMichael Niedermayer <michael@niedermayer.cc>
Thu, 18 Jun 2026 18:31:06 +0000 (20:31 +0200)
commitd79983ab0f6fa34101dd70b30f16a045c5e960ac
tree1a92859b2d5582d7f63ae19f6b4a9ccd10b48787
parent24919c78d3f7f8f95922784c78debf13e2f1f83f
avformat/sctp: add size check in sctp_read() matching sctp_write()

Commit 5b98cea4 added a size < 2 guard to sctp_write() to prevent
out-of-bounds access when max_streams is enabled, but the identical
pattern in sctp_read() was not addressed.

When max_streams is non-zero, sctp_read() passes (buf + 2, size - 2)
to ff_sctp_recvmsg(). If size < 2, size - 2 wraps to a large value
on the implicit cast to size_t in the callee.

Add the same guard.

Signed-off-by: bird <6666242+bird@users.noreply.github.com>
(cherry picked from commit 5c3602abaa50dfe60a3356de5abff73f15df0f99)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavformat/sctp.c