Re: [PATCH 3/3] libfrog: enforce dir XOR blkdev in __fs_table_lookup_mount

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

 



On Tue, Mar 27, 2018 at 05:14:51PM -0500, Eric Sandeen wrote:
> It's not valid to call fs_table_lookup_mount with both
> dir and blkdev set, but one of them must be supplied.
> Doing otherwise is a programming error, so catch it
> with an ASSERT.
> 
> Fixes-coverity-id: 1433615
> Fixes-coverity-id: 1433616
> Signed-off-by: Eric Sandeen <sandeen@xxxxxxxxxx>

Hmmm.... what /is/ the intended behavior if some jerk does
fs_table_lookup_mount(NULL) and both arguments are NULL?  AFAICT the
non-static wrappers will prevent the case where both parameters are
specified.

How about:

if (!dir && !blkdev) {
	ASSERT(0);
	return NULL;
}

just after the variable declarations?

--D

> ---
> 
> diff --git a/libfrog/paths.c b/libfrog/paths.c
> index 318b48f..55cb284 100644
> --- a/libfrog/paths.c
> +++ b/libfrog/paths.c
> @@ -98,6 +98,10 @@ __fs_table_lookup_mount(
>  	char		rpath[PATH_MAX];
>  	char		dpath[PATH_MAX];
>  
> +	/* There can be only one! */
> +	ASSERT(dir || blkdev);
> +	ASSERT(!(dir && blkdev));
> +
>  	if (dir && !realpath(dir, dpath))
>  		return NULL;
>  	if (blkdev && !realpath(blkdev, dpath))
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@xxxxxxxxxxxxxxx
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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