Ensure that we load system libraries from the correct location.
authorJan-Arve Sæther <jan-arve.saether@nokia.com>
Tue, 31 Aug 2010 08:23:30 +0000 (10:23 +0200)
committerJan-Arve Sæther <jan-arve.saether@nokia.com>
Fri, 3 Sep 2010 08:22:25 +0000 (10:22 +0200)
commit5738dcd705e7edde816940f9c0ab2c364c81ad20
treee6be0a4b0f11289a7f0e8f6b4d4cce1de28aee8e
parentdac9e5dd5644d29d6a8dde752e7c594727f16661
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
28 files changed:
qmake/Makefile.win32
qmake/qmake.pri
src/activeqt/shared/qaxtypes.cpp
src/corelib/io/qfsfileengine_win.cpp
src/corelib/io/qsettings.cpp
src/corelib/kernel/qeventdispatcher_win.cpp
src/corelib/plugin/plugin.pri
src/corelib/plugin/qsystemlibrary.cpp [new file with mode: 0644]
src/corelib/plugin/qsystemlibrary_p.h [new file with mode: 0644]
src/gui/accessible/qaccessible_win.cpp
src/gui/dialogs/qfiledialog_win.cpp
src/gui/dialogs/qwizard_win.cpp
src/gui/kernel/qapplication_win.cpp
src/gui/kernel/qdesktopwidget_win.cpp
src/gui/kernel/qwidget_win.cpp
src/gui/styles/qwindowsstyle.cpp
src/gui/styles/qwindowsvistastyle.cpp
src/gui/styles/qwindowsxpstyle.cpp
src/gui/text/qfontdatabase_win.cpp
src/gui/text/qfontengine_win.cpp
src/gui/util/qdesktopservices_win.cpp
src/gui/util/qsystemtrayicon_win.cpp
src/network/kernel/qhostinfo_win.cpp
src/network/kernel/qnetworkinterface_win.cpp
src/network/kernel/qnetworkproxy_win.cpp
src/network/ssl/qsslsocket_openssl_symbols.cpp
src/qt3support/network/q3dns.cpp
src/tools/bootstrap/bootstrap.pro