<fix>
修复报警信息,为以下修复点 1、修复空指针未判断 2、修复open后未及时close 导致内存泄露 3、修复strdup后未free 4、修复赋值后未使用等问题 5、修复编码中判断条件中无符号变量小于零的情况 Signed-off-by: xiacong <xiacong4@huawei.com> Change-Id: I13d046141afeb8a116e6a04304a3793bf8e12bee Signed-off-by: xiacong <xiacong4@huawei.com>
This commit is contained in:
@@ -902,6 +902,10 @@ static int MapToPosixRet(int ret)
|
||||
/* POSIX interface */
|
||||
int LOS_Open(const char *path, int flags, ...)
|
||||
{
|
||||
if (path == NULL) {
|
||||
errno = EINVAL;
|
||||
return (int)LOS_NOK;
|
||||
}
|
||||
#ifdef LOSCFG_RANDOM_DEV
|
||||
unsigned flagMask = O_RDONLY | O_WRONLY | O_RDWR | O_APPEND | O_CREAT | O_LARGEFILE \
|
||||
| O_TRUNC | O_EXCL | O_DIRECTORY;
|
||||
@@ -952,7 +956,7 @@ int LOS_Open(const char *path, int flags, ...)
|
||||
FREE_AND_SET_NULL(canonicalPath);
|
||||
#endif
|
||||
#if (LOSCFG_POSIX_PIPE_API == 1)
|
||||
if ((path != NULL) && !strncmp(path, PIPE_DEV_PATH, strlen(PIPE_DEV_PATH))) {
|
||||
if (!strncmp(path, PIPE_DEV_PATH, strlen(PIPE_DEV_PATH))) {
|
||||
return PipeOpen(path, flags, PIPE_DEV_FD);
|
||||
}
|
||||
#endif
|
||||
@@ -1149,8 +1153,9 @@ int OsFcntl(int fd, int cmd, va_list ap)
|
||||
ret = VfsVfcntl(filep, cmd, ap);
|
||||
VfsDetachFile(filep);
|
||||
} else {
|
||||
#ifndef LOSCFG_NET_LWIP_SACK
|
||||
ret = -EBADF;
|
||||
#ifdef LOSCFG_NET_LWIP_SACK
|
||||
#else
|
||||
int arg = va_arg(ap, int);
|
||||
ret = lwip_fcntl(fd, (long)cmd, arg);
|
||||
return ret;
|
||||
@@ -1182,8 +1187,9 @@ int OsIoctl(int fd, int req, va_list ap)
|
||||
if (fd < CONFIG_NFILE_DESCRIPTORS) {
|
||||
ret = VfsIoctl(fd, req, ap);
|
||||
} else {
|
||||
#ifndef LOSCFG_NET_LWIP_SACK
|
||||
ret = -EBADF;
|
||||
#ifdef LOSCFG_NET_LWIP_SACK
|
||||
#else
|
||||
UINTPTR arg = va_arg(ap, UINTPTR);
|
||||
ret = lwip_ioctl(fd, (long)req, (void *)arg);
|
||||
#endif /* LOSCFG_NET_LWIP_SACK */
|
||||
|
||||
@@ -47,7 +47,7 @@ int GetPartIdByPartName(const char *partName)
|
||||
|
||||
/* the character next to p is the partId */
|
||||
char *p = strrchr(partName, 'p');
|
||||
if (p + 1 != NULL) {
|
||||
if (p != NULL) {
|
||||
return atoi(p + 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -529,7 +529,7 @@ u32_t OsShellPing(int argc, const char **argv)
|
||||
{
|
||||
int ret;
|
||||
u32_t i = 0;
|
||||
u32_t count = 0;
|
||||
u32_t count;
|
||||
int count_set = 0;
|
||||
u32_t interval = 1000; /* default ping interval */
|
||||
u32_t data_len = 48; /* default data length */
|
||||
|
||||
@@ -67,7 +67,7 @@ int SysUserTaskCreate(unsigned long entry, unsigned long userArea, unsigned long
|
||||
|
||||
int SysSchedSetScheduler(unsigned int tid, int policy, int priority)
|
||||
{
|
||||
if ((tid <= 0) || (tid > LOSCFG_BASE_CORE_TSK_LIMIT)) {
|
||||
if ((tid == 0) || (tid > LOSCFG_BASE_CORE_TSK_LIMIT)) {
|
||||
return EINVAL;
|
||||
}
|
||||
|
||||
@@ -92,7 +92,7 @@ int *SysSchedGetArea(unsigned int tid)
|
||||
unsigned int intSave;
|
||||
int *area = NULL;
|
||||
|
||||
if ((tid <= 0) || (tid > LOSCFG_BASE_CORE_TSK_LIMIT)) {
|
||||
if ((tid == 0) || (tid > LOSCFG_BASE_CORE_TSK_LIMIT)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -544,11 +544,6 @@ STATIC INT32 OsShellCmdDoRmdir(const CHAR *pathname)
|
||||
}
|
||||
if (strcmp(dirent->d_name, "..") && strcmp(dirent->d_name, ".")) {
|
||||
size_t fullPathBufSize = strlen(pathname) + strlen(dirent->d_name) + SEPARATOR_EOF_LEN;
|
||||
if (fullPathBufSize <= 0) {
|
||||
PRINTK("buffer size is invalid!\n");
|
||||
(VOID)closedir(d);
|
||||
return -1;
|
||||
}
|
||||
fullpath = (CHAR *)malloc(fullPathBufSize);
|
||||
if (fullpath == NULL) {
|
||||
PRINTK("malloc failure!\n");
|
||||
|
||||
Reference in New Issue
Block a user