mirror of
https://github.com/espressif/openthread.git
synced 2026-06-05 21:14:49 +00:00
3d731aae2f
This commit fixes a deterministic null-pointer dereference in CoapBase::ProcessBlock2Request when receiving a Block2 request with block number greater than 0 without a preceding active blockwise transfer. Previously, when mLastResponse was null, the option copying logic would unconditionally attempt to initialize the iterator with a dereferenced mLastResponse pointer (iterator.Init(*mLastResponse)), causing a segmentation fault crash. This fix inserts a VerifyOrExit check on mLastResponse inside ProcessBlock2Request. If mLastResponse is null, it returns the kErrorNoFrameReceived error code. In ProcessBlockwiseRequest, this is mapped to a 4.08 Request Entity Incomplete response, matching the spec-compliant error handling behavior of Block1. An automated reproduction and verification test case has also been added to tests/nexus/test_coap_block.cpp.