Re: [PATCH 07/10] mkfs.cramfs: fix unsigned integer overflow [AddressSanitizer]

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

 



On Sun, Nov 30, 2014 at 01:57:39PM +0000, Sami Kerola wrote:
> --- a/disk-utils/mkfs.cramfs.c
> +++ b/disk-utils/mkfs.cramfs.c
> @@ -619,7 +619,10 @@ do_compress(char *base, unsigned int offset, unsigned char const *name,
>  	/* TODO: Arguably, original_size in these 2 lines should be
>  	   st_blocks * 512.  But if you say that, then perhaps
>  	   administrative data should also be included in both. */
> -	change = new_size - original_size;
> +	if (new_size <= original_size)
> +		change = new_size - original_size;
> +	else
> +		change = new_size;

Is it correct?

>  	if (verbose)
>  		printf(_("%6.2f%% (%+ld bytes)\t%s\n"),
>  		       (change * 100) / (double) original_size, change, name);

The verbose message reports difference between old and new size (in
{+,-} bytes) Your patch use complete new_size if this number is bigger
that original_size.

    Karel


-- 
 Karel Zak  <kzak@xxxxxxxxxx>
 http://karelzak.blogspot.com
--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux