diff --git a/src/internal.c b/src/internal.c index eb7baccb5..fb7b42217 100644 --- a/src/internal.c +++ b/src/internal.c @@ -2267,7 +2267,9 @@ void DtlsMsgListDelete(DtlsMsg* head, void* heap) void DtlsMsgSet(DtlsMsg* msg, word32 seq, const byte* data, byte type, word32 fragOffset, word32 fragSz) { - if (msg != NULL && data != NULL && msg->fragSz <= msg->sz) { + if (msg != NULL && data != NULL && msg->fragSz <= msg->sz && + fragOffset < msg->sz && (fragOffset + fragSz) <= msg->sz) { + msg->seq = seq; msg->type = type; msg->fragSz += fragSz;