Fix GPT signature test

gpt.Signature is not a null-terminated string, but an 8-byte character array. Using `strcmp` will not provide a valid result. Use `strncmp` over the first 8 bytes instead.

Signed-off-by: Jason Kridner <jkridner@beagleboard.org>
This commit is contained in:
Jason Kridner 2024-07-16 18:30:18 -04:00 committed by Tom Dewey
parent 686ad14308
commit c1c8c5a7dd

View file

@ -166,7 +166,7 @@ DeviceWrapperFatPartition *DeviceWrapper::fatPartition(int nr)
struct gpt_partition gptpart;
pread((char *) &gpt, sizeof(gpt), 512);
if (!strcmp("EFI PART", gpt.Signature) && gpt.MyLBA == 1)
if (!strncmp("EFI PART", gpt.Signature, 8) && gpt.MyLBA == 1)
{
qDebug() << "Using GPT partition table";
if (nr > gpt.NumberOfPartitionEntries)