All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sridhar Markonda <sridharm@linux.ibm.com>
To: grub-devel@gnu.org
Cc: daniel.kiper@oracle.com, phcoder@gmail.com,
	sudhakar@linux.ibm.com, stefanb@linux.ibm.com,
	nayna@linux.ibm.com, sridharm@linux.ibm.com,
	ssrish@linux.ibm.com
Subject: [PATCH] script/execute: Add NULL check for grub_calloc in gettext_append
Date: Tue,  2 Dec 2025 12:38:45 +0530	[thread overview]
Message-ID: <20251202070845.35256-1-sridharm@linux.ibm.com> (raw)

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

             reply	other threads:[~2025-12-02  7:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-02  7:08 Sridhar Markonda [this message]
2025-12-20 13:11 ` [PATCH] script/execute: Add NULL check for grub_calloc in gettext_append Daniel Kiper

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20251202070845.35256-1-sridharm@linux.ibm.com \
    --to=sridharm@linux.ibm.com \
    --cc=daniel.kiper@oracle.com \
    --cc=grub-devel@gnu.org \
    --cc=nayna@linux.ibm.com \
    --cc=phcoder@gmail.com \
    --cc=ssrish@linux.ibm.com \
    --cc=stefanb@linux.ibm.com \
    --cc=sudhakar@linux.ibm.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.