2
1

0067-loader-i386-linux-Cast-left-shift-to-grub_uint32_t.patch 1.3 KB

1234567891011121314151617181920212223242526272829303132333435
  1. From 3668d0c12b0604d08cf290529797c348a59483ea Mon Sep 17 00:00:00 2001
  2. From: Alec Brown <alec.r.brown@oracle.com>
  3. Date: Fri, 7 Feb 2025 01:47:57 +0000
  4. Subject: [PATCH] loader/i386/linux: Cast left shift to grub_uint32_t
  5. The Coverity complains that we might overflow into a negative value when
  6. setting linux_params.kernel_alignment to (1 << align). We can remedy
  7. this by casting it to grub_uint32_t.
  8. Fixes: CID 473876
  9. Signed-off-by: Alec Brown <alec.r.brown@oracle.com>
  10. Reviewed-by: Daniel Kiper <daniel.kiper@oracle.com>
  11. Upstream: 490a6ab71cebd96fae7a1ceb9067484f5ccbec2a
  12. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
  13. ---
  14. grub-core/loader/i386/linux.c | 2 +-
  15. 1 file changed, 1 insertion(+), 1 deletion(-)
  16. diff --git a/grub-core/loader/i386/linux.c b/grub-core/loader/i386/linux.c
  17. index 977757f2c..b051600c8 100644
  18. --- a/grub-core/loader/i386/linux.c
  19. +++ b/grub-core/loader/i386/linux.c
  20. @@ -806,7 +806,7 @@ grub_cmd_linux (grub_command_t cmd __attribute__ ((unused)),
  21. }
  22. linux_params.code32_start = prot_mode_target + lh.code32_start - GRUB_LINUX_BZIMAGE_ADDR;
  23. - linux_params.kernel_alignment = (1 << align);
  24. + linux_params.kernel_alignment = ((grub_uint32_t) 1 << align);
  25. linux_params.ps_mouse = linux_params.padding11 = 0;
  26. linux_params.type_of_loader = GRUB_LINUX_BOOT_LOADER_TYPE;
  27. --
  28. 2.50.1