summaryrefslogtreecommitdiff
path: root/src/network/kernel/qauthenticator.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/network/kernel/qauthenticator.cpp')
-rw-r--r--src/network/kernel/qauthenticator.cpp24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/network/kernel/qauthenticator.cpp b/src/network/kernel/qauthenticator.cpp
index f97d833bd5..73f6b94ef1 100644
--- a/src/network/kernel/qauthenticator.cpp
+++ b/src/network/kernel/qauthenticator.cpp
@@ -164,9 +164,13 @@ QAuthenticator &QAuthenticator::operator=(const QAuthenticator &other)
{
if (d == other.d)
return *this;
- detach();
- d->user = other.d->user;
- d->password = other.d->password;
+
+ if (d && !d->ref.deref())
+ delete d;
+
+ d = other.d;
+ if (d)
+ d->ref.ref();
return *this;
}
@@ -232,19 +236,21 @@ void QAuthenticator::setUser(const QString &user)
//domain name is present
d->realm.clear();
d->userDomain = user.left(separatorPosn);
- d->user = user.mid(separatorPosn + 1);
+ d->extractedUser = user.mid(separatorPosn + 1);
+ d->user = user;
} else if((separatorPosn = user.indexOf(QLatin1String("@"))) != -1) {
//domain name is present
d->realm.clear();
d->userDomain = user.left(separatorPosn);
- d->user = user.left(separatorPosn);
+ d->extractedUser = user.left(separatorPosn);
+ d->user = user;
} else {
+ d->extractedUser = user;
d->user = user;
d->realm.clear();
d->userDomain.clear();
}
break;
- // For other auth mechanisms, domain name will be part of username
default:
d->user = user;
break;
@@ -1196,7 +1202,7 @@ static QByteArray qCreatev2Hash(const QAuthenticatorPrivate *ctx,
Q_ASSERT(hashKey.size() == 16);
// Assuming the user and domain is always unicode in challenge
QByteArray message =
- qStringAsUcs2Le(ctx->user.toUpper()) +
+ qStringAsUcs2Le(ctx->extractedUser.toUpper()) +
qStringAsUcs2Le(phase3->domainStr);
phase3->v2Hash = qEncodeHmacMd5(hashKey, message);
@@ -1401,8 +1407,8 @@ static QByteArray qNtlmPhase3(QAuthenticatorPrivate *ctx, const QByteArray& phas
pb.domainStr = ctx->userDomain;
}
- offset = qEncodeNtlmString(pb.user, offset, ctx->user, unicode);
- pb.userStr = ctx->user;
+ offset = qEncodeNtlmString(pb.user, offset, ctx->extractedUser, unicode);
+ pb.userStr = ctx->extractedUser;
offset = qEncodeNtlmString(pb.workstation, offset, ctx->workstation, unicode);
pb.workstationStr = ctx->workstation;