Re: [PATCH] hfsplus: fix NULL dereference in hfsplus_lookup()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, 2018-07-12 at 18:53 -0300, Ernesto A. Fernández wrote:
> Check that the hidden directory is not NULL before using it, instead of
> after.
> 
> Reported-by: Wen Xu <wen.xu@xxxxxxxxxx>
> Signed-off-by: Ernesto A. Fernández <ernesto.mnd.fernandez@xxxxxxxxx>
> ---

It's really hard to understand this simple patch. I believe it makes
sense to rework the patch slightly with the goal to make it more clear.
Also, it will be great to add a short comment in the code to explain
what's wrong.

I think it makes sense to split this long check condition on something
more clear, simple and elegant.

Thanks,
Vyacheslav Dubeyko.

>  fs/hfsplus/dir.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/hfsplus/dir.c b/fs/hfsplus/dir.c
> index b5254378f011..cd017d7dbdfa 100644
> --- a/fs/hfsplus/dir.c
> +++ b/fs/hfsplus/dir.c
> @@ -78,13 +78,13 @@ static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry,
>  				cpu_to_be32(HFSP_HARDLINK_TYPE) &&
>  				entry.file.user_info.fdCreator ==
>  				cpu_to_be32(HFSP_HFSPLUS_CREATOR) &&
> +				HFSPLUS_SB(sb)->hidden_dir &&
>  				(entry.file.create_date ==
>  					HFSPLUS_I(HFSPLUS_SB(sb)->hidden_dir)->
>  						create_date ||
>  				entry.file.create_date ==
>  					HFSPLUS_I(d_inode(sb->s_root))->
> -						create_date) &&
> -				HFSPLUS_SB(sb)->hidden_dir) {
> +						create_date)) {
>  			struct qstr str;
>  			char name[32];
>  





[Index of Archives]     [Linux Ext4 Filesystem]     [Union Filesystem]     [Filesystem Testing]     [Ceph Users]     [Ecryptfs]     [AutoFS]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux Cachefs]     [Reiser Filesystem]     [Linux RAID]     [Samba]     [Device Mapper]     [CEPH Development]

  Powered by Linux