mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-31 01:24:12 +02:00
BaseTools/VfrCompile: Avoid possible NULL pointer dereference
Cc: Liming Gao <liming.gao@intel.com> Cc: Yonghong Zhu <yonghong.zhu@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Dandan Bi <dandan.bi@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Hao Wu <hao.a.wu@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
parent
d1f6eb27fe
commit
9b78c54a09
@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|||||||
**/
|
**/
|
||||||
|
|
||||||
#include "stdio.h"
|
#include "stdio.h"
|
||||||
|
#include "assert.h"
|
||||||
#include "VfrFormPkg.h"
|
#include "VfrFormPkg.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -669,6 +670,8 @@ CFormPkg::AdjustDynamicInsertOpcode (
|
|||||||
|
|
||||||
InserPositionNode = GetBinBufferNodeForAddr(InserPositionAddr);
|
InserPositionNode = GetBinBufferNodeForAddr(InserPositionAddr);
|
||||||
InsertOpcodeNode = GetBinBufferNodeForAddr(InsertOpcodeAddr);
|
InsertOpcodeNode = GetBinBufferNodeForAddr(InsertOpcodeAddr);
|
||||||
|
assert (InserPositionNode != NULL);
|
||||||
|
assert (InsertOpcodeNode != NULL);
|
||||||
|
|
||||||
if (InserPositionNode == InsertOpcodeNode) {
|
if (InserPositionNode == InsertOpcodeNode) {
|
||||||
//
|
//
|
||||||
@ -741,6 +744,8 @@ CFormPkg::AdjustDynamicInsertOpcode (
|
|||||||
// Insert the last restore data node.
|
// Insert the last restore data node.
|
||||||
//
|
//
|
||||||
TmpNode = GetNodeBefore (InsertOpcodeNode);
|
TmpNode = GetNodeBefore (InsertOpcodeNode);
|
||||||
|
assert (TmpNode != NULL);
|
||||||
|
|
||||||
if (TmpNode == InserPositionNode) {
|
if (TmpNode == InserPositionNode) {
|
||||||
NewRestoreNodeBegin->mNext = NewRestoreNodeEnd;
|
NewRestoreNodeBegin->mNext = NewRestoreNodeEnd;
|
||||||
} else {
|
} else {
|
||||||
@ -790,6 +795,8 @@ CFormPkg::AdjustDynamicInsertOpcode (
|
|||||||
mBufferNodeQueueTail = NewLastEndNode;
|
mBufferNodeQueueTail = NewLastEndNode;
|
||||||
} else if (mBufferNodeQueueTail->mBufferFree - mBufferNodeQueueTail->mBufferStart == 2) {
|
} else if (mBufferNodeQueueTail->mBufferFree - mBufferNodeQueueTail->mBufferStart == 2) {
|
||||||
TmpNode = GetNodeBefore(mBufferNodeQueueTail);
|
TmpNode = GetNodeBefore(mBufferNodeQueueTail);
|
||||||
|
assert (TmpNode != NULL);
|
||||||
|
|
||||||
TmpNode->mNext = NewRestoreNodeBegin;
|
TmpNode->mNext = NewRestoreNodeBegin;
|
||||||
if (NewRestoreNodeEnd != NULL) {
|
if (NewRestoreNodeEnd != NULL) {
|
||||||
NewRestoreNodeEnd->mNext = mBufferNodeQueueTail;
|
NewRestoreNodeEnd->mNext = mBufferNodeQueueTail;
|
||||||
@ -1314,7 +1321,7 @@ CIfrRecordInfoDB::IfrAdjustDynamicOpcodeInRecords (
|
|||||||
//
|
//
|
||||||
// Check the nodes whether exist.
|
// Check the nodes whether exist.
|
||||||
//
|
//
|
||||||
if (pNodeBeforeDynamic == NULL || pAdjustNode == NULL) {
|
if (pNodeBeforeDynamic == NULL || pAdjustNode == NULL || pNodeBeforeAdjust == NULL) {
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1854,6 +1861,10 @@ CIfrRecordInfoDB::IfrCreateDefaultForQuestion (
|
|||||||
pSNode = pSNode->mNext;
|
pSNode = pSNode->mNext;
|
||||||
OpcodeCount++;
|
OpcodeCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
assert (pSNode);
|
||||||
|
assert (pENode);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Record the offset of node which need to be adjust, will move the new created default opcode to this offset.
|
// Record the offset of node which need to be adjust, will move the new created default opcode to this offset.
|
||||||
//
|
//
|
||||||
@ -1875,6 +1886,7 @@ CIfrRecordInfoDB::IfrCreateDefaultForQuestion (
|
|||||||
while (pSNode != NULL && pSNode->mNext != NULL && OpcodeNumber-- != 0) {
|
while (pSNode != NULL && pSNode->mNext != NULL && OpcodeNumber-- != 0) {
|
||||||
pOpHead = (EFI_IFR_OP_HEADER *) pSNode->mIfrBinBuf;
|
pOpHead = (EFI_IFR_OP_HEADER *) pSNode->mIfrBinBuf;
|
||||||
Obj = new CIfrObj (pOpHead->OpCode, NULL, pSNode->mBinBufLen, FALSE);
|
Obj = new CIfrObj (pOpHead->OpCode, NULL, pSNode->mBinBufLen, FALSE);
|
||||||
|
assert (Obj != NULL);
|
||||||
Obj->SetLineNo (pSNode->mLineNo);
|
Obj->SetLineNo (pSNode->mLineNo);
|
||||||
ObjBinBuf = Obj->GetObjBinAddr();
|
ObjBinBuf = Obj->GetObjBinAddr();
|
||||||
memcpy (ObjBinBuf, pSNode->mIfrBinBuf, (UINTN)pSNode->mBinBufLen);
|
memcpy (ObjBinBuf, pSNode->mIfrBinBuf, (UINTN)pSNode->mBinBufLen);
|
||||||
@ -2378,6 +2390,8 @@ CIfrObj::CIfrObj (
|
|||||||
mObjBinBuf = ((DelayEmit == FALSE) && (gCreateOp == TRUE)) ? gCFormPkg.IfrBinBufferGet (mObjBinLen) : new CHAR8[EFI_IFR_MAX_LENGTH];
|
mObjBinBuf = ((DelayEmit == FALSE) && (gCreateOp == TRUE)) ? gCFormPkg.IfrBinBufferGet (mObjBinLen) : new CHAR8[EFI_IFR_MAX_LENGTH];
|
||||||
mRecordIdx = (gCreateOp == TRUE) ? gCIfrRecordInfoDB.IfrRecordRegister (0xFFFFFFFF, mObjBinBuf, mObjBinLen, mPkgOffset) : EFI_IFR_RECORDINFO_IDX_INVALUD;
|
mRecordIdx = (gCreateOp == TRUE) ? gCIfrRecordInfoDB.IfrRecordRegister (0xFFFFFFFF, mObjBinBuf, mObjBinLen, mPkgOffset) : EFI_IFR_RECORDINFO_IDX_INVALUD;
|
||||||
|
|
||||||
|
assert (mObjBinBuf != NULL);
|
||||||
|
|
||||||
if (IfrObj != NULL) {
|
if (IfrObj != NULL) {
|
||||||
*IfrObj = mObjBinBuf;
|
*IfrObj = mObjBinBuf;
|
||||||
}
|
}
|
||||||
|
@ -665,7 +665,7 @@ CVfrVarDataTypeDB::GetTypeField (
|
|||||||
{
|
{
|
||||||
SVfrDataField *pField = NULL;
|
SVfrDataField *pField = NULL;
|
||||||
|
|
||||||
if ((FName == NULL) && (Type == NULL)) {
|
if ((FName == NULL) || (Type == NULL)) {
|
||||||
return VFR_RETURN_FATAL_ERROR;
|
return VFR_RETURN_FATAL_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user