From aa00e8eb623d5cb4ba32860dd3671a87f3763f89 Mon Sep 17 00:00:00 2001 From: Denis Shienkov Date: Mon, 23 Sep 2019 17:10:30 +0300 Subject: Avoid possible symbol clashes on static builds on Windows MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We have same 'resolveSymbols' functions names in the global namespace as in the qtserialport module and as in the qtserialbus module. This can lead to the arbitrary call of this function from a different module that can lead to the crash or other issue (e.g. to this issue QTBUG-78546). So, we can just to rename this function that solves this issue in the future. Change-Id: I25f9d2a33c6858c5194d8c76eefd518eecfb6f7b Reviewed-by: André Hartmann Reviewed-by: Alex Blasche --- src/serialport/qserialport_win.cpp | 2 +- src/serialport/qtntdll_p.h | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/serialport/qserialport_win.cpp b/src/serialport/qserialport_win.cpp index da1e7aa..c0061fc 100644 --- a/src/serialport/qserialport_win.cpp +++ b/src/serialport/qserialport_win.cpp @@ -246,7 +246,7 @@ bool QSerialPortPrivate::open(QIODevice::OpenMode mode) { { QMutexLocker locker(&helper()->mutex); - static bool symbolsResolved = resolveSymbols(&helper()->ntLibrary); + static bool symbolsResolved = resolveNtdllSymbols(&helper()->ntLibrary); if (!symbolsResolved) { setError(QSerialPortErrorInfo(QSerialPort::OpenError, helper()->ntLibrary.errorString())); diff --git a/src/serialport/qtntdll_p.h b/src/serialport/qtntdll_p.h index a8cdaf6..2e57201 100644 --- a/src/serialport/qtntdll_p.h +++ b/src/serialport/qtntdll_p.h @@ -123,14 +123,14 @@ typedef VOID (WINAPI *PIO_APC_ROUTINE) ( static fp_##symbolName symbolName; #define RESOLVE_SYMBOL(symbolName) \ - symbolName = reinterpret_cast(resolveSymbol(ntLibrary, #symbolName)); \ + symbolName = reinterpret_cast(resolveNtdllSymbol(ntLibrary, #symbolName)); \ if (!symbolName) \ return false; GENERATE_SYMBOL_VARIABLE(ULONG, RtlNtStatusToDosError, NTSTATUS) GENERATE_SYMBOL_VARIABLE(NTSTATUS, NtDeviceIoControlFile, HANDLE, HANDLE, PIO_APC_ROUTINE, PVOID, PIO_STATUS_BLOCK, ULONG, PVOID, ULONG, PVOID, ULONG) -inline QFunctionPointer resolveSymbol(QLibrary *ntLibrary, const char *symbolName) +inline QFunctionPointer resolveNtdllSymbol(QLibrary *ntLibrary, const char *symbolName) { QFunctionPointer symbolFunctionPointer = ntLibrary->resolve(symbolName); if (!symbolFunctionPointer) @@ -139,7 +139,7 @@ inline QFunctionPointer resolveSymbol(QLibrary *ntLibrary, const char *symbolNam return symbolFunctionPointer; } -inline bool resolveSymbols(QLibrary *ntLibrary) +inline bool resolveNtdllSymbols(QLibrary *ntLibrary) { if (!ntLibrary->isLoaded()) { ntLibrary->setFileName(QStringLiteral("ntdll")); -- cgit v1.2.1