fix: set field length properly in tsdbGetSnapDetails

This commit is contained in:
Benguang Zhao 2023-10-13 20:46:53 +08:00
parent 83013e0fe5
commit f2bd43c07e
2 changed files with 6 additions and 5 deletions

View File

@ -52,9 +52,9 @@ typedef enum {
int32_t grantCheck(EGrantType grant); int32_t grantCheck(EGrantType grant);
#ifndef TD_GRANT_OPTIMIZE #ifndef TD_GRANT_OPTIMIZE
int32_t grantAlterActiveCode(const char* old, const char* new, char* out, int8_t type); int32_t grantAlterActiveCode(const char* old, const char* newer, char* out, int8_t type);
#else #else
int32_t grantAlterActiveCode(int32_t did, const char* old, const char* new, char* out, int8_t type); int32_t grantAlterActiveCode(int32_t did, const char* old, const char* newer, char* out, int8_t type);
#endif #endif
#ifndef GRANTS_CFG #ifndef GRANTS_CFG
@ -114,4 +114,4 @@ int32_t grantAlterActiveCode(int32_t did, const char* old, const char* new, char
} }
#endif #endif
#endif /*_TD_COMMON_GRANT_H_*/ #endif /*_TD_COMMON_GRANT_H_*/

View File

@ -1562,6 +1562,7 @@ int32_t tsdbSnapGetDetails(SVnode* pVnode, SSnapshot* pSnap) {
head->len = 0; head->len = 0;
head->typ = pSnap->type; head->typ = pSnap->type;
int32_t offset = sizeof(SSyncTLV); int32_t offset = sizeof(SSyncTLV);
int32_t tlen = 0;
// fill snapshot info // fill snapshot info
for (int32_t j = 0; j < tsdbMaxCnt; ++j) { for (int32_t j = 0; j < tsdbMaxCnt; ++j) {
@ -1573,7 +1574,6 @@ int32_t tsdbSnapGetDetails(SVnode* pVnode, SSnapshot* pSnap) {
subHead->typ = subTyps[j]; subHead->typ = subTyps[j];
ASSERT(subHead->val == (char*)data + offset + sizeof(SSyncTLV)); ASSERT(subHead->val == (char*)data + offset + sizeof(SSyncTLV));
int32_t tlen = 0;
if ((tlen = tSerializeTsdbSnapPartList(subHead->val, bufLen - offset - sizeof(SSyncTLV), pLists[j])) < 0) { if ((tlen = tSerializeTsdbSnapPartList(subHead->val, bufLen - offset - sizeof(SSyncTLV), pLists[j])) < 0) {
tsdbError("vgId:%d, failed to serialize snap partition list of tsdb %d since %s", TD_VID(pVnode), j, terrstr()); tsdbError("vgId:%d, failed to serialize snap partition list of tsdb %d since %s", TD_VID(pVnode), j, terrstr());
goto _out; goto _out;
@ -1582,7 +1582,8 @@ int32_t tsdbSnapGetDetails(SVnode* pVnode, SSnapshot* pSnap) {
offset += sizeof(SSyncTLV) + tlen; offset += sizeof(SSyncTLV) + tlen;
} }
head->len = offset; head->len = offset - sizeof(SSyncTLV);
ASSERT(offset <= bufLen);
code = 0; code = 0;
_out: _out: