Fixed possible security problem if cache dir is modified. Only files with md5sum as file name will be considered by the avatar manager.
This commit is contained in:
@@ -317,15 +317,11 @@ AvatarManager::InternalReadDirectory(const std::string &dir, AvatarMap &avatars)
|
|||||||
string md5sum(basename(i->path()));
|
string md5sum(basename(i->path()));
|
||||||
MD5Buf md5buf;
|
MD5Buf md5buf;
|
||||||
string fileName(i->path().file_string());
|
string fileName(i->path().file_string());
|
||||||
bool success = true;
|
if (md5buf.FromString(md5sum))
|
||||||
if (!md5buf.FromString(md5sum))
|
|
||||||
{
|
{
|
||||||
// sigh. File name is not an md5 sum. Calculate on our own...
|
// Only consider files with md5sum as name.
|
||||||
if (!CryptHelper::MD5Sum(fileName, md5buf))
|
|
||||||
success = false;
|
|
||||||
}
|
|
||||||
if (success)
|
|
||||||
avatars.insert(AvatarMap::value_type(md5buf, fileName));
|
avatars.insert(AvatarMap::value_type(md5buf, fileName));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user