Subject: bug#35714: Parted destroys mbr_signature (Disk Identifier) when adding MBR bootcode

From: Phillip Susi <[email-masked]>
Date: Thu, 16 May 2019 09:13:55 -0400

Matthijs Kooijman writes:

> Hi folks,
>
> I believe I found a bug in the dos partition table writer. Let me start
> with the cause. There's this bit of code:
>
> 	if (!table->boot_code[0]) {
> 		memset (table->boot_code, 0, 512);
> 		memcpy (table->boot_code, MBR_BOOT_CODE, sizeof (MBR_BOOT_CODE));
> 	}

Yikes! Clearly this should have been sizeof( table->boot_code ) rather
than 512.