This is an automated email from the git hooks/post-receive script.
pierov pushed a commit to branch tor-browser-91.10.0esr-11.5-1 in repository tor-browser.
The following commit(s) were added to refs/heads/tor-browser-91.10.0esr-11.5-1 by this push: new f5b70adbf5b73 fixup! Bug 40458: Implement .tor.onion aliases f5b70adbf5b73 is described below
commit f5b70adbf5b73e7e896ec49255b83bae00f8edd9 Author: Pier Angelo Vendrame pierov@torproject.org AuthorDate: Tue Jun 21 19:33:07 2022 +0200
fixup! Bug 40458: Implement .tor.onion aliases
Bug 41035: OnionAliasService should use threadsafe ISupports --- netwerk/dns/OnionAliasService.cpp | 7 +++++-- netwerk/dns/OnionAliasService.h | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/netwerk/dns/OnionAliasService.cpp b/netwerk/dns/OnionAliasService.cpp index 2d24bb68023b4..5140f4fe0d833 100644 --- a/netwerk/dns/OnionAliasService.cpp +++ b/netwerk/dns/OnionAliasService.cpp @@ -65,7 +65,7 @@ OnionAliasService::AddOnionAlias(const nsACString& aShortHostname, !ValidateOnionV3(*longHostname)) { return NS_ERROR_INVALID_ARG; } - mozilla::MutexAutoLock lock(mLock); + mozilla::AutoWriteLock lock(mLock); mOnionAliases.InsertOrUpdate(shortHostname, std::move(longHostname)); return NS_OK; } @@ -76,6 +76,9 @@ OnionAliasService::GetOnionAlias(const nsACString& aShortHostname, nsACString& a aLongHostname = aShortHostname; if (StringEndsWith(aShortHostname, ".tor.onion"_ns)) { nsAutoCString* alias = nullptr; + // We want to keep the string stored in the map alive at least until we + // finish to copy it to the output parameter. + mozilla::AutoReadLock lock(mLock); if (mOnionAliases.Get(aShortHostname, &alias)) { // We take for granted aliases have already been validated aLongHostname.Assign(*alias); @@ -86,7 +89,7 @@ OnionAliasService::GetOnionAlias(const nsACString& aShortHostname, nsACString& a
NS_IMETHODIMP OnionAliasService::ClearOnionAliases() { - mozilla::MutexAutoLock lock(mLock); + mozilla::AutoWriteLock lock(mLock); mOnionAliases.Clear(); return NS_OK; } diff --git a/netwerk/dns/OnionAliasService.h b/netwerk/dns/OnionAliasService.h index 913157e61ccb6..5f72d295018e8 100644 --- a/netwerk/dns/OnionAliasService.h +++ b/netwerk/dns/OnionAliasService.h @@ -8,7 +8,7 @@ namespace torproject {
class OnionAliasService final : public IOnionAliasService { public: - NS_DECL_ISUPPORTS + NS_DECL_THREADSAFE_ISUPPORTS NS_DECL_IONIONALIASSERVICE
static already_AddRefed<IOnionAliasService> GetSingleton(); @@ -23,7 +23,7 @@ private: virtual ~OnionAliasService() = default;
// mLock protects access to mOnionAliases - mozilla::Mutex mLock{"OnionAliasService.mLock"}; + mozilla::RWLock mLock{"OnionAliasService.mLock"};
// AutoCStrings have a 64 byte buffer, so it is advised not to use them for // long storage. However, it is enough to contain onion addresses, so we use
tor-commits@lists.torproject.org