0036-gettext-Integer-overflow-leads-to-heap-OOB-write-or-.patch 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. From 31b3e24947c6dbb65ea2eca30ddd168dc47513ce 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. Upstream: 09bd6eb58b0f71ec273916070fa1e2de16897a91
  15. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  16. ---
  17. grub-core/gettext/gettext.c | 4 ++--
  18. 1 file changed, 2 insertions(+), 2 deletions(-)
  19. diff --git a/grub-core/gettext/gettext.c b/grub-core/gettext/gettext.c
  20. index e4f4f8ee6..63bb1ab73 100644
  21. --- a/grub-core/gettext/gettext.c
  22. +++ b/grub-core/gettext/gettext.c
  23. @@ -323,8 +323,8 @@ grub_mofile_open (struct grub_gettext_context *ctx,
  24. for (ctx->grub_gettext_max_log = 0; ctx->grub_gettext_max >> ctx->grub_gettext_max_log;
  25. ctx->grub_gettext_max_log++);
  26. - ctx->grub_gettext_msg_list = grub_zalloc (ctx->grub_gettext_max
  27. - * sizeof (ctx->grub_gettext_msg_list[0]));
  28. + ctx->grub_gettext_msg_list = grub_calloc (ctx->grub_gettext_max,
  29. + sizeof (ctx->grub_gettext_msg_list[0]));
  30. if (!ctx->grub_gettext_msg_list)
  31. {
  32. grub_file_close (fd);
  33. --
  34. 2.50.1