Commit 95eb80d7 authored by Dawit Alemayehu's avatar Dawit Alemayehu
Browse files

Fix logic error that causes a single authentication item to be potentially

stored multiple times and cause a hard to debug crash.

CCBUG:256712
parent a7a26eab
......@@ -813,20 +813,21 @@ KPasswdServer::addAuthInfoItem(const QString &key, const KIO::AuthInfo &info, ql
authList = new AuthInfoContainerList;
m_authDict.insert(key, authList);
}
AuthInfoContainer *current = 0;
Q_FOREACH(current, *authList)
AuthInfoContainer *authItem = 0;
Q_FOREACH(AuthInfoContainer* current, *authList)
{
if (current->info.realmValue == info.realmValue)
{
authList->removeAll(current);
authItem = current;
break;
}
}
if (!current)
if (!authItem)
{
current = new AuthInfoContainer;
current->expire = AuthInfoContainer::expTime;
authItem = new AuthInfoContainer;
authItem->expire = AuthInfoContainer::expTime;
kDebug(debugArea()) << "Creating AuthInfoContainer";
}
else
......@@ -834,15 +835,15 @@ KPasswdServer::addAuthInfoItem(const QString &key, const KIO::AuthInfo &info, ql
kDebug(debugArea()) << "Updating AuthInfoContainer";
}
current->info = info;
current->directory = info.url.directory(KUrl::AppendTrailingSlash|KUrl::ObeyTrailingSlash);
current->seqNr = seqNr;
current->isCanceled = canceled;
authItem->info = info;
authItem->directory = info.url.directory(KUrl::AppendTrailingSlash|KUrl::ObeyTrailingSlash);
authItem->seqNr = seqNr;
authItem->isCanceled = canceled;
updateAuthExpire(key, current, windowId, (info.keepPassword && !canceled));
updateAuthExpire(key, authItem, windowId, (info.keepPassword && !canceled));
// Insert into list, keep the list sorted "longest path" first.
authList->append(current);
authList->append(authItem);
qSort(authList->begin(), authList->end(), AuthInfoContainer::Sorter());
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment