summaryrefslogtreecommitdiffstats
path: root/netwerk/protocol/http
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@gmail.com>2018-09-27 00:54:34 +0200
committerGitHub <noreply@github.com>2018-09-27 00:54:34 +0200
commit63875408947b0e5551f41e4de1e0ca44dd970c36 (patch)
treebb7666d331f2d67d9e77f9cae5937224f2777be5 /netwerk/protocol/http
parenta549e0c4a3aceedacd3bd70f9df9629cac57f0c4 (diff)
parent475a210a336da603f308d9163e3922b7cc285e0b (diff)
downloadUXP-63875408947b0e5551f41e4de1e0ca44dd970c36.tar
UXP-63875408947b0e5551f41e4de1e0ca44dd970c36.tar.gz
UXP-63875408947b0e5551f41e4de1e0ca44dd970c36.tar.lz
UXP-63875408947b0e5551f41e4de1e0ca44dd970c36.tar.xz
UXP-63875408947b0e5551f41e4de1e0ca44dd970c36.zip
Merge pull request #789 from g4jc/sha256_leakfix
backport mozbug 1444532 - fix a leak in SHA256 in nsHttpConnectionInfo.cpp r=mayhemer
Diffstat (limited to 'netwerk/protocol/http')
-rw-r--r--netwerk/protocol/http/nsHttpConnectionInfo.cpp22
1 files changed, 8 insertions, 14 deletions
diff --git a/netwerk/protocol/http/nsHttpConnectionInfo.cpp b/netwerk/protocol/http/nsHttpConnectionInfo.cpp
index e965fd1cc..93a40843c 100644
--- a/netwerk/protocol/http/nsHttpConnectionInfo.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionInfo.cpp
@@ -15,32 +15,26 @@
#include "nsHttpConnectionInfo.h"
#include "mozilla/net/DNS.h"
-#include "prnetdb.h"
-#include "nsICryptoHash.h"
#include "nsComponentManagerUtils.h"
+#include "nsICryptoHash.h"
#include "nsIProtocolProxyService.h"
+#include "nsNetCID.h"
+#include "prnetdb.h"
static nsresult
SHA256(const char* aPlainText, nsAutoCString& aResult)
{
- static nsICryptoHash* hasher = nullptr;
nsresult rv;
- if (!hasher) {
- rv = CallCreateInstance("@mozilla.org/security/hash;1", &hasher);
- if (NS_FAILED(rv)) {
- LOG(("nsHttpDigestAuth: no crypto hash!\n"));
- return rv;
- }
+ nsCOMPtr<nsICryptoHash> hasher = do_CreateInstance(NS_CRYPTO_HASH_CONTRACTID, &rv);
+ if (NS_FAILED(rv)) {
+ LOG(("nsHttpDigestAuth: no crypto hash!\n"));
+ return rv;
}
-
rv = hasher->Init(nsICryptoHash::SHA256);
NS_ENSURE_SUCCESS(rv, rv);
-
rv = hasher->Update((unsigned char*) aPlainText, strlen(aPlainText));
NS_ENSURE_SUCCESS(rv, rv);
-
- rv = hasher->Finish(false, aResult);
- return rv;
+ return hasher->Finish(false, aResult);
}
namespace mozilla {