script/execute: Add missing grub_strdup() failure check

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:
Avnish Chouhan 2025-11-10 20:27:20 +05:30 committed by Daniel Kiper
parent f0170c2177
commit 9eebd67744

View File

@ -1015,6 +1015,9 @@ grub_script_execute_cmdline (struct grub_script_cmd *cmd)
{
/* As a last resort, try if it is an assignment. */
char *assign = grub_strdup (cmdname);
if (assign == NULL)
return grub_errno;
char *eq = grub_strchr (assign, '=');
if (eq)