diff --git a/components/fs/vfs/vfs_fs.c b/components/fs/vfs/vfs_fs.c index ce05503e..b3af9b3f 100644 --- a/components/fs/vfs/vfs_fs.c +++ b/components/fs/vfs/vfs_fs.c @@ -910,12 +910,17 @@ int LOS_Open(const char *path, int flags, ...) { #ifdef LOSCFG_RANDOM_DEV unsigned flagMask = O_RDONLY | O_WRONLY | O_RDWR | O_APPEND | O_CREAT | O_LARGEFILE | O_TRUNC | O_EXCL | O_DIRECTORY; - if (((unsigned)flags & ~flagMask) || (path == NULL)) { + if ((unsigned)flags & ~flagMask) { errno = EINVAL; return LOS_NOK; } size_t pathLen = strlen(path) + 1; + if ((unsigned)pathLen > PATH_MAX) { + errno = EINVAL; + return LOS_NOK; + } + char *canonicalPath = (char *)malloc(pathLen); if (!canonicalPath) { errno = ENOMEM; @@ -952,7 +957,7 @@ int LOS_Open(const char *path, int flags, ...) FREE_AND_SET_NULL(canonicalPath); #endif #if (LOSCFG_POSIX_PIPE_API == 1) - if (!strncmp(path, PIPE_DEV_PATH, strlen(PIPE_DEV_PATH))) { + if ((path != NULL) && !strncmp(path, PIPE_DEV_PATH, strlen(PIPE_DEV_PATH))) { return PipeOpen(path, flags, PIPE_DEV_FD); } #endif diff --git a/kernel/src/los_queue.c b/kernel/src/los_queue.c index 686e5d14..785b2316 100644 --- a/kernel/src/los_queue.c +++ b/kernel/src/los_queue.c @@ -39,6 +39,7 @@ #include "los_memory.h" #include "los_task.h" #include "los_sched.h" +#include #if (LOSCFG_BASE_IPC_QUEUE == 1)