From dd90367387bd199452f96d105ea09b4e6de5d02f Mon Sep 17 00:00:00 2001 From: vit9696 Date: Sat, 19 May 2018 23:35:57 +0300 Subject: [PATCH] Fix recursion in UEFIReplace --- UEFIReplace/uefireplace.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/UEFIReplace/uefireplace.cpp b/UEFIReplace/uefireplace.cpp index 97eaafb..36978cf 100644 --- a/UEFIReplace/uefireplace.cpp +++ b/UEFIReplace/uefireplace.cpp @@ -84,17 +84,18 @@ UINT8 UEFIReplace::replaceInFile(const QModelIndex & index, const QByteArray & g { if (!model || !index.isValid()) return ERR_INVALID_PARAMETER; + bool patched = false; if (model->subtype(index) == sectionType) { QModelIndex fileIndex = model->findParentOfType(index, Types::File); QByteArray fileGuid = model->header(fileIndex).left(sizeof(EFI_GUID)); - if (fileGuid == guid) { + if (fileGuid == guid && model->action(index) != Actions::Replace) { UINT8 result = ffsEngine->replace(index, newData, REPLACE_MODE_BODY); if (replaceOnce || (result != ERR_SUCCESS && result != ERR_NOTHING_TO_PATCH)) return result; + patched = result == ERR_SUCCESS; } } - bool patched = false; if (model->rowCount(index) > 0) { for (int i = 0; i < model->rowCount(index); i++) { UINT8 result = replaceInFile(index.child(i, 0), guid, sectionType, newData, replaceOnce);