summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>2010-06-09 02:04:12 +0000
committerli-elvin <li-elvin@6f19259b-4bc3-4df7-8a09-765794883524>2010-06-09 02:04:12 +0000
commit2788ff5116913c11e457382b42d4da19afc9e11c (patch)
tree2dbcdb717638e0ee9fba3927f40ed08fe5ba6495
parent7830363c37c25097bc0322cd60310f03a349b81b (diff)
downloadedk2-platforms-2788ff5116913c11e457382b42d4da19afc9e11c.tar.xz
Fix the issue that if OEM SMBIOS data includes string, it will cause SmbiosFldMiscTypeOEM buffer overflow.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10569 6f19259b-4bc3-4df7-8a09-765794883524
-rw-r--r--EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/ConvLib.c45
-rw-r--r--EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/MiscConv.c42
-rw-r--r--EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/Thunk.h14
3 files changed, 78 insertions, 23 deletions
diff --git a/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/ConvLib.c b/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/ConvLib.c
index 3adaeffb5d..10208cecb4 100644
--- a/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/ConvLib.c
+++ b/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/ConvLib.c
@@ -2,7 +2,7 @@
Common filling functions used in translating Datahub's record
to PI SMBIOS's record.
-Copyright (c) 2009, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -159,6 +159,49 @@ SmbiosEnlargeStructureBuffer (
}
/**
+ Update the structure buffer of a structure node in SMBIOS database.
+ The function lead the structure pointer for SMBIOS record changed.
+
+ @param StructureNode The structure node whose structure buffer is to be enlarged.
+ @param NewRecord The new SMBIOS record.
+
+**/
+VOID
+SmbiosUpdateStructureBuffer (
+ IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
+ IN EFI_SMBIOS_TABLE_HEADER *NewRecord
+ )
+{
+ EFI_SMBIOS_PROTOCOL *Smbios;
+ EFI_STATUS Status;
+ UINT8 CountOfString;
+
+ Smbios = GetSmbiosProtocol();
+ ASSERT (Smbios != NULL);
+
+ Status = Smbios->Remove (Smbios, StructureNode->SmbiosHandle);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // try to use original handle to enlarge the buffer.
+ //
+ Status = Smbios->Add (Smbios, NULL, &StructureNode->SmbiosHandle, NewRecord);
+ ASSERT_EFI_ERROR (Status);
+
+ StructureNode->Structure = GetSmbiosBufferFromHandle (
+ StructureNode->SmbiosHandle,
+ StructureNode->SmbiosType,
+ NULL
+ );
+ GetSmbiosStructureSize (
+ StructureNode->Structure,
+ &StructureNode->StructureSize,
+ &CountOfString
+ );
+ return ;
+}
+
+/**
Fill a standard Smbios string field.
This function will convert the unicode string to single byte chars, and only
diff --git a/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/MiscConv.c b/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/MiscConv.c
index 3358a96672..5c62cc6b53 100644
--- a/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/MiscConv.c
+++ b/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/MiscConv.c
@@ -2391,30 +2391,28 @@ SmbiosFldMiscTypeOEM (
ASSERT_EFI_ERROR (Status);
if (StructureSize < RecordDataSize) {
- Status = SmbiosEnlargeStructureBuffer (
- StructureNode,
- ((EFI_SMBIOS_TABLE_HEADER *)RecordData)->Length,
- StructureSize,
- RecordDataSize
- );
- if (EFI_ERROR (Status)) {
- return Status;
- }
+ //
+ // Create new SMBIOS table entry
+ //
+ SmbiosUpdateStructureBuffer (
+ StructureNode,
+ RecordData
+ );
+ } else {
+ //
+ // Copy the entire data (including the Smbios structure header),
+ // but preserve the handle that is already allocated.
+ //
+ Handle = StructureNode->Structure->Handle;
+ CopyMem (
+ StructureNode->Structure,
+ RecordData,
+ RecordDataSize
+ );
+ StructureNode->Structure->Handle = Handle;
+ StructureNode->StructureSize = RecordDataSize;
}
- //
- // Copy the entire data (including the Smbios structure header),
- // but preserve the handle that is already allocated.
- //
- Handle = StructureNode->Structure->Handle;
- CopyMem (
- StructureNode->Structure,
- RecordData,
- RecordDataSize
- );
- StructureNode->Structure->Handle = Handle;
- StructureNode->StructureSize = RecordDataSize;
-
if (NewRecordData != NULL) {
FreePool (NewRecordData);
}
diff --git a/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/Thunk.h b/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/Thunk.h
index a35db23370..a2f477dafa 100644
--- a/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/Thunk.h
+++ b/EdkCompatibilityPkg/Compatibility/PiSmbiosRecordOnDataHubSmbiosRecordThunk/Thunk.h
@@ -265,6 +265,20 @@ SmbiosEnlargeStructureBuffer (
);
/**
+ Update the structure buffer of a structure node in SMBIOS database.
+ The function lead the structure pointer for SMBIOS record changed.
+
+ @param StructureNode The structure node whose structure buffer is to be enlarged.
+ @param NewRecord The new SMBIOS record.
+
+**/
+VOID
+SmbiosUpdateStructureBuffer (
+ IN OUT SMBIOS_STRUCTURE_NODE *StructureNode,
+ IN EFI_SMBIOS_TABLE_HEADER *NewRecord
+ );
+
+/**
Fill a standard Smbios string field.
This function will convert the unicode string to single byte chars, and only