forked from mirrors/gecko-dev
Bug 1554559 - P1. Test for invalid arguments. r=kershaw
Will also silence static analysis in phabricator whenever a caller of this code is used. Differential Revision: https://phabricator.services.mozilla.com/D33419 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
83296d7309
commit
638940d1fc
1 changed files with 9 additions and 4 deletions
|
|
@ -110,6 +110,11 @@ SharedPreferenceDeserializer::~SharedPreferenceDeserializer() {
|
||||||
bool SharedPreferenceDeserializer::DeserializeFromSharedMemory(
|
bool SharedPreferenceDeserializer::DeserializeFromSharedMemory(
|
||||||
char* aPrefsHandleStr, char* aPrefMapHandleStr, char* aPrefsLenStr,
|
char* aPrefsHandleStr, char* aPrefMapHandleStr, char* aPrefsLenStr,
|
||||||
char* aPrefMapSizeStr) {
|
char* aPrefMapSizeStr) {
|
||||||
|
#ifdef XP_WIN
|
||||||
|
MOZ_ASSERT(aPrefsHandleStr && aPrefMapHandleStr, "Can't be null");
|
||||||
|
#endif
|
||||||
|
MOZ_ASSERT(aPrefsLenStr && aPrefMapSizeStr, "Can't be null");
|
||||||
|
|
||||||
// Parses an arg containing a pointer-sized-integer.
|
// Parses an arg containing a pointer-sized-integer.
|
||||||
auto parseUIntPtrArg = [](char*& aArg) {
|
auto parseUIntPtrArg = [](char*& aArg) {
|
||||||
// ContentParent uses %zu to print a word-sized unsigned integer. So
|
// ContentParent uses %zu to print a word-sized unsigned integer. So
|
||||||
|
|
@ -124,7 +129,7 @@ bool SharedPreferenceDeserializer::DeserializeFromSharedMemory(
|
||||||
};
|
};
|
||||||
|
|
||||||
mPrefsHandle = Some(parseHandleArg(aPrefsHandleStr));
|
mPrefsHandle = Some(parseHandleArg(aPrefsHandleStr));
|
||||||
if (aPrefsHandleStr[0] != '\0') {
|
if (!aPrefsHandleStr || aPrefsHandleStr[0] != '\0') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -133,7 +138,7 @@ bool SharedPreferenceDeserializer::DeserializeFromSharedMemory(
|
||||||
// closed.
|
// closed.
|
||||||
FileDescriptor::UniquePlatformHandle handle(
|
FileDescriptor::UniquePlatformHandle handle(
|
||||||
parseHandleArg(aPrefMapHandleStr));
|
parseHandleArg(aPrefMapHandleStr));
|
||||||
if (aPrefMapHandleStr[0] != '\0') {
|
if (!aPrefMapHandleStr || aPrefMapHandleStr[0] != '\0') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -141,12 +146,12 @@ bool SharedPreferenceDeserializer::DeserializeFromSharedMemory(
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
mPrefsLen = Some(parseUIntPtrArg(aPrefsLenStr));
|
mPrefsLen = Some(parseUIntPtrArg(aPrefsLenStr));
|
||||||
if (aPrefsLenStr[0] != '\0') {
|
if (!aPrefsLenStr || aPrefsLenStr[0] != '\0') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
mPrefMapSize = Some(parseUIntPtrArg(aPrefMapSizeStr));
|
mPrefMapSize = Some(parseUIntPtrArg(aPrefMapSizeStr));
|
||||||
if (aPrefMapSizeStr[0] != '\0') {
|
if (!aPrefMapSizeStr || aPrefMapSizeStr[0] != '\0') {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue