From fd23056d4ec5c7136dcd6e36e7e356da9ff5a0ee Mon Sep 17 00:00:00 2001 From: yudechen Date: Fri, 17 Jun 2022 15:47:39 +0800 Subject: [PATCH] change max syscap string len form 128 to 256. Signed-off-by: yudechen Change-Id: I8f47a5768167f38a474e9c67caed15422272321d --- include/syscap_define.h | 2 +- src/create_pcid.c | 21 ++++++++++----------- src/syscap_tool.c | 2 +- 3 files changed, 12 insertions(+), 13 deletions(-) diff --git a/include/syscap_define.h b/include/syscap_define.h index d7ceb8f..aa1bcfc 100644 --- a/include/syscap_define.h +++ b/include/syscap_define.h @@ -17,7 +17,7 @@ #define _SYSCAP_DEFINE_H typedef struct SystemCapabilityWithNum { - char syscapStr[128]; + char syscapStr[256]; uint16_t num; } SyscapWithNum; diff --git a/src/create_pcid.c b/src/create_pcid.c index 6217c42..ad58fc8 100644 --- a/src/create_pcid.c +++ b/src/create_pcid.c @@ -30,8 +30,7 @@ #include "syscap_define.h" #include "create_pcid.h" -#define SINGLE_FEAT_LENGTH (32 * 8) -#define PER_SYSCAP_LEN_MAX 128 +#define SINGLE_SYSCAP_LEN 256 #define PCID_OUT_BUFFER 32 #define PRIVATE_SYSCAP_SIZE 1000 #define UINT8_BIT 8 @@ -423,9 +422,9 @@ int32_t DecodePCID(char *inputFile, char *outDirPath) char *ptrPrivateSyscap = (char *)(pcidMain + 1); uint16_t privateSyscapLen = contextBufLen - sizeof(PCIDMain) - 1; - char priSyscapStr[PER_SYSCAP_LEN_MAX] = {0}; + char priSyscapStr[SINGLE_SYSCAP_LEN] = {0}; char *tempPriSyscapStr = priSyscapStr; - char fullPriSyscapStr[PER_SYSCAP_LEN_MAX] = {0}; + char fullPriSyscapStr[SINGLE_SYSCAP_LEN] = {0}; if (privateSyscapLen < 0) { PRINT_ERR("parse private syscap failed."); ret = -1; @@ -437,7 +436,7 @@ int32_t DecodePCID(char *inputFile, char *outDirPath) while (*ptrPrivateSyscap != '\0') { if (*ptrPrivateSyscap == ',') { *tempPriSyscapStr = '\0'; - ret = sprintf_s(fullPriSyscapStr, PER_SYSCAP_LEN_MAX, "SystemCapability.%s", priSyscapStr); + ret = sprintf_s(fullPriSyscapStr, SINGLE_SYSCAP_LEN, "SystemCapability.%s", priSyscapStr); if (ret == -1) { printf("sprintf_s failed\n"); goto FREE_VECTOR_OUT; @@ -761,19 +760,19 @@ int32_t DecodePcidToString(char *inputFile, char *outDirPath) if (priSyscapCount == 0) { goto OUT_PUT; } - priSyscapFull = (char *)malloc(priSyscapCount * SINGLE_FEAT_LENGTH); + priSyscapFull = (char *)malloc(priSyscapCount * SINGLE_SYSCAP_LEN); if (priSyscapFull == NULL) { PRINT_ERR("malloc failed\n"); goto FREE_PRISYSCAP_FULL; } - (void)memset_s(priSyscapFull, priSyscapCount * SINGLE_FEAT_LENGTH, - 0, priSyscapCount * SINGLE_FEAT_LENGTH); - char tempSyscap[SINGLE_FEAT_LENGTH] = {0}; + (void)memset_s(priSyscapFull, priSyscapCount * SINGLE_SYSCAP_LEN, + 0, priSyscapCount * SINGLE_SYSCAP_LEN); + char tempSyscap[SINGLE_SYSCAP_LEN] = {0}; char *temp = tempSyscap; for (i = 0, j = 0; i < privateSyscapLen; i++) { if (*privateSyscap == ',') { *temp = '\0'; - ret = sprintf_s(priSyscapFull + j * SINGLE_FEAT_LENGTH, SINGLE_FEAT_LENGTH, + ret = sprintf_s(priSyscapFull + j * SINGLE_SYSCAP_LEN, SINGLE_SYSCAP_LEN, "SystemCapability.%s", tempSyscap); if (ret == -1) { PRINT_ERR("sprintf_s failed\n"); @@ -809,7 +808,7 @@ OUT_PUT: } } for (i = 0; i < priSyscapCount; i++) { - ret = sprintf_s(output, outputLen, "%s,%s", output, priSyscapFull + i * SINGLE_FEAT_LENGTH); + ret = sprintf_s(output, outputLen, "%s,%s", output, priSyscapFull + i * SINGLE_SYSCAP_LEN); if (ret == -1) { PRINT_ERR("sprintf_s failed\n"); goto FREE_OUTPUT; diff --git a/src/syscap_tool.c b/src/syscap_tool.c index 2879c0c..75a161d 100644 --- a/src/syscap_tool.c +++ b/src/syscap_tool.c @@ -44,7 +44,7 @@ typedef struct RequiredProductCompatibilityIDHead { uint16_t apiVersionType : 1; } RPCIDHead; -#define SINGLE_SYSCAP_LEN 128 +#define SINGLE_SYSCAP_LEN 256 #define SYSCAP_PREFIX_LEN 17 #define SINGLE_FEAT_LEN (SINGLE_SYSCAP_LEN - SYSCAP_PREFIX_LEN) #define UINT8_BIT 8 -- Gitee