Tag panic instead of silently fail when wrong get[type] is called.

Handle Prop </false> in InjectKexts.
Replace FreePool by delete.
This commit is contained in:
jief666 2020-09-04 00:34:44 +03:00
parent 8276e8b4f9
commit efb3c44b0f
2 changed files with 25 additions and 31 deletions

View File

@ -1732,6 +1732,8 @@ FillinCustomEntry (
if (Prop != NULL) {
if ( Prop->isTrueOrYes() ) {
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
} else if ( Prop->isFalseOrNn() ) {
// nothing to do
} else if ( Prop->isString() && Prop->getString()->stringValue().equalIC("Detect") ) {
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_CHECKFAKESMC);
Entry->Flags = OSFLAG_SET(Entry->Flags, OSFLAG_WITHKEXTS);
@ -2640,7 +2642,7 @@ GetEarlyUserSettings (
// Allocate an entry
CUSTOM_LOADER_ENTRY* Entry = new CUSTOM_LOADER_ENTRY;
// Fill it in
if (Entry != NULL && (!FillinCustomEntry(Entry, Dict3, FALSE) || !AddCustomLoaderEntry(Entry))) {
if ( !FillinCustomEntry(Entry, Dict3, FALSE) || !AddCustomLoaderEntry(Entry) ) {
delete Entry;
}
}
@ -2656,11 +2658,9 @@ GetEarlyUserSettings (
const TagDict* Dict3 = LegacyArray->dictElementAt(i, "Legacy"_XS8);
// Allocate an entry
Entry = new CUSTOM_LEGACY_ENTRY;
if (Entry) {
// Fill it in
if (!FillingCustomLegacy(Entry, Dict3) || !AddCustomLegacyEntry(Entry)) {
FreePool(Entry);
}
// Fill it in
if (!FillingCustomLegacy(Entry, Dict3) || !AddCustomLegacyEntry(Entry)) {
delete Entry;
}
}
}
@ -2673,17 +2673,11 @@ GetEarlyUserSettings (
if (Count > 0) {
for (i = 0; i < Count; i++) {
const TagDict* Dict3 = ToolArray->dictElementAt(i, "Tool"_XS8);
if ( !Dict3->isDict() ) {
MsgLog("MALFORMED PLIST : Entries must be an array of dict");
continue;
}
// Allocate an entry
Entry = new CUSTOM_TOOL_ENTRY;
if (Entry) {
// Fill it in
if (!FillingCustomTool(Entry, Dict3) || !AddCustomToolEntry(Entry)) {
FreePool(Entry);
}
delete Entry;
}
}
}

View File

@ -71,25 +71,25 @@ public:
void printf(unsigned int ident) const;
virtual void printf() const { printf(0); }
virtual const TagDict* getDict() const { return NULL; }
virtual const TagKey* getKey() const { return NULL; }
virtual const TagString* getString() const { return NULL; }
virtual const TagInt64* getInt64() const { return NULL; }
virtual const TagFloat* getFloat() const { return NULL; }
virtual const TagBool* getBool() const { return NULL; }
virtual const TagData* getData() const { return NULL; }
virtual const TagDate* getDate() const { return NULL; }
virtual const TagArray* getArray() const { return NULL; }
virtual const TagDict* getDict() const { panic("getDict() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual const TagKey* getKey() const { panic("getKey() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual const TagString* getString() const { panic("getString() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual const TagInt64* getInt64() const { panic("getInt64() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual const TagFloat* getFloat() const { panic("getFloat() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual const TagBool* getBool() const { panic("getBool() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual const TagData* getData() const { panic("getData() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual const TagDate* getDate() const { panic("getDate() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual const TagArray* getArray() const { panic("getArray() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual TagDict* getDict() { return NULL; }
virtual TagKey* getKey() { return NULL; }
virtual TagString* getString() { return NULL; }
virtual TagInt64* getInt64() { return NULL; }
virtual TagFloat* getFloat() { return NULL; }
virtual TagBool* getBool() { return NULL; }
virtual TagData* getData() { return NULL; }
virtual TagDate* getDate() { return NULL; }
virtual TagArray* getArray() { return NULL; }
virtual TagDict* getDict() { panic("getDict() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual TagKey* getKey() { panic("getKey() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual TagString* getString() { panic("getString() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual TagInt64* getInt64() { panic("getInt64() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual TagFloat* getFloat() { panic("getFloat() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual TagBool* getBool() { panic("getBool() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual TagData* getData() { panic("getData() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual TagDate* getDate() { panic("getDate() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual TagArray* getArray() { panic("getArray() called on a tag of type %s.", this->getTypeAsXString8().c_str()); }
virtual bool isDict() const { return false; }
virtual bool isKey() const { return false; }