[PATCH 03/11] xfsprogs: mkfs: fix unintentional integer overflow

Eric Sandeen sandeen at sandeen.net
Wed Dec 2 21:34:40 CST 2015


I don't think it's possible for blocklog to be large enough to overflow,
but I suppose being defensive is fine.

Coverity-Id: 996962
Reviewed-by: Eric Sandeen <sandeen at redhat.com>

On 12/2/15 5:19 AM, Vivek Trivedi wrote:
> Fix unintentional integer overflow  in mkfs.
> Reported by coverity.
> 
> Signed-off-by: Vivek Trivedi <t.vivek at samsung.com>
> ---
>  mkfs/xfs_mkfs.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/mkfs/xfs_mkfs.c b/mkfs/xfs_mkfs.c
> index 7cba41a..e540c48 100644
> --- a/mkfs/xfs_mkfs.c
> +++ b/mkfs/xfs_mkfs.c
> @@ -2033,7 +2033,7 @@ _("warning: sparse inodes not supported without CRC support, disabled.\n"));
>  		/* check that rswidth is a multiple of fs blocksize */
>  		if (!norsflag && rswidth && !(BBTOB(rswidth) % blocksize)) {
>  			rswidth = DTOBT(rswidth);
> -			rtextbytes = rswidth << blocklog;
> +			rtextbytes = (__uint64_t)rswidth << blocklog;
>  			if (XFS_MIN_RTEXTSIZE <= rtextbytes &&
>  			    (rtextbytes <= XFS_MAX_RTEXTSIZE)) {
>  				rtextblocks = rswidth;
> 



More information about the xfs mailing list