Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Commit 59d74ca

Browse files
Fir for PBR parsing crash for 3_0
1 parent 16a0525 commit 59d74ca

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

DcpmPkg/common/PbrOs.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ VOID DeserializePbrMode(UINT32 *pMode, UINT32 defaultMode);
100100
if(NULL == buffer) { \
101101
NVDIMM_ERR("Failed to allocate memory for deserializing buffer\n"); \
102102
} \
103+
else \
103104
if (1 != fread(buffer, size, 1, pFile)) \
104105
{ \
105106
NVDIMM_ERR("Failed to read the PBR file: %s\n", file); \
@@ -222,7 +223,17 @@ EFI_STATUS PbrDeserializeCtx(
222223
if (PBR_INVALID_SIG != ctx->PartitionContexts[CtxIndex].PartitionSig) {
223224
AsciiSPrint(pbr_filename, sizeof(pbr_filename), "%x.pbr", ctx->PartitionContexts[CtxIndex].PartitionSig);
224225
AsciiSPrint(pbr_dir, sizeof(pbr_dir), "%s%s", PBR_TMP_DIR, pbr_filename);
226+
227+
ctx->PartitionContexts[CtxIndex].PartitionData = NULL; // initialize buffer to NULL to allow proper error handling in case of fail to open pbr_dir file
225228
DeserializeBufferEx(pbr_dir, ctx->PartitionContexts[CtxIndex].PartitionData, ctx->PartitionContexts[CtxIndex].PartitionSize);
229+
230+
if(ctx->PartitionContexts[CtxIndex].PartitionData == NULL)
231+
{
232+
// we do not free already allocated memory because OS will free it after process exit
233+
NVDIMM_ERR("PBR context file corrupted, please remove "PBR_TMP_DIR PBR_CTX_FILE_NAME"\n");
234+
ReturnCode = EFI_END_OF_FILE;
235+
goto Finish;
236+
}
226237
}
227238
}
228239

0 commit comments

Comments
 (0)