mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
fs/unionfs: add sanity check for parameter
if relpath is NULL, it will cause system crash:
unionfs_opendir with relpath NULL
-> unionfs_tryopendir
-> unionfs_offsetpath
-> strncmp(prefix, relpath, pfxlen
Signed-off-by: Jiuzhu Dong <dongjiuzhu1@xiaomi.com>
This commit is contained in:
@@ -1421,6 +1421,11 @@ static int unionfs_opendir(FAR struct inode *mountpt,
|
|||||||
|
|
||||||
finfo("relpath: \"%s\"\n", relpath ? relpath : "NULL");
|
finfo("relpath: \"%s\"\n", relpath ? relpath : "NULL");
|
||||||
|
|
||||||
|
if (!relpath)
|
||||||
|
{
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
/* Recover the filesystem data from the struct inode instance */
|
/* Recover the filesystem data from the struct inode instance */
|
||||||
|
|
||||||
DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
|
DEBUGASSERT(mountpt != NULL && mountpt->i_private != NULL);
|
||||||
@@ -1441,7 +1446,7 @@ static int unionfs_opendir(FAR struct inode *mountpt,
|
|||||||
* omit duplicates on file system 1.
|
* omit duplicates on file system 1.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (relpath && strlen(relpath) > 0)
|
if (strlen(relpath) > 0)
|
||||||
{
|
{
|
||||||
fu->fu_relpath = strdup(relpath);
|
fu->fu_relpath = strdup(relpath);
|
||||||
if (!fu->fu_relpath)
|
if (!fu->fu_relpath)
|
||||||
|
|||||||
Reference in New Issue
Block a user