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:
parent
e4c9a491c8
commit
a91d143944
1 changed files with 6 additions and 1 deletions
|
@ -1421,6 +1421,11 @@ static int unionfs_opendir(FAR struct inode *mountpt,
|
|||
|
||||
finfo("relpath: \"%s\"\n", relpath ? relpath : "NULL");
|
||||
|
||||
if (!relpath)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Recover the filesystem data from the struct inode instance */
|
||||
|
||||
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.
|
||||
*/
|
||||
|
||||
if (relpath && strlen(relpath) > 0)
|
||||
if (strlen(relpath) > 0)
|
||||
{
|
||||
fu->fu_relpath = strdup(relpath);
|
||||
if (!fu->fu_relpath)
|
||||
|
|
Loading…
Reference in a new issue