未验证 提交 913d22bf 编写于 作者: O openharmony_ci 提交者: Gitee

!822 A核内源代码检视问题修改

Merge pull request !822 from wangchen/0308_a
...@@ -180,7 +180,7 @@ static void LmsFreeTest(void) ...@@ -180,7 +180,7 @@ static void LmsFreeTest(void)
printf("\n-------- LmsFreeTest Start --------\n"); printf("\n-------- LmsFreeTest Start --------\n");
char *buf = (char *)malloc(16); char *buf = (char *)malloc(16);
printf("[LmsFreeTest] malloc addr:%p size:%d\n", buf, 16); printf("[LmsFreeTest] malloc addr:%p size:%d\n", buf, 16);
printf("[LmsFreeTest] free addr:%p\n", buf, 16); printf("[LmsFreeTest] free addr:%p size:%d\n", buf, 16);
free(buf); free(buf);
printf("[LmsFreeTest] Use after free error should be triggered, read addr:%p range[1,1]\n", buf); printf("[LmsFreeTest] Use after free error should be triggered, read addr:%p range[1,1]\n", buf);
BufReadTest(buf, 1, 1); BufReadTest(buf, 1, 1);
...@@ -204,5 +204,6 @@ int main(int argc, char * const * argv) ...@@ -204,5 +204,6 @@ int main(int argc, char * const * argv)
LmsStrcpyTest(); LmsStrcpyTest();
LmsStrcatTest(); LmsStrcatTest();
LmsFreeTest(); LmsFreeTest();
free(tmp);
printf("\n############### Lms Test End ###############\n"); printf("\n############### Lms Test End ###############\n");
} }
\ No newline at end of file
...@@ -36,7 +36,6 @@ ...@@ -36,7 +36,6 @@
#include "dirent.h" #include "dirent.h"
#include "securec.h" #include "securec.h"
#define SHELL_INIT_MAGIC_FLAG 0xABABABAB #define SHELL_INIT_MAGIC_FLAG 0xABABABAB
#define CTRL_C 0x03 /* 0x03: ctrl+c ASCII */ #define CTRL_C 0x03 /* 0x03: ctrl+c ASCII */
...@@ -585,7 +584,6 @@ END: ...@@ -585,7 +584,6 @@ END:
unsigned int OsCmdExec(CmdParsed *cmdParsed, char *cmdStr) unsigned int OsCmdExec(CmdParsed *cmdParsed, char *cmdStr)
{ {
/* TODO: complete the usrspace command */
unsigned int ret = SH_OK; unsigned int ret = SH_OK;
if (cmdParsed && cmdStr) { if (cmdParsed && cmdStr) {
ret = SH_NOK; ret = SH_NOK;
......
...@@ -519,7 +519,7 @@ int ProcOpen(struct ProcFile *procFile) ...@@ -519,7 +519,7 @@ int ProcOpen(struct ProcFile *procFile)
static int ProcRead(struct ProcDirEntry *pde, char *buf, size_t len) static int ProcRead(struct ProcDirEntry *pde, char *buf, size_t len)
{ {
if (pde == NULL || pde == NULL || pde->pf == NULL) { if (pde == NULL || pde->pf == NULL) {
return PROC_ERROR; return PROC_ERROR;
} }
struct ProcFile *procFile = pde->pf; struct ProcFile *procFile = pde->pf;
......
...@@ -380,6 +380,11 @@ int VnodeLookupAt(const char *path, struct Vnode **result, uint32_t flags, struc ...@@ -380,6 +380,11 @@ int VnodeLookupAt(const char *path, struct Vnode **result, uint32_t flags, struc
if (orgVnode != NULL) { if (orgVnode != NULL) {
startVnode = orgVnode; startVnode = orgVnode;
normalizedPath = strdup(path); normalizedPath = strdup(path);
if (normalizedPath == NULL) {
PRINT_ERR("[VFS]lookup failed, strdup err\n");
ret = -EINVAL;
goto OUT_FREE_PATH;
}
} else { } else {
ret = PreProcess(path, &startVnode, &normalizedPath); ret = PreProcess(path, &startVnode, &normalizedPath);
if (ret != LOS_OK) { if (ret != LOS_OK) {
......
...@@ -2002,6 +2002,8 @@ LITE_OS_SEC_TEXT VOID LOS_Exit(INT32 status) ...@@ -2002,6 +2002,8 @@ LITE_OS_SEC_TEXT VOID LOS_Exit(INT32 status)
{ {
UINT32 intSave; UINT32 intSave;
(void)status;
/* The exit of a kernel - state process must be kernel - state and all threads must actively exit */ /* The exit of a kernel - state process must be kernel - state and all threads must actively exit */
LosProcessCB *processCB = OsCurrProcessGet(); LosProcessCB *processCB = OsCurrProcessGet();
SCHEDULER_LOCK(intSave); SCHEDULER_LOCK(intSave);
......
...@@ -578,7 +578,7 @@ BOOL OsSchedModifyTaskSchedParam(LosTaskCB *taskCB, UINT16 policy, UINT16 priori ...@@ -578,7 +578,7 @@ BOOL OsSchedModifyTaskSchedParam(LosTaskCB *taskCB, UINT16 policy, UINT16 priori
} }
taskCB->priority = priority; taskCB->priority = priority;
OsHookCall(LOS_HOOK_TYPE_TASK_PRIMODIFY, taskCB, taskCB->priority); OsHookCall(LOS_HOOK_TYPE_TASK_PRIMODIFY, taskCB, taskCB->priority);
if (taskCB->taskStatus & OS_TASK_STATUS_INIT) { if (taskCB->taskStatus & OS_TASK_STATUS_INIT) {
OsSchedTaskEnQueue(taskCB); OsSchedTaskEnQueue(taskCB);
return TRUE; return TRUE;
...@@ -771,7 +771,9 @@ BOOL OsSchedSwtmrTimeListFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg) ...@@ -771,7 +771,9 @@ BOOL OsSchedSwtmrTimeListFind(SCHED_TL_FIND_FUNC checkFunc, UINTPTR arg)
for (UINT16 cpuid = 0; cpuid < LOSCFG_KERNEL_CORE_NUM; cpuid++) { for (UINT16 cpuid = 0; cpuid < LOSCFG_KERNEL_CORE_NUM; cpuid++) {
SchedRunQue *rq = OsSchedRunQueByID(cpuid); SchedRunQue *rq = OsSchedRunQueByID(cpuid);
SortLinkAttribute *swtmrSortLink = &rq->swtmrSortLink; SortLinkAttribute *swtmrSortLink = &rq->swtmrSortLink;
return SchedSwtmrRunQueFind(swtmrSortLink, checkFunc, arg); if (SchedSwtmrRunQueFind(swtmrSortLink, checkFunc, arg)) {
return TRUE;
}
} }
return FALSE; return FALSE;
} }
......
...@@ -1325,7 +1325,9 @@ INT32 system_console_init(const CHAR *deviceName) ...@@ -1325,7 +1325,9 @@ INT32 system_console_init(const CHAR *deviceName)
LOS_SpinLockSave(&g_consoleSpin, &intSave); LOS_SpinLockSave(&g_consoleSpin, &intSave);
(VOID)OsConsoleDelete(consoleCB); (VOID)OsConsoleDelete(consoleCB);
g_console[consoleID - 1] = NULL; g_console[consoleID - 1] = NULL;
g_taskConsoleIDArray[OsCurrTaskGet()->taskID] = 0; if (OsCurrTaskGet() != NULL) {
g_taskConsoleIDArray[OsCurrTaskGet()->taskID] = 0;
}
LOS_SpinUnlockRestore(&g_consoleSpin, intSave); LOS_SpinUnlockRestore(&g_consoleSpin, intSave);
return VFS_ERROR; return VFS_ERROR;
} }
......
...@@ -52,7 +52,7 @@ STATIC VOID OsRbLeftRotateNode(LosRbTree *pstTree, LosRbNode *pstX) ...@@ -52,7 +52,7 @@ STATIC VOID OsRbLeftRotateNode(LosRbTree *pstTree, LosRbNode *pstX)
LosRbNode *pstNilT = NULL; LosRbNode *pstNilT = NULL;
LosRbNode *pstParent = NULL; LosRbNode *pstParent = NULL;
if (NULL == pstTree || NULL == pstX) { if (pstTree == NULL || pstX == NULL) {
return; return;
} }
pstNilT = &(pstTree->stNilT); pstNilT = &(pstTree->stNilT);
......
...@@ -3015,7 +3015,7 @@ int netstat_netconn_sendq(struct netconn *conn) ...@@ -3015,7 +3015,7 @@ int netstat_netconn_sendq(struct netconn *conn)
retVal = netstat_tcp_sendq(conn->pcb.tcp); retVal = netstat_tcp_sendq(conn->pcb.tcp);
break; break;
case NETCONN_RAW: case NETCONN_RAW:
retVal = 0; /* todo */ retVal = 0;
break; break;
#if PF_PKT_SUPPORT #if PF_PKT_SUPPORT
case NETCONN_PKT_RAW: case NETCONN_PKT_RAW:
......
...@@ -144,7 +144,7 @@ err_t netifapi_dhcps_stop(struct netif *netif) ...@@ -144,7 +144,7 @@ err_t netifapi_dhcps_stop(struct netif *netif)
*/ */
static void tcp_unlock_accept(ip6_addr_t *ipaddr) static void tcp_unlock_accept(ip6_addr_t *ipaddr)
{ {
// FIXME
} }
static void netif_ip6_addr_setinvalid(struct netif *netif, const ip6_addr_t *addr6) static void netif_ip6_addr_setinvalid(struct netif *netif, const ip6_addr_t *addr6)
...@@ -327,26 +327,22 @@ err_t netif_set_hwaddr(struct netif *netif, const unsigned char *hw_addr, int hw ...@@ -327,26 +327,22 @@ err_t netif_set_hwaddr(struct netif *netif, const unsigned char *hw_addr, int hw
err_t etharp_update_arp_entry(struct netif *netif, const ip4_addr_t *ipaddr, struct eth_addr *ethaddr, u8_t flags) err_t etharp_update_arp_entry(struct netif *netif, const ip4_addr_t *ipaddr, struct eth_addr *ethaddr, u8_t flags)
{ {
// FIXME
return 0; return 0;
} }
err_t etharp_delete_arp_entry(struct netif *netif, ip4_addr_t *ipaddr) err_t etharp_delete_arp_entry(struct netif *netif, ip4_addr_t *ipaddr)
{ {
// FIXME
return 0; return 0;
} }
err_t lwip_dns_setserver(u8_t numdns, ip_addr_t *dnsserver) err_t lwip_dns_setserver(u8_t numdns, ip_addr_t *dnsserver)
{ {
// FIXME
return 0; return 0;
} }
err_t lwip_dns_getserver(u8_t numdns, ip_addr_t *dnsserver) err_t lwip_dns_getserver(u8_t numdns, ip_addr_t *dnsserver)
{ {
// FIXME
return 0; return 0;
} }
...@@ -372,7 +368,6 @@ sys_sem_t dup_addr_detect; ...@@ -372,7 +368,6 @@ sys_sem_t dup_addr_detect;
int lwip_sntp_start(int server_num, char **sntp_server, struct timeval *time) int lwip_sntp_start(int server_num, char **sntp_server, struct timeval *time)
{ {
// FIXME
return 0; return 0;
} }
......
...@@ -69,7 +69,7 @@ static UINT32 Testcase(VOID) ...@@ -69,7 +69,7 @@ static UINT32 Testcase(VOID)
tickNum = (osEndTime - osStartTime) * LOSCFG_BASE_CORE_TICK_PER_SECOND / OS_SYS_CLOCK; tickNum = (osEndTime - osStartTime) * LOSCFG_BASE_CORE_TICK_PER_SECOND / OS_SYS_CLOCK;
if (tickNum < (10 - 2) && tickNum > (10 + 2)) { // when tick num in 10 - 2 or 10 + 2 interval if (tickNum < (10 - 2) || tickNum > (10 + 2)) { // when tick num in 10 - 2 or 10 + 2 interval
ICUNIT_ASSERT_EQUAL(tickNum, 0, tickNum); ICUNIT_ASSERT_EQUAL(tickNum, 0, tickNum);
} }
ret = LOS_EventClear(&g_event, 0); ret = LOS_EventClear(&g_event, 0);
......
...@@ -82,16 +82,21 @@ static int TestCase(void) ...@@ -82,16 +82,21 @@ static int TestCase(void)
printf("fd=%d\n", fd); printf("fd=%d\n", fd);
if (fd == -1) { if (fd == -1) {
perror("openls"); perror("openls");
munmap(p, st.st_size);
return -1; return -1;
} }
rc = read(fd, p, st.st_size); rc = read(fd, p, st.st_size);
if (rc == -1) { if (rc == -1) {
perror("read"); perror("read");
munmap(p, st.st_size);
close(shmFd);
return -1; return -1;
} }
if (rc != st.st_size) { if (rc != st.st_size) {
fputs("Strange situation!\n", stderr); fputs("Strange situation!\n", stderr);
munmap(p, st.st_size);
close(shmFd);
return -1; return -1;
} }
......
...@@ -44,9 +44,10 @@ static int testcase(void) ...@@ -44,9 +44,10 @@ static int testcase(void)
ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd); ICUNIT_ASSERT_NOT_EQUAL(shmfd, -1, shmfd);
writebuf = (char*)malloc(pageSize); writebuf = (char*)malloc(pageSize);
ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf);
readbuf = (char*)malloc(pageSize); readbuf = (char*)malloc(pageSize);
ICUNIT_ASSERT_NOT_EQUAL(readbuf, NULL, readbuf); ICUNIT_ASSERT_NOT_EQUAL(readbuf, NULL, readbuf);
ICUNIT_ASSERT_NOT_EQUAL(writebuf, NULL, writebuf);
memset_s(writebuf, pageSize, 0xf, pageSize); memset_s(writebuf, pageSize, 0xf, pageSize);
count = write(shmfd, writebuf, pageSize); count = write(shmfd, writebuf, pageSize);
......
...@@ -460,6 +460,7 @@ int RemoveDir(const char *dir) ...@@ -460,6 +460,7 @@ int RemoveDir(const char *dir)
ret = sprintf_s(dir_name, sizeof(dir_name), "%s/%s", dir, dp->d_name); ret = sprintf_s(dir_name, sizeof(dir_name), "%s/%s", dir, dp->d_name);
if (ret < 0) { if (ret < 0) {
perror("sprintf dir_name error"); perror("sprintf dir_name error");
closedir(dirp);
return -1; return -1;
} }
RemoveDir(dir_name); RemoveDir(dir_name);
......
...@@ -55,8 +55,6 @@ static int TestCase(void) ...@@ -55,8 +55,6 @@ static int TestCase(void)
ret = unlinkat(dirFd, FILEPATH, AT_REMOVEDIR); ret = unlinkat(dirFd, FILEPATH, AT_REMOVEDIR);
ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1); ICUNIT_GOTO_NOT_EQUAL(ret, JFFS_IS_ERROR, ret, EXIT1);
return JFFS_NO_ERROR;
EXIT1: EXIT1:
close(fd); close(fd);
unlink(DIRPATH); unlink(DIRPATH);
......
...@@ -353,7 +353,7 @@ INT32 JffsFixWrite(CHAR *path, INT64 fileSize, INT32 writeSize, INT32 interfaceT ...@@ -353,7 +353,7 @@ INT32 JffsFixWrite(CHAR *path, INT64 fileSize, INT32 writeSize, INT32 interfaceT
gettimeofday(&testTime2, 0); gettimeofday(&testTime2, 0);
perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec); perTime = (testTime2.tv_sec - testTime1.tv_sec) * USECS_PER_SEC + (testTime2.tv_usec - testTime1.tv_usec);
printf("fix_Write TaskID:%3d,sucess to fclose the %s ,task:%d ms,\n", taskId, path, MSECS_PER_SEC / MSECS_PER_SEC); printf("fix_Write TaskID:%3d,sucess to fclose the %s ,task:%d ms,\n", taskId, path, (perTime / USECS_PER_SEC) * MSECS_PER_SEC);
free(writeBuf); free(writeBuf);
...@@ -1000,7 +1000,7 @@ public: ...@@ -1000,7 +1000,7 @@ public:
}; };
#if defined(LOSCFG_USER_TEST_FULL) #if defined(LOSCFG_USER_TEST_FULL)
/* * /* *
* @tc.name: IO_TEST_FACCESSAT_001 * @tc.name: IO_TEST_FACCESSAT_001
* @tc.desc: normal tests for faccessat * @tc.desc: normal tests for faccessat
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: AR000EEMQ9 * @tc.require: AR000EEMQ9
......
...@@ -35,6 +35,7 @@ static UINT32 testcase(VOID) ...@@ -35,6 +35,7 @@ static UINT32 testcase(VOID)
struct mntent* mnt = nullptr; struct mntent* mnt = nullptr;
struct mntent* mnt_new = nullptr; struct mntent* mnt_new = nullptr;
FILE *fp = nullptr; FILE *fp = nullptr;
FILE *fp2 = nullptr;
char *argv[2] = {nullptr}; char *argv[2] = {nullptr};
argv[0] = "/etc/fstab"; argv[0] = "/etc/fstab";
argv[1] = "errors"; argv[1] = "errors";
...@@ -45,14 +46,14 @@ static UINT32 testcase(VOID) ...@@ -45,14 +46,14 @@ static UINT32 testcase(VOID)
char *pathList[] = {"/etc/fstab"}; char *pathList[] = {"/etc/fstab"};
char *streamList[] = {(char *)fileWords}; char *streamList[] = {(char *)fileWords};
int streamLen[] = {sizeof(fileWords)}; int streamLen[] = {sizeof(fileWords)};
int flag = PrepareFileEnv(pathList, streamList, streamLen, 1); int flag = PrepareFileEnv(pathList, streamList, streamLen, 1);
if (flag != 0) { if (flag != 0) {
printf("error: need some env file, but prepare is not ok"); printf("error: need some env file, but prepare is not ok");
(VOID)RecoveryFileEnv(pathList, 1); (VOID)RecoveryFileEnv(pathList, 1);
return -1; return -1;
} }
mnt_new = (struct mntent *)malloc(sizeof(struct mntent)); mnt_new = (struct mntent *)malloc(sizeof(struct mntent));
mnt_new->mnt_fsname = "UUID=c4992556-a86e-45e8-ba5f-190b16a9073x"; mnt_new->mnt_fsname = "UUID=c4992556-a86e-45e8-ba5f-190b16a9073x";
mnt_new->mnt_dir = "/usr1"; mnt_new->mnt_dir = "/usr1";
...@@ -64,6 +65,7 @@ static UINT32 testcase(VOID) ...@@ -64,6 +65,7 @@ static UINT32 testcase(VOID)
fp = setmntent("/etc/fstab", "r"); fp = setmntent("/etc/fstab", "r");
if (!fp) { if (!fp) {
printf("fp=0x%x\n", fp); printf("fp=0x%x\n", fp);
free(mnt_new);
return LOS_NOK; return LOS_NOK;
} }
...@@ -81,7 +83,8 @@ static UINT32 testcase(VOID) ...@@ -81,7 +83,8 @@ static UINT32 testcase(VOID)
/* test the addmntent below */ /* test the addmntent below */
fp = setmntent(argv[0], "a"); fp = setmntent(argv[0], "a");
if (fopen("/lib/libc.so", "r")) { fp2 = fopen("/lib/libc.so", "r");
if (fp2 != NULL) {
printf("aha I found you are OHOS!!!\n"); printf("aha I found you are OHOS!!!\n");
if (addmntent(fp, mnt_new)) { if (addmntent(fp, mnt_new)) {
printf("a new mnt is added to %s\n", argv[0]); printf("a new mnt is added to %s\n", argv[0]);
...@@ -91,6 +94,9 @@ static UINT32 testcase(VOID) ...@@ -91,6 +94,9 @@ static UINT32 testcase(VOID)
if (fp != NULL) { if (fp != NULL) {
endmntent(fp); endmntent(fp);
} }
if (fp2 != NULL) {
fclose(fp2);
}
(VOID)RecoveryFileEnv(pathList, 1); (VOID)RecoveryFileEnv(pathList, 1);
return LOS_OK; return LOS_OK;
} }
......
...@@ -34,7 +34,7 @@ static int TestCase(void) ...@@ -34,7 +34,7 @@ static int TestCase(void)
{ {
char *name = getlogin(); char *name = getlogin();
ICUNIT_ASSERT_NOT_EQUAL(name, "USER1", NULL); ICUNIT_ASSERT_NOT_EQUAL(name, "USER1", NULL);
int ret = getlogin_r(name, sizeof(name)); int ret = getlogin_r(name, strlen(name) + 1);
ICUNIT_ASSERT_EQUAL(ret, 6, ret); ICUNIT_ASSERT_EQUAL(ret, 6, ret);
ret = setenv("LOGNAME", "USER1", 1); ret = setenv("LOGNAME", "USER1", 1);
ICUNIT_ASSERT_EQUAL(ret, 0, ret); ICUNIT_ASSERT_EQUAL(ret, 0, ret);
......
...@@ -39,7 +39,10 @@ struct q { ...@@ -39,7 +39,10 @@ struct q {
static struct q *New(int i) static struct q *New(int i)
{ {
struct q *q = (struct q *)malloc(sizeof *q); struct q *q = (struct q *)malloc(sizeof *q);
q->i = i; if (q != NULL) {
q->i = i;
}
return q; return q;
} }
......
...@@ -76,17 +76,6 @@ HWTEST_F(TimeTimerTest, TimerTest003, TestSize.Level0) ...@@ -76,17 +76,6 @@ HWTEST_F(TimeTimerTest, TimerTest003, TestSize.Level0)
TimerTest003(); TimerTest003();
} }
/* *
* @tc.name: TimerTest004
* @tc.desc: function for TimeTimerTest
* @tc.type: FUNC
* @tc.require: AR000EEMQ9
*/
/*HWTEST_F(TimeTimerTest, TimerTest004, TestSize.Level0)
{
TimerTest004(); // TODO: musl sigaction handler have only one param.
}*/
/* * /* *
* @tc.name: TimerTest005 * @tc.name: TimerTest005
* @tc.desc: function for timer_create SIGEV_THREAD. * @tc.desc: function for timer_create SIGEV_THREAD.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册