diff --git a/src/rpc/src/rpcUdp.c b/src/rpc/src/rpcUdp.c index 086a390cb8ea2a95f576cb1bff81dfc79769863a..46313543d861ab1a2b56a236b0416cb373295bb7 100644 --- a/src/rpc/src/rpcUdp.c +++ b/src/rpc/src/rpcUdp.c @@ -186,9 +186,11 @@ static void *taosRecvUdpData(void *param) { SUdpConn *pConn = param; struct sockaddr_in sourceAdd; ssize_t dataLen; + int32_t msgLen; unsigned int addLen; uint16_t port; SRecvInfo recvInfo; + SRpcHead *pHead; memset(&sourceAdd, 0, sizeof(sourceAdd)); addLen = sizeof(sourceAdd); @@ -218,6 +220,13 @@ static void *taosRecvUdpData(void *param) { continue; } + pHead = (SRpcHead *)msg; + msgLen = (int32_t)htonl((uint32_t)pHead->msgLen); + if (dataLen < msgLen) { + tError("%s recvfrom failed(%s): dataLen: %ld, msgLen: %d", pConn->label, strerror(errno), (long)dataLen, msgLen); + continue; + } + int32_t size = dataLen + tsRpcOverhead; char *tmsg = malloc(size); if (NULL == tmsg) {