Re: [PATCH 5/8] db: validate name and namelen in attr_set_f and attr_remove_f

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

 



On Sat, May 09, 2020 at 07:01:22PM +0200, Christoph Hellwig wrote:
> libxfs has stopped validating these parameters internally, so do it
> in the xfs_db commands.
> 
> Signed-off-by: Christoph Hellwig <hch@xxxxxx>

IIRC the VFS checks these parameters so that libxfs doesn't have to,
right?

If so,
Reviewed-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>

--D

> ---
>  db/attrset.c | 18 ++++++++++++++++++
>  1 file changed, 18 insertions(+)
> 
> diff --git a/db/attrset.c b/db/attrset.c
> index 0a464983..e3575271 100644
> --- a/db/attrset.c
> +++ b/db/attrset.c
> @@ -130,7 +130,16 @@ attr_set_f(
>  	}
>  
>  	args.name = (const unsigned char *)argv[optind];
> +	if (!args.name) {
> +		dbprintf(_("invalid name\n"));
> +		return 0;
> +	}
> +
>  	args.namelen = strlen(argv[optind]);
> +	if (args.namelen >= MAXNAMELEN) {
> +		dbprintf(_("name too long\n"));
> +		return 0;
> +	}
>  
>  	if (args.valuelen) {
>  		args.value = memalign(getpagesize(), args.valuelen);
> @@ -216,7 +225,16 @@ attr_remove_f(
>  	}
>  
>  	args.name = (const unsigned char *)argv[optind];
> +	if (!args.name) {
> +		dbprintf(_("invalid name\n"));
> +		return 0;
> +	}
> +
>  	args.namelen = strlen(argv[optind]);
> +	if (args.namelen >= MAXNAMELEN) {
> +		dbprintf(_("name too long\n"));
> +		return 0;
> +	}
>  
>  	if (libxfs_iget(mp, NULL, iocur_top->ino, 0, &args.dp,
>  			&xfs_default_ifork_ops)) {
> -- 
> 2.26.2
> 



[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux