All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] script/execute: Add NULL check for grub_calloc in gettext_append
@ 2025-12-02  7:08 Sridhar Markonda
  2025-12-20 13:11 ` Daniel Kiper
  0 siblings, 1 reply; 2+ messages in thread
From: Sridhar Markonda @ 2025-12-02  7:08 UTC (permalink / raw)
  To: grub-devel
  Cc: daniel.kiper, phcoder, sudhakar, stefanb, nayna, sridharm, ssrish

Add a NULL check after grub_calloc in gettext_append to handle allocation errors.
This prevents using a NULL pointer and stops crashes during string translation.

Signed-off-by: Sridhar Markonda <sridharm@linux.ibm.com>
Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>
---
 grub-core/script/execute.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/grub-core/script/execute.c b/grub-core/script/execute.c
index 62afcdc99..369d985ee 100644
--- a/grub-core/script/execute.c
+++ b/grub-core/script/execute.c
@@ -562,6 +562,8 @@ gettext_append (struct grub_script_argv *result, const char *orig_str)
     if (*iptr == '$')
       dollar_cnt++;
   ctx.allowed_strings = grub_calloc (dollar_cnt, sizeof (ctx.allowed_strings[0]));
+  if (ctx.allowed_strings == NULL)
+    goto fail;
 
   if (parse_string (orig_str, gettext_save_allow, &ctx, 0))
     goto fail;
-- 
2.47.3


_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] script/execute: Add NULL check for grub_calloc in gettext_append
  2025-12-02  7:08 [PATCH] script/execute: Add NULL check for grub_calloc in gettext_append Sridhar Markonda
@ 2025-12-20 13:11 ` Daniel Kiper
  0 siblings, 0 replies; 2+ messages in thread
From: Daniel Kiper @ 2025-12-20 13:11 UTC (permalink / raw)
  To: Sridhar Markonda; +Cc: grub-devel, phcoder, sudhakar, stefanb, nayna, ssrish

On Tue, Dec 02, 2025 at 12:38:45PM +0530, Sridhar Markonda wrote:
> Add a NULL check after grub_calloc in gettext_append to handle allocation errors.
> This prevents using a NULL pointer and stops crashes during string translation.
>
> Signed-off-by: Sridhar Markonda <sridharm@linux.ibm.com>
> Signed-off-by: Sudhakar Kuppusamy <sudhakar@linux.ibm.com>

Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>

Daniel

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
https://lists.gnu.org/mailman/listinfo/grub-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-12-20 13:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-02  7:08 [PATCH] script/execute: Add NULL check for grub_calloc in gettext_append Sridhar Markonda
2025-12-20 13:11 ` Daniel Kiper

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.