This is an automated email from the ASF dual-hosted git repository.

sjanc pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-newtmgr.git

commit 85b05893a889ccfd30d55d4df25cbd2b0ac09200
Author: Szymon Janc <[email protected]>
AuthorDate: Wed Oct 21 23:29:30 2026 +0200

    nmxact/nmcoap: Do not panic on invalid CoAP-TCP packet
    
    Commit 0dd1daa ("nmxact: API change for CoAP operations") added a
    panic("GA") in Reassembler.RxFrag() when coap.PullTcp() fails, which
    looks like a debugging leftover. It made the following "return nil"
    unreachable and lets any malformed packet received from a device
    crash the whole program.
    
    Simply removing the panic is not enough: on decode error PullTcp()
    returns the input buffer unchanged, so the invalid bytes would stay
    in the reassembly buffer and every subsequent fragment would be
    appended to them and fail to decode as well. Drop the buffered data
    on error so that reception can recover with the next packet.
    
    Assisted-by: Claude:claude-opus-5-5
---
 nmxact/nmcoap/frag.go | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nmxact/nmcoap/frag.go b/nmxact/nmcoap/frag.go
index 5bb5526..a7371d7 100644
--- a/nmxact/nmcoap/frag.go
+++ b/nmxact/nmcoap/frag.go
@@ -40,7 +40,7 @@ func (r *Reassembler) RxFrag(frag []byte) *coap.TcpMessage {
        tm, r.cur, err = coap.PullTcp(r.cur)
        if err != nil {
                log.Debugf("received invalid CoAP-TCP packet: %s", err.Error())
-               panic("GA")
+               r.cur = nil
                return nil
        }
 

Reply via email to