Bug 1156416 - Validate camera parameters supplied by the application. r=mikeh

This commit is contained in:
Andrew Osmond 2015-04-17 14:17:18 -04:00
parent b8a35a1187
commit 1b014ef5da
2 changed files with 15 additions and 12 deletions

View File

@ -106,7 +106,7 @@ GonkCameraParameters::Unflatten(const String8& aFlatParameters)
break;
}
nsAutoCString key(data, pos - data);
nsDependentCSubstring key(data, pos - data);
data = pos + 1;
nsCString* value;

View File

@ -97,14 +97,17 @@ protected:
nsresult SetImpl(const char* aKey, const char* aValue)
{
nsCString key(aKey);
if (!aValue || strchr(aValue, ';') || strchr(aValue, '=')) {
return NS_ERROR_ILLEGAL_VALUE;
}
nsDependentCString key(aKey);
mParams.Put(key, new nsCString(aValue));
return NS_OK;
}
nsresult SetImpl(const char* aKey, int aValue)
{
nsCString key(aKey);
nsDependentCString key(aKey);
nsCString* value = new nsCString();
value->AppendInt(aValue);
mParams.Put(key, value);
@ -113,7 +116,7 @@ protected:
nsresult SetImpl(const char* aKey, double aValue)
{
nsCString key(aKey);
nsDependentCString key(aKey);
nsCString* value = new nsCString();
value->AppendFloat(aValue);
mParams.Put(key, value);
@ -122,7 +125,7 @@ protected:
nsresult SetImpl(const char* aKey, float aValue)
{
nsCString key(aKey);
nsDependentCString key(aKey);
nsCString* value = new nsCString();
value->AppendFloat(aValue);
mParams.Put(key, value);
@ -131,14 +134,14 @@ protected:
nsresult SetImpl(const char* aKey, bool aValue)
{
nsCString key(aKey);
nsDependentCString key(aKey);
mParams.Put(key, new nsCString(aValue ? "true" : "false"));
return NS_OK;
}
nsresult GetImpl(const char* aKey, const char*& aRet)
{
nsCString key(aKey);
nsDependentCString key(aKey);
nsCString* value;
if (!mParams.Get(key, &value)) {
aRet = nullptr;
@ -150,7 +153,7 @@ protected:
nsresult GetImpl(const char* aKey, float& aRet)
{
nsCString key(aKey);
nsDependentCString key(aKey);
nsCString* value;
nsresult rv = NS_ERROR_FAILURE;
if (mParams.Get(key, &value)) {
@ -163,7 +166,7 @@ protected:
nsresult GetImpl(const char* aKey, double& aRet)
{
nsCString key(aKey);
nsDependentCString key(aKey);
nsCString* value;
nsresult rv = NS_ERROR_FAILURE;
if (mParams.Get(key, &value)) {
@ -176,7 +179,7 @@ protected:
nsresult GetImpl(const char* aKey, int& aRet)
{
nsCString key(aKey);
nsDependentCString key(aKey);
nsCString* value;
nsresult rv = NS_ERROR_FAILURE;
if (mParams.Get(key, &value)) {
@ -189,7 +192,7 @@ protected:
nsresult GetImpl(const char* aKey, bool& aRet)
{
nsCString key(aKey);
nsDependentCString key(aKey);
nsCString* value;
if (!mParams.Get(key, &value)) {
aRet = false;
@ -228,7 +231,7 @@ protected:
nsresult
ClearImpl(const char* aKey)
{
nsCString key(aKey);
nsDependentCString key(aKey);
mParams.Remove(key);
return NS_OK;
}