summaryrefslogtreecommitdiffstats
path: root/src/gui/text
diff options
context:
space:
mode:
authorJan-Arve Sæther <jan-arve.saether@nokia.com>2010-08-31 08:23:30 (GMT)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>2010-09-03 08:22:25 (GMT)
commit5738dcd705e7edde816940f9c0ab2c364c81ad20 (patch)
treee6be0a4b0f11289a7f0e8f6b4d4cce1de28aee8e /src/gui/text
parentdac9e5dd5644d29d6a8dde752e7c594727f16661 (diff)
downloadQt-5738dcd705e7edde816940f9c0ab2c364c81ad20.zip
Qt-5738dcd705e7edde816940f9c0ab2c364c81ad20.tar.gz
Qt-5738dcd705e7edde816940f9c0ab2c364c81ad20.tar.bz2
Ensure that we load system libraries from the correct location.
This was a security hole that has been there for a while, but the public awareness have recently rised so the threat is more imminent now. The solution is to fix all places where we dynamically load system libraries. More specifically, we now load all system libraries with an absolute path that points to a library in the system directory (usually c:\windows\system32). We therefore introduce a small class named QSystemLibrary that only loads libraries located in the system path. This shares some of the API with QLibrary (in order to make the patch as small as possible). We don't fix QLibrary due to risk of regressions. In addition, applications can fix the code that calls QLibrary themselves. The problem does not apply to Windows CE, since the search order is documented as not searching in the current directory. However, it touches some CE-specific code - therefore QSystemLibrary is sometimes used on WinCE (however, it will just do a normal LoadLibrary() since its safe anyway). This change does not affect the testability plugin (it is not clearly documented where that plugin is located, and the plugin should never be used in production code anyway) Loading OpenSSL libraries The ssl libraries are handled specially, and searched in this order (we cannot expect them to always be in the system folder): 1. Application path 2. System libraries path 3. Trying all paths inside the PATH environment variable Task-number: QT-3825 Reviewed-by: Thiago Macieira Reviewed-by: Peter Hartmann
Diffstat (limited to 'src/gui/text')
-rw-r--r--src/gui/text/qfontdatabase_win.cpp10
-rw-r--r--src/gui/text/qfontengine_win.cpp4
2 files changed, 7 insertions, 7 deletions
diff --git a/src/gui/text/qfontdatabase_win.cpp b/src/gui/text/qfontdatabase_win.cpp
index a6ceee1..160b139 100644
--- a/src/gui/text/qfontdatabase_win.cpp
+++ b/src/gui/text/qfontdatabase_win.cpp
@@ -45,7 +45,7 @@
#include "qfont_p.h"
#include "qfontengine_p.h"
#include "qpaintdevice.h"
-#include "qlibrary.h"
+#include <private/qsystemlibrary_p.h>
#include "qabstractfileengine.h"
#include "qendian.h"
@@ -1049,7 +1049,7 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
{
if(!fnt->data.isEmpty()) {
#ifndef Q_OS_WINCE
- PtrAddFontMemResourceEx ptrAddFontMemResourceEx = (PtrAddFontMemResourceEx)QLibrary::resolve(QLatin1String("gdi32"),
+ PtrAddFontMemResourceEx ptrAddFontMemResourceEx = (PtrAddFontMemResourceEx)QSystemLibrary::resolve(QLatin1String("gdi32"),
"AddFontMemResourceEx");
if (!ptrAddFontMemResourceEx)
return;
@@ -1112,7 +1112,7 @@ static void registerFont(QFontDatabasePrivate::ApplicationFont *fnt)
return;
#else
// supported from 2000 on, so no need to deal with the *A variant
- PtrAddFontResourceExW ptrAddFontResourceExW = (PtrAddFontResourceExW)QLibrary::resolve(QLatin1String("gdi32"),
+ PtrAddFontResourceExW ptrAddFontResourceExW = (PtrAddFontResourceExW)QSystemLibrary::resolve(QLatin1String("gdi32"),
"AddFontResourceExW");
if (!ptrAddFontResourceExW
|| ptrAddFontResourceExW((wchar_t*)fnt->fileName.utf16(), FR_PRIVATE, 0) == 0)
@@ -1141,7 +1141,7 @@ bool QFontDatabase::removeApplicationFont(int handle)
if (!removeSucceeded)
return false;
#else
- PtrRemoveFontMemResourceEx ptrRemoveFontMemResourceEx = (PtrRemoveFontMemResourceEx)QLibrary::resolve(QLatin1String("gdi32"),
+ PtrRemoveFontMemResourceEx ptrRemoveFontMemResourceEx = (PtrRemoveFontMemResourceEx)QSystemLibrary::resolve(QLatin1String("gdi32"),
"RemoveFontMemResourceEx");
if (!ptrRemoveFontMemResourceEx
|| !ptrRemoveFontMemResourceEx(font.handle))
@@ -1152,7 +1152,7 @@ bool QFontDatabase::removeApplicationFont(int handle)
if (!RemoveFontResource((LPCWSTR)font.fileName.utf16()))
return false;
#else
- PtrRemoveFontResourceExW ptrRemoveFontResourceExW = (PtrRemoveFontResourceExW)QLibrary::resolve(QLatin1String("gdi32"),
+ PtrRemoveFontResourceExW ptrRemoveFontResourceExW = (PtrRemoveFontResourceExW)QSystemLibrary::resolve(QLatin1String("gdi32"),
"RemoveFontResourceExW");
if (!ptrRemoveFontResourceExW
|| !ptrRemoveFontResourceExW((LPCWSTR)font.fileName.utf16(), FR_PRIVATE, 0))
diff --git a/src/gui/text/qfontengine_win.cpp b/src/gui/text/qfontengine_win.cpp
index eea196e..be90f1c 100644
--- a/src/gui/text/qfontengine_win.cpp
+++ b/src/gui/text/qfontengine_win.cpp
@@ -50,7 +50,7 @@
#include "qt_windows.h"
#include <private/qapplication_p.h>
-#include <qlibrary.h>
+#include <private/qsystemlibrary_p.h>
#include <qpaintdevice.h>
#include <qpainter.h>
#include <limits.h>
@@ -140,7 +140,7 @@ static void resolveGetCharWidthI()
if (resolvedGetCharWidthI)
return;
resolvedGetCharWidthI = true;
- ptrGetCharWidthI = (PtrGetCharWidthI)QLibrary::resolve(QLatin1String("gdi32"), "GetCharWidthI");
+ ptrGetCharWidthI = (PtrGetCharWidthI)QSystemLibrary::resolve(QLatin1String("gdi32"), "GetCharWidthI");
}
#endif // !defined(Q_WS_WINCE)