mirror of
https://github.com/openharmony/developtools_syscap_codec.git
synced 2026-08-27 02:11:19 -04:00
fix: EncodePrivateSyscap input null point should return true.
Signed-off-by: yudechen <chenyude@huawei.com> Change-Id: I2ebf3fec0fd08a30763355f86ac7e35215016b61
This commit is contained in:
@@ -163,6 +163,7 @@ bool EncodePrivateSyscap(char **output, int *outputLen)
|
||||
*outputLen = bufferLen - PCID_MAIN_BYTES - 1;
|
||||
if (*outputLen == 0) {
|
||||
*output = outputStr;
|
||||
(*outputLen)--;
|
||||
return true;
|
||||
}
|
||||
outputStr = (char *)malloc(*outputLen);
|
||||
@@ -246,7 +247,7 @@ bool DecodePrivateSyscap(char *input, char (**output)[SINGLE_SYSCAP_LEN], int *o
|
||||
if (input == NULL) {
|
||||
*output = outputArray;
|
||||
*outputCnt = syscapCnt;
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
while (*inputPos != '\0') {
|
||||
|
||||
+2
-2
@@ -275,8 +275,8 @@ int32_t CreatePCID(char *inputFile, char *outDirPath)
|
||||
for (i = 0; i < privateCapSize; i++) {
|
||||
jsonArrayItem = cJSON_GetArrayItem(jsonPriSyscapObj, i);
|
||||
priSyscapStr = strchr(jsonArrayItem->valuestring, '.') + 1;
|
||||
nRet = strcat_s(priSyscapHead, PRIVATE_SYSCAP_SIZE - 1, priSyscapStr);
|
||||
nRet += strcat_s(priSyscapHead, PRIVATE_SYSCAP_SIZE - 1, ",");
|
||||
nRet = strcat_s(priSyscapHead, allPriSyscapStrLen + 1, priSyscapStr);
|
||||
nRet += strcat_s(priSyscapHead, allPriSyscapStrLen + 1, ",");
|
||||
if (nRet != EOK) {
|
||||
PRINT_ERR("strcat_s \"pri\" string is failed\n");
|
||||
ret = -1;
|
||||
|
||||
@@ -49,6 +49,9 @@ HWTEST_F(SyscapCodecTest, EncodePrivateSyscap, TestSize.Level1)
|
||||
char *charPriInput = nullptr;
|
||||
int priOutLen;
|
||||
EXPECT_TRUE(EncodePrivateSyscap(&charPriInput, &priOutLen));
|
||||
// Currently, private syscap is null.
|
||||
EXPECT_EQ(charPriInput, nullptr);
|
||||
EXPECT_EQ(priOutLen, 0);
|
||||
free(charPriInput);
|
||||
}
|
||||
|
||||
@@ -74,7 +77,7 @@ HWTEST_F(SyscapCodecTest, DecodeOsSyscap, TestSize.Level1)
|
||||
|
||||
/*
|
||||
* @tc.name: DecodePrivateSyscap
|
||||
* @tc.desc: Check the PrivateSyscap Decoding.
|
||||
* @tc.desc: Check the null PrivateSyscap Decoding.
|
||||
* @tc.type: FUNC
|
||||
*/
|
||||
HWTEST_F(SyscapCodecTest, DecodePrivateSyscap, TestSize.Level1)
|
||||
|
||||
Reference in New Issue
Block a user