From db4f13faad0665a4f700dad84f0b99a030b9810d Mon Sep 17 00:00:00 2001 From: slguan Date: Sat, 7 Mar 2020 10:28:29 +0800 Subject: [PATCH] invalid memory write while authorization failed --- src/system/detail/src/mgmtShell.c | 51 ++++++++++++++++--------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/src/system/detail/src/mgmtShell.c b/src/system/detail/src/mgmtShell.c index 06556c817f..e617b4b45c 100644 --- a/src/system/detail/src/mgmtShell.c +++ b/src/system/detail/src/mgmtShell.c @@ -1333,36 +1333,37 @@ _rsp: pRsp->code = code; pMsg += sizeof(STaosRsp); - if (code == 0) { - pConnectRsp = (SConnectRsp *)pRsp->more; - sprintf(pConnectRsp->acctId, "%x", pConn->pAcct->acctId); - strcpy(pConnectRsp->version, version); - pConnectRsp->writeAuth = pConn->writeAuth; - pConnectRsp->superAuth = pConn->superAuth; - pMsg += sizeof(SConnectRsp); - - int size; - if (pSdbPublicIpList != NULL && pSdbIpList != NULL) { - size = pSdbPublicIpList->numOfIps * 4 + sizeof(SIpList); - if (pConn->usePublicIp) { - memcpy(pMsg, pSdbPublicIpList, size); - } else { - memcpy(pMsg, pSdbIpList, size); - } + pConnectRsp = (SConnectRsp *)pRsp->more; + sprintf(pConnectRsp->acctId, "%x", pConn->pAcct->acctId); + strcpy(pConnectRsp->version, version); + pConnectRsp->writeAuth = pConn->writeAuth; + pConnectRsp->superAuth = pConn->superAuth; + pMsg += sizeof(SConnectRsp); + + int size; + if (pSdbPublicIpList != NULL && pSdbIpList != NULL) { + size = pSdbPublicIpList->numOfIps * 4 + sizeof(SIpList); + if (pConn->usePublicIp) { + memcpy(pMsg, pSdbPublicIpList, size); } else { - SIpList tmpIpList; - tmpIpList.numOfIps = 0; - size = tmpIpList.numOfIps * 4 + sizeof(SIpList); - memcpy(pMsg, &tmpIpList, size); + memcpy(pMsg, pSdbIpList, size); } + } else { + SIpList tmpIpList; + tmpIpList.numOfIps = 0; + size = tmpIpList.numOfIps * 4 + sizeof(SIpList); + memcpy(pMsg, &tmpIpList, size); + } - pMsg += size; + pMsg += size; - // set the time resolution: millisecond or microsecond - *((uint32_t *)pMsg) = tsTimePrecision; - pMsg += sizeof(uint32_t); + // set the time resolution: millisecond or microsecond + *((uint32_t *)pMsg) = tsTimePrecision; + pMsg += sizeof(uint32_t); - } else { + if (code != 0) { + pConnectRsp->writeAuth = 0; + pConnectRsp->superAuth = 0; pConn->pAcct = NULL; pConn->pUser = NULL; } -- GitLab