[parted-devel] [PATCH v3] dos: improve MBR signature generation

Brian C. Lane bcl at redhat.com
Tue Oct 1 23:27:05 UTC 2013


On Wed, Oct 02, 2013 at 01:00:43AM +1000, Jonathan Liu wrote:
> +/* hack: use the ext2 uuid library to generate a reasonably random (hopefully
> + * with /dev/random) number.  Unfortunately, we can only use 4 bytes of it.
> + * We make sure to avoid returning zero which may be interpreted as no FAT
> + * serial number or no MBR signature.
> + */
> +static inline uint32_t
> +generate_random_uint32 (void)
> +{
> +	union {
> +		uuid_t uuid;
> +		uint32_t i;
> +	} uu32;
> +
> +	do {
> +		uuid_generate (uu32.uuid);
> +	} while (uu32.i == 0);

I'd like to see a limit on this while with an error if it gets a zero
more than 3 times in a row.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 482 bytes
Desc: not available
URL: <http://lists.alioth.debian.org/pipermail/parted-devel/attachments/20131001/aeab9bbb/attachment.sig>


More information about the parted-devel mailing list