CVE-2024-45776.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. From 09bd6eb58b0f71ec273916070fa1e2de16897a91 Mon Sep 17 00:00:00 2001
  2. From: Lidong Chen <lidong.chen@oracle.com>
  3. Date: Fri, 22 Nov 2024 06:27:56 +0000
  4. Subject: [PATCH] gettext: Integer overflow leads to heap OOB write or read
  5. Calculation of ctx->grub_gettext_msg_list size in grub_mofile_open() may
  6. overflow leading to subsequent OOB write or read. This patch fixes the
  7. issue by replacing grub_zalloc() and explicit multiplication with
  8. grub_calloc() which does the same thing in safe manner.
  9. Fixes: CVE-2024-45776
  10. Reported-by: Nils Langius <nils@langius.de>
  11. Signed-off-by: Lidong Chen <lidong.chen@oracle.com>
  12. Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
  13. Reviewed-by: Alec Brown <alec.r.brown@oracle.com>
  14. CVE: CVE-2024-45776
  15. Upstream-Status: Backport [https://git.savannah.gnu.org/cgit/grub.git/commit/?id=09bd6eb58b0f71ec273916070fa1e2de16897a91]
  16. Signed-off-by: Hitendra Prajapati <hprajapati@mvista.com>
  17. ---
  18. grub-core/gettext/gettext.c | 4 ++--
  19. 1 file changed, 2 insertions(+), 2 deletions(-)
  20. diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c
  21. index 4d02e62..55d8b67 100644
  22. --- a/grub-core/gettext/gettext.c
  23. +++ b/grub-core/gettext/gettext.c
  24. @@ -323,8 +323,8 @@ grub_mofile_open (struct grub_gettext_context *ctx,
  25. for (ctx->grub_gettext_max_log = 0; ctx->grub_gettext_max >> ctx->grub_gettext_max_log;
  26. ctx->grub_gettext_max_log++);
  27. - ctx->grub_gettext_msg_list = grub_zalloc (ctx->grub_gettext_max
  28. - * sizeof (ctx->grub_gettext_msg_list[0]));
  29. + ctx->grub_gettext_msg_list = grub_calloc (ctx->grub_gettext_max,
  30. + sizeof (ctx->grub_gettext_msg_list[0]));
  31. if (!ctx->grub_gettext_msg_list)
  32. {
  33. grub_file_close (fd);
  34. --
  35. 2.25.1