fix: 编译告警清零

【背景】

3.0 LTS 告警清零

【修改方案】
添加了安全函数的检查,将不安全的函数改写为安全函数

【影响】
对现有的产品编译不会有影响。

re #I4TM2U

Signed-off-by: yinjiaming <yinjiaming@huawei.com>
Change-Id: I4479172e755821916aa6f299607fdceac763d468
This commit is contained in:
yinjiaming 2022-02-14 08:32:16 +00:00
parent 9de6f57cda
commit 6ffea886d3
5 changed files with 23 additions and 5 deletions

View File

@ -138,6 +138,9 @@ UINT32 PreHandleCmdline(const CHAR *input, CHAR **output, UINT32 *outputlen)
UINT32 ret;
const CHAR *cmdBuf = input;
UINT32 cmdBufLen = strlen(cmdBuf);
if ((cmdBufLen + 1) > SHELL_CMD_MAX_SIZE) {
return SH_NOK;
}
CHAR *shiftStr = (CHAR *)malloc(cmdBufLen + 1);
if (shiftStr == NULL) {

View File

@ -523,7 +523,10 @@ static int OsShellCmdDoRmdir(const char *pathname)
char *fullpath = NULL;
int ret;
(void)memset_s(&statInfo, sizeof(statInfo), 0, sizeof(struct stat));
ret = memset_s(&statInfo, sizeof(struct stat), 0, sizeof(struct stat));
if (ret != 0) {
return -1;
}
if (stat(pathname, &statInfo) != 0) {
return -1;
}

View File

@ -338,8 +338,12 @@ __STATIC_FORCEINLINE q31_t riscv_nn_requantize(const q31_t val, const q31_t mult
__STATIC_FORCEINLINE q31_t riscv_nn_read_q15x2_ia(const q15_t **in_q15)
{
q31_t val;
int ret;
memcpy(&val, *in_q15, 4);
ret = memcpy_s(&val, sizeof(q31_t), *in_q15, 4); // 4: data offset
if (ret != 0) {
return 0;
}
*in_q15 += 2;
return (val);
@ -353,7 +357,10 @@ __STATIC_FORCEINLINE q31_t riscv_nn_read_q15x2_ia(const q15_t **in_q15)
__STATIC_FORCEINLINE q31_t riscv_nn_read_q7x4_ia(const q7_t **in_q7)
{
q31_t val;
memcpy(&val, *in_q7, 4);
int ret = memcpy_s(&val, sizeof(q31_t), *in_q7, 4); // 4: data offset
if (ret != 0) {
return 0;
}
*in_q7 += 4;
return (val);

View File

@ -34,6 +34,7 @@
#if (LOSCFG_MEM_MUL_REGIONS == 1)
#define MEMGAP_SIZE 16
// simulate two non-continuous memory regions
STATIC UINT8 g_memPool_TC46_01[0x200];
STATIC UINT8 g_memGap_TC46[0x10];
@ -57,7 +58,7 @@ static UINT32 TestCase(VOID)
// p points to the start address of the gap node between g_memPool_TC46_01 and g_memPool_TC46_02
p = g_memPool_TC46_01 + 0x200;
(void)memset_s(g_memGap_TC46, 0x10, 1, 0x10);
(void)memset_s(g_memGap_TC46, MEMGAP_SIZE, 1, MEMGAP_SIZE);
ret = LOS_MemFree(m_aucSysMem0, p);
ICUNIT_GOTO_EQUAL(ret, LOS_NOK, ret, EXIT);

View File

@ -73,7 +73,11 @@ static uint32_t RegexFuzz(void)
heartbeatPrint(i);
string1 = DT_SetGetString(&g_element[NUM_0_INDEX], initStrLen, maxStrLen, "CHN");
(void)strncpy_s(str1, MAX_STR_BUF_LEN, string1, maxStrLen);
ret = strncpy_s(str1, MAX_STR_BUF_LEN, string1, maxStrLen);
if (ret != 0) {
printf("strncpy_s failure in %s[%d], i = %d\n", __FUCTION__, __LINE__, i);
return 1;
}
str1[MAX_STR_BUF_LEN - 1] = '\0';
string2 = DT_SetGetString(&g_element[NUM_1_INDEX], initStrLen, maxStrLen, "CHN");
(void)strncpy_s(str2, MAX_STR_BUF_LEN, string2, maxStrLen);