From c1c8c5a7dd1c5b433a9cb33df9b8989c55ccc9a8 Mon Sep 17 00:00:00 2001 From: Jason Kridner Date: Tue, 16 Jul 2024 18:30:18 -0400 Subject: [PATCH] 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 --- src/devicewrapper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/devicewrapper.cpp b/src/devicewrapper.cpp index 9a39454..2bf1faf 100644 --- a/src/devicewrapper.cpp +++ b/src/devicewrapper.cpp @@ -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)