diff options
author | Michele Calgaro <michele.calgaro@yahoo.it> | 2018-11-27 14:55:23 +0900 |
---|---|---|
committer | Michele Calgaro <michele.calgaro@yahoo.it> | 2018-11-27 14:55:23 +0900 |
commit | 6ec26d859be239e6db1bb392140db76227a56522 (patch) | |
tree | 1cae6e9ff2c6537c9454113f54a20b123f3921d1 /tdeio | |
parent | 82afa07a430c43bc122c7325dc67fb9f3ad6216a (diff) | |
download | tdelibs-6ec26d859be239e6db1bb392140db76227a56522.tar.gz tdelibs-6ec26d859be239e6db1bb392140db76227a56522.zip |
KPasswordEdit::password() now returns a TQString instead of a const char *. This relates to bug 2961.
Signed-off-by: Michele Calgaro <michele.calgaro@yahoo.it>
Diffstat (limited to 'tdeio')
-rw-r--r-- | tdeio/kssl/ksslpemcallback.cc | 17 | ||||
-rw-r--r-- | tdeio/misc/tdewalletd/tdewalletd.cpp | 14 |
2 files changed, 14 insertions, 17 deletions
diff --git a/tdeio/kssl/ksslpemcallback.cc b/tdeio/kssl/ksslpemcallback.cc index 207949a0c..584020c0f 100644 --- a/tdeio/kssl/ksslpemcallback.cc +++ b/tdeio/kssl/ksslpemcallback.cc @@ -28,26 +28,23 @@ int KSSLPemCallback(char *buf, int size, int rwflag, void *userdata) { #ifdef KSSL_HAVE_SSL - TQCString pass; + TQString pass2; Q_UNUSED(userdata); Q_UNUSED(rwflag); if (!buf) return -1; - int rc = KPasswordDialog::getPassword(pass, i18n("Certificate password")); + int rc = KPasswordDialog::getPassword(pass2, i18n("Certificate password")); if (rc != KPasswordDialog::Accepted) return -1; + TQCString pass = pass2.utf8(); // utf8 length may differ from TQString length const uint passlen = pass.length(); if (passlen > (unsigned int)size-1) pass.truncate((unsigned int)size-1); - tqstrncpy(buf, pass.data(), size-1); - - for (unsigned int i = 0; i < passlen; i++) - pass[i] = 0; - // To be sure that it doesn't optimise the previous loop away - for (unsigned int i = 0; i < passlen; i++) - pass[i] = pass[i]; - buf[size-1] = 0; + tqstrncpy(buf, pass, size-1); + buf[size-1] = 0; + pass.fill(' '); + pass2.fill(' '); return (int)passlen; #else Q_UNUSED(buf); diff --git a/tdeio/misc/tdewalletd/tdewalletd.cpp b/tdeio/misc/tdewalletd/tdewalletd.cpp index 5d73df4e6..97e942c3a 100644 --- a/tdeio/misc/tdewalletd/tdewalletd.cpp +++ b/tdeio/misc/tdewalletd/tdewalletd.cpp @@ -471,13 +471,13 @@ int TDEWalletD::internalOpen(const TQCString& appid, const TQString& wallet, boo kpd->setAllowEmptyPasswords(true); } - const char *p = 0L; + TQCString p; while (!b->isOpen()) { assert(kpd); // kpd can't be null if isOpen() is false setupDialog( kpd, w, appid, modal ); if (kpd->exec() == KDialog::Accepted) { - p = kpd->password(); - int rc = b->open(TQByteArray().duplicate(p, strlen(p))); + p = kpd->password().utf8(); + int rc = b->open(TQByteArray().duplicate(p)); if (!b->isOpen()) { kpd->setPrompt(i18n("<qt>Error opening the wallet '<b>%1</b>'. Please try again.<br>(Error code %2: %3)").arg(TQStyleSheet::escape(wallet)).arg(rc).arg(TDEWallet::Backend::openRCToString(rc))); kpd->clearPassword(); @@ -487,7 +487,7 @@ int TDEWalletD::internalOpen(const TQCString& appid, const TQString& wallet, boo } } - if (!emptyPass && (!p || !b->isOpen())) { + if (!emptyPass && (p.isEmpty() || !b->isOpen())) { delete b; delete kpd; return -1; @@ -662,11 +662,11 @@ void TDEWalletD::doTransactionChangePassword(const TQCString& appid, const TQStr kpd->setAllowEmptyPasswords(true); setupDialog( kpd, wId, appid, false ); if (kpd->exec() == KDialog::Accepted) { - const char *p = kpd->password(); - if (p) { + TQCString p = kpd->password().utf8(); + if (!p.isEmpty()) { _passwords[wallet] = p; TQByteArray pa; - pa.duplicate(p, strlen(p)); + pa.duplicate(p); int rc = w->close(pa); if (rc < 0) { KMessageBox::sorryWId(wId, i18n("Error re-encrypting the wallet. Password was not changed."), i18n("TDE Wallet Service")); |