Add support for Clang sanitizers for UEFITool

Only applied to CMake Debug builds, useful for debugging undefined behavior.
This commit is contained in:
Nikolaj Schlej 2023-01-31 17:45:29 -08:00
parent 2467b48802
commit b649b98cb5
5 changed files with 29 additions and 10 deletions

View File

@ -39,7 +39,7 @@ jobs:
- name: Upload to releases - name: Upload to releases
if: github.event_name == 'release' if: github.event_name == 'release'
uses: svenstaro/upload-release-action@e74ff71f7d8a4c4745b560a485cc5fdb9b5b999d uses: svenstaro/upload-release-action@v2
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*.zip file: dist/*.zip
@ -68,7 +68,7 @@ jobs:
- name: Upload to releases - name: Upload to releases
if: github.event_name == 'release' if: github.event_name == 'release'
uses: svenstaro/upload-release-action@e74ff71f7d8a4c4745b560a485cc5fdb9b5b999d uses: svenstaro/upload-release-action@v2
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*.zip file: dist/*.zip
@ -116,7 +116,7 @@ jobs:
- name: Upload to releases - name: Upload to releases
if: github.event_name == 'release' if: github.event_name == 'release'
uses: svenstaro/upload-release-action@e74ff71f7d8a4c4745b560a485cc5fdb9b5b999d uses: svenstaro/upload-release-action@v2
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*.zip file: dist/*.zip
@ -215,7 +215,7 @@ jobs:
- name: Upload to releases - name: Upload to releases
if: github.event_name == 'release' if: github.event_name == 'release'
uses: svenstaro/upload-release-action@e74ff71f7d8a4c4745b560a485cc5fdb9b5b999d uses: svenstaro/upload-release-action@v2
with: with:
repo_token: ${{ secrets.GITHUB_TOKEN }} repo_token: ${{ secrets.GITHUB_TOKEN }}
file: dist/*.zip file: dist/*.zip
@ -344,8 +344,9 @@ jobs:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 11 - name: Set up JDK 11
uses: actions/setup-java@v1 uses: actions/setup-java@v3
with: with:
distribution: 'zulu'
java-version: 11 java-version: 11
- name: Download and set up sonar-scanner - name: Download and set up sonar-scanner

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.16) CMAKE_MINIMUM_REQUIRED(VERSION 3.22)
PROJECT(UEFITool_everything) PROJECT(UEFITool_everything)

View File

@ -1,4 +1,4 @@
CMAKE_MINIMUM_REQUIRED(VERSION 3.16) CMAKE_MINIMUM_REQUIRED(VERSION 3.22)
PROJECT(UEFITool LANGUAGES C CXX) PROJECT(UEFITool LANGUAGES C CXX)
@ -8,6 +8,24 @@ SET(CMAKE_CXX_EXTENSIONS OFF)
FIND_PACKAGE(Qt6 REQUIRED COMPONENTS Widgets) FIND_PACKAGE(Qt6 REQUIRED COMPONENTS Widgets)
IF (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Enable sanitizers for debug builds done by Clang
IF(CMAKE_BUILD_TYPE MATCHES Debug)
MESSAGE("-- Clang sanitizers enabled")
ADD_COMPILE_OPTIONS(-fsanitize=undefined)
ADD_COMPILE_OPTIONS(-fsanitize=integer)
ADD_COMPILE_OPTIONS(-fsanitize=nullability)
ADD_COMPILE_OPTIONS(-fsanitize=implicit-conversion)
ADD_COMPILE_OPTIONS(-fsanitize=array-bounds)
ADD_COMPILE_OPTIONS(-fno-omit-frame-pointer)
ADD_LINK_OPTIONS(-fsanitize=integer)
ADD_LINK_OPTIONS(-fsanitize=nullability)
ADD_LINK_OPTIONS(-fsanitize=implicit-conversion)
ADD_LINK_OPTIONS(-fsanitize=array-bounds)
ADD_LINK_OPTIONS(-fno-omit-frame-pointer)
ENDIF()
ENDIF()
SET(PROJECT_FORMS SET(PROJECT_FORMS
uefitool.ui uefitool.ui
searchdialog.ui searchdialog.ui

View File

@ -580,7 +580,7 @@ void UEFITool::remove()
void UEFITool::about() void UEFITool::about()
{ {
QMessageBox::about(this, tr("About UEFITool"), QMessageBox::about(this, tr("About UEFITool"),
tr("Copyright (c) 2013-2022, Nikolaj Schlej.<br><br>" tr("Copyright (c) 2013-2023, Nikolaj Schlej.<br><br>"
"Program icon made by <a href=https://www.behance.net/alzhidkov>Alexander Zhidkov</a>.<br><br>" "Program icon made by <a href=https://www.behance.net/alzhidkov>Alexander Zhidkov</a>.<br><br>"
"GUI uses QHexEdit2 library made by <a href=https://github.com/Simsys>Simsys</a>.<br>" "GUI uses QHexEdit2 library made by <a href=https://github.com/Simsys>Simsys</a>.<br>"
"Qt-less engine uses Bstrlib made by <a href=https://github.com/websnarf>Paul Hsieh</a>.<br>" "Qt-less engine uses Bstrlib made by <a href=https://github.com/websnarf>Paul Hsieh</a>.<br>"

View File

@ -472,7 +472,7 @@ INTN findPattern(const UINT8 *pattern, const UINT8 *patternMask, UINTN patternSi
bool matches = true; bool matches = true;
for (UINTN i = 0; i < patternSize; i++) { for (UINTN i = 0; i < patternSize; i++) {
if ((data[dataOff + i] & patternMask[i]) != pattern[i]) { if ((data[dataOff + i] & patternMask[i]) != pattern[i]) {
matches = true; matches = false;
break; break;
} }
} }
@ -583,4 +583,4 @@ USTATUS zlibDecompress(const UByteArray& input, UByteArray& output)
inflateEnd(&stream); inflateEnd(&stream);
return ret == Z_STREAM_END ? U_SUCCESS : U_ZLIB_DECOMPRESSION_FAILED; return ret == Z_STREAM_END ? U_SUCCESS : U_ZLIB_DECOMPRESSION_FAILED;
} }