mirror of
https://git.savannah.gnu.org/git/grub.git
synced 2026-10-21 23:02:40 +00:00
kern/ieee1275/openfw: Add missing grub_strdup() failure checks
If grub_strdup() fails, it returns NULL and passing NULL further down to the code can lead to segmentation fault or an undefined behavior. Signed-off-by: Avnish Chouhan <avnish@linux.ibm.com> Reviewed-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com> Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
This commit is contained in:
1 parent
3a66437054
commit
f0170c2177
1 file changed
+14
-3
@@ -201,6 +201,11 @@ grub_ieee1275_devalias_next (struct grub_ieee1275_devalias *alias)
|
|||||||
alias->path = 0;
|
alias->path = 0;
|
||||||
}
|
}
|
||||||
tmp = grub_strdup (alias->name);
|
tmp = grub_strdup (alias->name);
|
||||||
|
if (tmp == NULL)
|
||||||
|
{
|
||||||
|
grub_ieee1275_devalias_free (alias);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
if (grub_ieee1275_next_property (alias->parent_dev, tmp,
|
if (grub_ieee1275_next_property (alias->parent_dev, tmp,
|
||||||
alias->name) <= 0)
|
alias->name) <= 0)
|
||||||
{
|
{
|
||||||
@@ -432,9 +437,15 @@ grub_ieee1275_parse_args (const char *path, enum grub_ieee1275_parse_type ptype)
|
|||||||
ret = grub_strdup (args);
|
ret = grub_strdup (args);
|
||||||
else
|
else
|
||||||
ret = grub_strndup (args, (grub_size_t)(comma - args));
|
ret = grub_strndup (args, (grub_size_t)(comma - args));
|
||||||
/* Consistently provide numbered partitions to GRUB.
|
|
||||||
OpenBOOT traditionally uses alphabetical partition
|
if (ret == NULL)
|
||||||
specifiers. */
|
return 0;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Consistently provide numbered partitions to GRUB.
|
||||||
|
* OpenBOOT traditionally uses alphabetical partition
|
||||||
|
* specifiers.
|
||||||
|
*/
|
||||||
if (ret[0] >= 'a' && ret[0] <= 'z')
|
if (ret[0] >= 'a' && ret[0] <= 'z')
|
||||||
ret[0] = '1' + (ret[0] - 'a');
|
ret[0] = '1' + (ret[0] - 'a');
|
||||||
grub_free (args);
|
grub_free (args);
|
||||||
|
|||||||
Reference in new issue
Block a user