Re: [PATCH 41/36] xfs_repair: better cli option parameter checking

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

 



On 3/20/19 2:36 PM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@xxxxxxxxxx>
> 
> For the xfs_repair options that require a parameter, check that the user
> actually provided one instead of segfaulting.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@xxxxxxxxxx>

looks good, but, uh, neither 

-c lazycount=
nor
-o phase2_threads=

is documented in the man page.  :(

Reviewed-by: Eric Sandeen <sandeen@xxxxxxxxxx>

> ---
>  repair/xfs_repair.c |   12 ++++++++++++
>  1 file changed, 12 insertions(+)
> 
> diff --git a/repair/xfs_repair.c b/repair/xfs_repair.c
> index 2d333d50..9657503f 100644
> --- a/repair/xfs_repair.c
> +++ b/repair/xfs_repair.c
> @@ -233,10 +233,16 @@ process_args(int argc, char **argv)
>  					if (max_mem_specified)
>  						do_abort(
>  		_("-o bhash option cannot be used with -m option\n"));
> +					if (!val)
> +						do_abort(
> +		_("-o bhash requires a parameter\n"));
>  					libxfs_bhash_size = (int)strtol(val, NULL, 0);
>  					bhash_option_used = 1;
>  					break;
>  				case AG_STRIDE:
> +					if (!val)
> +						do_abort(
> +		_("-o ag_stride requires a parameter\n"));
>  					ag_stride = (int)strtol(val, NULL, 0);
>  					break;
>  				case FORCE_GEO:
> @@ -247,6 +253,9 @@ process_args(int argc, char **argv)
>  					force_geo = 1;
>  					break;
>  				case PHASE2_THREADS:
> +					if (!val)
> +						do_abort(
> +		_("-o phase2_threads requires a parameter\n"));
>  					phase2_threads = (int)strtol(val, NULL, 0);
>  					break;
>  				default:
> @@ -262,6 +271,9 @@ process_args(int argc, char **argv)
>  
>  				switch (getsubopt(&p, c_opts, &val)) {
>  				case CONVERT_LAZY_COUNT:
> +					if (!val)
> +						do_abort(
> +		_("-c lazycount requires a parameter\n"));
>  					lazy_count = (int)strtol(val, NULL, 0);
>  					convert_lazy_count = 1;
>  					break;
> 



[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