mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-27 06:43:32 +00:00
Bug 976922 - heap-use-after-free mozilla::net::CacheEntry::GetMetaDataElement in NS_strdup, r=honzab
This commit is contained in:
parent
f06539de43
commit
dc96947b54
@ -1052,16 +1052,15 @@ NS_IMETHODIMP CacheEntry::GetSecurityInfo(nsISupports * *aSecurityInfo)
|
||||
|
||||
NS_ENSURE_SUCCESS(mFileStatus, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
char const* info;
|
||||
nsXPIDLCString info;
|
||||
nsCOMPtr<nsISupports> secInfo;
|
||||
nsresult rv;
|
||||
|
||||
rv = mFile->GetElement("security-info", &info);
|
||||
rv = mFile->GetElement("security-info", getter_Copies(info));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (info) {
|
||||
rv = NS_DeserializeObject(nsDependentCString(info),
|
||||
getter_AddRefs(secInfo));
|
||||
rv = NS_DeserializeObject(info, getter_AddRefs(secInfo));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
@ -1148,15 +1147,7 @@ NS_IMETHODIMP CacheEntry::GetMetaDataElement(const char * aKey, char * *aRetval)
|
||||
{
|
||||
NS_ENSURE_SUCCESS(mFileStatus, NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
const char *value;
|
||||
nsresult rv = mFile->GetElement(aKey, &value);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!value)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*aRetval = NS_strdup(value);
|
||||
return NS_OK;
|
||||
return mFile->GetElement(aKey, aRetval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP CacheEntry::SetMetaDataElement(const char * aKey, const char * aValue)
|
||||
|
@ -775,13 +775,18 @@ CacheFile::ThrowMemoryCachedData()
|
||||
}
|
||||
|
||||
nsresult
|
||||
CacheFile::GetElement(const char *aKey, const char **_retval)
|
||||
CacheFile::GetElement(const char *aKey, char **_retval)
|
||||
{
|
||||
CacheFileAutoLock lock(this);
|
||||
MOZ_ASSERT(mMetadata);
|
||||
NS_ENSURE_TRUE(mMetadata, NS_ERROR_UNEXPECTED);
|
||||
|
||||
*_retval = mMetadata->GetElement(aKey);
|
||||
const char *value;
|
||||
value = mMetadata->GetElement(aKey);
|
||||
if (!value)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
*_retval = NS_strdup(value);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -83,7 +83,7 @@ public:
|
||||
nsresult ThrowMemoryCachedData();
|
||||
|
||||
// metadata forwarders
|
||||
nsresult GetElement(const char *aKey, const char **_retval);
|
||||
nsresult GetElement(const char *aKey, char **_retval);
|
||||
nsresult SetElement(const char *aKey, const char *aValue);
|
||||
nsresult ElementsSize(uint32_t *_retval);
|
||||
nsresult SetExpirationTime(uint32_t aExpirationTime);
|
||||
|
Loading…
Reference in New Issue
Block a user