|
|
80913e |
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
|
80913e |
From: Alexey Makhalov <amakhalov@vmware.com>
|
|
|
80913e |
Date: Wed, 8 Jul 2020 21:30:43 +0000
|
|
|
80913e |
Subject: [PATCH] xnu: Fix double free in grub_xnu_devprop_add_property()
|
|
|
80913e |
|
|
|
80913e |
grub_xnu_devprop_add_property() should not free utf8 and utf16 as it get
|
|
|
80913e |
allocated and freed in the caller.
|
|
|
80913e |
|
|
|
80913e |
Minor improvement: do prop fields initialization after memory allocations.
|
|
|
80913e |
|
|
|
80913e |
Fixes: CID 292442, CID 292457, CID 292460, CID 292466
|
|
|
80913e |
|
|
|
80913e |
Signed-off-by: Alexey Makhalov <amakhalov@vmware.com>
|
|
|
80913e |
Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
|
|
|
80913e |
Upstream-commit-id: 4d5e2d13519
|
|
|
80913e |
---
|
|
|
80913e |
grub-core/loader/i386/xnu.c | 19 +++++++++----------
|
|
|
80913e |
1 file changed, 9 insertions(+), 10 deletions(-)
|
|
|
80913e |
|
|
|
80913e |
diff --git a/grub-core/loader/i386/xnu.c b/grub-core/loader/i386/xnu.c
|
|
|
80913e |
index ee0eaadc4ee..c760db30fc0 100644
|
|
|
80913e |
--- a/grub-core/loader/i386/xnu.c
|
|
|
80913e |
+++ b/grub-core/loader/i386/xnu.c
|
|
|
80913e |
@@ -262,20 +262,19 @@ grub_xnu_devprop_add_property (struct grub_xnu_devprop_device_descriptor *dev,
|
|
|
80913e |
if (!prop)
|
|
|
80913e |
return grub_errno;
|
|
|
80913e |
|
|
|
80913e |
+ prop->data = grub_malloc (datalen);
|
|
|
80913e |
+ if (!prop->data)
|
|
|
80913e |
+ {
|
|
|
80913e |
+ grub_free (prop);
|
|
|
80913e |
+ return grub_errno;
|
|
|
80913e |
+ }
|
|
|
80913e |
+ grub_memcpy (prop->data, data, datalen);
|
|
|
80913e |
+
|
|
|
80913e |
prop->name = utf8;
|
|
|
80913e |
prop->name16 = utf16;
|
|
|
80913e |
prop->name16len = utf16len;
|
|
|
80913e |
-
|
|
|
80913e |
prop->length = datalen;
|
|
|
80913e |
- prop->data = grub_malloc (prop->length);
|
|
|
80913e |
- if (!prop->data)
|
|
|
80913e |
- {
|
|
|
80913e |
- grub_free (prop->name);
|
|
|
80913e |
- grub_free (prop->name16);
|
|
|
80913e |
- grub_free (prop);
|
|
|
80913e |
- return grub_errno;
|
|
|
80913e |
- }
|
|
|
80913e |
- grub_memcpy (prop->data, data, prop->length);
|
|
|
80913e |
+
|
|
|
80913e |
grub_list_push (GRUB_AS_LIST_P (&dev->properties),
|
|
|
80913e |
GRUB_AS_LIST (prop));
|
|
|
80913e |
return GRUB_ERR_NONE;
|