qlibrary_unix.cpp: Make adding 'lib' prefix possible even when the file name starts with 'lib'

Loading QLibrary("library_manager") and QLibrary("lib_example") is not
possible if their binaries are called liblibrary_manager.so and
liblib_examplep.so.

Remove this prefix check: if (!prefixes.at(prefix).isEmpty() &&
			      name.startsWith(prefixes.at(prefix))
,in order to allow calling dlopen() with "lib" prefix added to the name
even if the name starts with "lib".

The drawback of removing the check is that extra dlopen() calls will
take place in other cases such as: "libexample.so". In this case we
will have two extra calls of dlopen() taking "liblibexample.so" and
"liblibexample".

Fixes: QTBUG-23470
Pick-to: 6.7 6.5 6.2
Change-Id: I2c0b1b81edf8253443388aa67d24f4cd64d4123d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from commit 2f11edad9e87311a977cb6edbd908a9fdd86a567)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Rym Bouabid 2024-06-14 15:25:26 +02:00 committed by Qt Cherry-pick Bot
parent 7a41956df0
commit d06924baef

View File

@ -185,8 +185,6 @@ bool QLibraryPrivate::load_sys()
Handle hnd = nullptr;
for (int prefix = 0; retry && !hnd && prefix < prefixes.size(); prefix++) {
for (int suffix = 0; retry && !hnd && suffix < suffixes.size(); suffix++) {
if (!prefixes.at(prefix).isEmpty() && name.startsWith(prefixes.at(prefix)))
continue;
if (path.isEmpty() && prefixes.at(prefix).contains(u'/'))
continue;
if (!suffixes.at(suffix).isEmpty() && name.endsWith(suffixes.at(suffix)))