From 82ef486dceb77a4779576f70cd9a1020a417cea3 Mon Sep 17 00:00:00 2001 From: wade zhang Date: Mon, 28 Mar 2022 16:42:37 +0800 Subject: [PATCH] TS-1368: Rename MD5 related names which conflict with names in system library --- src/client/src/tscParseLineProtocol.c | 8 ++++---- src/plugins/http/src/httpUtil.c | 8 ++++---- src/rpc/src/rpcMain.c | 12 ++++++------ src/util/inc/tmd5.h | 8 ++++---- src/util/inc/tutil.h | 8 ++++---- src/util/src/tmd5.c | 10 +++++----- src/util/src/tutil.c | 8 ++++---- 7 files changed, 31 insertions(+), 31 deletions(-) diff --git a/src/client/src/tscParseLineProtocol.c b/src/client/src/tscParseLineProtocol.c index e45c1bc956..bbe582466c 100644 --- a/src/client/src/tscParseLineProtocol.c +++ b/src/client/src/tscParseLineProtocol.c @@ -177,10 +177,10 @@ static int32_t getSmlMd5ChildTableName(TAOS_SML_DATA_POINT* point, char* tableNa } size_t len = 0; char* keyJoined = taosStringBuilderGetResult(&sb, &len); - MD5_CTX context; - MD5Init(&context); - MD5Update(&context, (uint8_t *)keyJoined, (uint32_t)len); - MD5Final(&context); + TAOS_MD5_CTX context; + taos_MD5Init(&context); + taos_MD5Update(&context, (uint8_t *)keyJoined, (uint32_t)len); + taos_MD5Final(&context); uint64_t digest1 = *(uint64_t*)(context.digest); uint64_t digest2 = *(uint64_t*)(context.digest + 8); *tableNameLen = snprintf(tableName, *tableNameLen, diff --git a/src/plugins/http/src/httpUtil.c b/src/plugins/http/src/httpUtil.c index f30ac7326e..221ff36d87 100644 --- a/src/plugins/http/src/httpUtil.c +++ b/src/plugins/http/src/httpUtil.c @@ -350,10 +350,10 @@ int32_t httpShrinkTableName(HttpContext *pContext, int32_t pos, char *name) { return pos; } - MD5_CTX context; - MD5Init(&context); - MD5Update(&context, (uint8_t *)name, (uint32_t)len); - MD5Final(&context); + TAOS_MD5_CTX context; + taos_MD5Init(&context); + taos_MD5Update(&context, (uint8_t *)name, (uint32_t)len); + taos_MD5Final(&context); int32_t table_name = httpAddToSqlCmdBuffer( pContext, "%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x", context.digest[0], diff --git a/src/rpc/src/rpcMain.c b/src/rpc/src/rpcMain.c index dfeca03826..b79843aad0 100644 --- a/src/rpc/src/rpcMain.c +++ b/src/rpc/src/rpcMain.c @@ -1541,14 +1541,14 @@ static SRpcHead *rpcDecompressRpcMsg(SRpcHead *pHead) { } static int rpcAuthenticateMsg(void *pMsg, int msgLen, void *pAuth, void *pKey) { - MD5_CTX context; + TAOS_MD5_CTX context; int ret = -1; - MD5Init(&context); - MD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); - MD5Update(&context, (uint8_t *)pMsg, msgLen); - MD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); - MD5Final(&context); + taos_MD5Init(&context); + taos_MD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); + taos_MD5Update(&context, (uint8_t *)pMsg, msgLen); + taos_MD5Update(&context, (uint8_t *)pKey, TSDB_KEY_LEN); + taos_MD5Final(&context); if (memcmp(context.digest, pAuth, sizeof(context.digest)) == 0) ret = 0; diff --git a/src/util/inc/tmd5.h b/src/util/inc/tmd5.h index d7fd038f37..f2c7ab6d7a 100644 --- a/src/util/inc/tmd5.h +++ b/src/util/inc/tmd5.h @@ -32,10 +32,10 @@ typedef struct { uint32_t buf[4]; /* scratch buffer */ uint8_t in[64]; /* input buffer */ uint8_t digest[16]; /* actual digest after MD5Final call */ -} MD5_CTX; +} TAOS_MD5_CTX; -void MD5Init(MD5_CTX *mdContext); -void MD5Update(MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen); -void MD5Final(MD5_CTX *mdContext); +void taos_MD5Init(MD5_CTX *mdContext); +void taos_MD5Update(MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen); +void taos_MD5Final(MD5_CTX *mdContext); #endif diff --git a/src/util/inc/tutil.h b/src/util/inc/tutil.h index a97b731f93..dd0d6f2b66 100644 --- a/src/util/inc/tutil.h +++ b/src/util/inc/tutil.h @@ -47,10 +47,10 @@ void jsonKeyMd5(void *pMsg, int msgLen, void *pKey); bool isValidateTag(char *input); static FORCE_INLINE void taosEncryptPass(uint8_t *inBuf, size_t inLen, char *target) { - MD5_CTX context; - MD5Init(&context); - MD5Update(&context, inBuf, (unsigned int)inLen); - MD5Final(&context); + TAOS_MD5_CTX context; + taos_MD5Init(&context); + taos_MD5Update(&context, inBuf, (unsigned int)inLen); + taos_MD5Final(&context); memcpy(target, context.digest, TSDB_KEY_LEN); } diff --git a/src/util/src/tmd5.c b/src/util/src/tmd5.c index a1fdcc6a05..185d04a2d6 100644 --- a/src/util/src/tmd5.c +++ b/src/util/src/tmd5.c @@ -85,8 +85,8 @@ static uint8_t PADDING[64] = {0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x /* The routine MD5Init initializes the message-digest context mdContext. All fields are set to zero. */ -void MD5Init(MD5_CTX *mdContext) { - memset(mdContext, 0, sizeof(MD5_CTX)); +void taos_MD5Init(TAOS_MD5_CTX *mdContext) { + memset(mdContext, 0, sizeof(TAOS_MD5_CTX)); /* Load magic initialization constants. */ mdContext->buf[0] = (uint32_t)0x67452301; @@ -99,7 +99,7 @@ void MD5Init(MD5_CTX *mdContext) { account for the presence of each of the characters inBuf[0..inLen-1] in the message whose digest is being computed. */ -void MD5Update(MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen) { +void taos_MD5Update(TAOS_MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen) { uint32_t in[16]; int mdi; unsigned int i, ii; @@ -130,7 +130,7 @@ void MD5Update(MD5_CTX *mdContext, uint8_t *inBuf, unsigned int inLen) { /* The routine MD5Final terminates the message-digest computation and ends with the desired message digest in mdContext->digest[0...15]. */ -void MD5Final(MD5_CTX *mdContext) { +void taos_MD5Final(TAOS_MD5_CTX *mdContext) { uint32_t in[16]; int mdi; unsigned int i, ii; @@ -145,7 +145,7 @@ void MD5Final(MD5_CTX *mdContext) { /* pad out to 56 mod 64 */ padLen = (mdi < 56) ? (56 - mdi) : (120 - mdi); - MD5Update(mdContext, PADDING, padLen); + taos_MD5Update(mdContext, PADDING, padLen); /* append length in bits and transform */ for (i = 0, ii = 0; i < 14; i++, ii += 4) diff --git a/src/util/src/tutil.c b/src/util/src/tutil.c index 8bcef9f32b..8a26c937a5 100644 --- a/src/util/src/tutil.c +++ b/src/util/src/tutil.c @@ -455,11 +455,11 @@ char *taosIpStr(uint32_t ipInt) { } void jsonKeyMd5(void *pMsg, int msgLen, void *pKey) { - MD5_CTX context; + TAOS_MD5_CTX context; - MD5Init(&context); - MD5Update(&context, (uint8_t *)pMsg, msgLen); - MD5Final(&context); + taos_MD5Init(&context); + taos_MD5Update(&context, (uint8_t *)pMsg, msgLen); + taos_MD5Final(&context); memcpy(pKey, context.digest, sizeof(context.digest)); } -- GitLab