diff --git a/lib/func.cpp b/lib/func.cpp index 6ce5ff1b..795173ea 100644 --- a/lib/func.cpp +++ b/lib/func.cpp @@ -194,8 +194,8 @@ QString relativePath(QString path) QFileInfo fi_path(path); QFileInfo fi_home(getHomeDir()); - QString prefix = fi_home.canonicalFilePath(); - path = fi_path.canonicalFilePath(); + QString prefix = fi_home.absoluteFilePath(); + path = fi_path.absoluteFilePath(); if (portable_app()) { if (path.startsWith(prefix)) diff --git a/lib/pkcs11_lib.cpp b/lib/pkcs11_lib.cpp index 1e053f18..c1fa7657 100644 --- a/lib/pkcs11_lib.cpp +++ b/lib/pkcs11_lib.cpp @@ -52,6 +52,7 @@ pkcs11_lib::pkcs11_lib(const QString &f) CK_RV rv; file = name2File(f, &enabled); p11 = NULL; + dl_handle = NULL; if (!enabled) return; @@ -59,7 +60,14 @@ pkcs11_lib::pkcs11_lib(const QString &f) lt_dlinit(); try { - dl_handle = lt_dlopen(find_filecodec(file)); + /* PKCS11 libs without path should be looked up locally */ + QString realfile = file; + if (!realfile.contains("/") && !realfile.isEmpty()) + realfile.prepend("./"); + QByteArray localfn = find_filecodec(realfile); + if (localfn.isEmpty()) + throw errorEx(QObject::tr("Invalid filename: %1").arg(file)); + dl_handle = lt_dlopen(localfn); if (dl_handle == NULL) throw errorEx(QObject::tr("Failed to open PKCS11 library: %1: %2").arg(file).arg(lt_dlerror()));