[coreboot-gerrit] New patch to review for coreboot: libpayload: Check for CBFS_DEFAULT_MEDIA in cbfs_get_file_content()
Nico Huber (nico.h@gmx.de)
gerrit at coreboot.org
Mon Oct 5 11:42:43 CET 2015
Nico Huber (nico.h at gmx.de) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/11796
-gerrit
commit 20d7286d066bde4f9a84354b4c0922a61d869a03
Author: Nico Huber <nico.huber at secunet.com>
Date: Mon Oct 5 12:08:24 2015 +0200
libpayload: Check for CBFS_DEFAULT_MEDIA in cbfs_get_file_content()
The error-prone interface of cbfs_get_file_content() led to another
possible NULL dereferencing. So check for CBFS_DEFAULT_MEDIA here
like the other functions do.
Change-Id: Ib8732160d389e9ecceb44f28be0e7de9a1d66e04
Signed-off-by: Nico Huber <nico.huber at secunet.com>
---
payloads/libpayload/libcbfs/cbfs_core.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/payloads/libpayload/libcbfs/cbfs_core.c b/payloads/libpayload/libcbfs/cbfs_core.c
index 369d946..a4cb033 100644
--- a/payloads/libpayload/libcbfs/cbfs_core.c
+++ b/payloads/libpayload/libcbfs/cbfs_core.c
@@ -191,6 +191,16 @@ struct cbfs_file *cbfs_get_file(struct cbfs_media *media, const char *name)
void *cbfs_get_file_content(struct cbfs_media *media, const char *name,
int type, size_t *sz)
{
+ struct cbfs_media default_media;
+
+ if (media == CBFS_DEFAULT_MEDIA) {
+ media = &default_media;
+ if (init_default_cbfs_media(media) != 0) {
+ ERROR("Failed to initialize default media.\n");
+ return NULL;
+ }
+ }
+
struct cbfs_file *file = cbfs_get_file(media, name);
if (sz)
More information about the coreboot-gerrit
mailing list