grub2/grub-2.00-no-huge-video.patch
2012-06-02 01:54:48 +02:00

67 lines
2.7 KiB
Diff

From: Valdimir Serbinenko <phcoder@gmail.com>
Subject: Reject huge flat panels and monitors over 4096x4096
https://bugzilla.redhat.com/show_bug.cgi?id=827003
Backport upstream rev 4412
diff --git a/grub-core/video/efi_gop.c b/grub-core/video/efi_gop.c
index 3e1cc23..4628dd0 100644
--- a/grub-core/video/efi_gop.c
+++ b/grub-core/video/efi_gop.c
@@ -368,7 +368,7 @@ grub_video_gop_setup (unsigned int width, unsigned int height,
{
err = 1;
grub_gop_get_preferred_mode (&preferred_width, &preferred_height);
- if (err)
+ if (err || width >= 4096 || height >= 4096)
{
preferred_width = 800;
preferred_height = 600;
diff --git a/grub-core/video/i386/pc/vbe.c b/grub-core/video/i386/pc/vbe.c
index 5656388..62e530a 100644
--- a/grub-core/video/i386/pc/vbe.c
+++ b/grub-core/video/i386/pc/vbe.c
@@ -581,7 +581,6 @@ grub_vbe_get_preferred_mode (unsigned int *width, unsigned int *height)
/* Use low memory scratch area as temporary storage for VESA BIOS calls. */
flat_panel_info = (struct grub_vbe_flat_panel_info *)
(GRUB_MEMORY_MACHINE_SCRATCH_ADDR + sizeof (struct grub_video_edid_info));
- grub_memset (flat_panel_info, 0, sizeof (*flat_panel_info));
if (controller_info.version >= 0x200
&& (grub_vbe_bios_get_ddc_capabilities (&ddc_level) & 0xff)
@@ -590,14 +589,18 @@ grub_vbe_get_preferred_mode (unsigned int *width, unsigned int *height)
if (grub_video_vbe_get_edid (&edid_info) == GRUB_ERR_NONE
&& grub_video_edid_checksum (&edid_info) == GRUB_ERR_NONE
&& grub_video_edid_preferred_mode (&edid_info, width, height)
- == GRUB_ERR_NONE)
+ == GRUB_ERR_NONE && *width < 4096 && *height < 4096)
return GRUB_ERR_NONE;
grub_errno = GRUB_ERR_NONE;
}
+ grub_memset (flat_panel_info, 0, sizeof (*flat_panel_info));
status = grub_vbe_bios_get_flat_panel_info (flat_panel_info);
- if (status == GRUB_VBE_STATUS_OK)
+ if (status == GRUB_VBE_STATUS_OK
+ && flat_panel_info->horizontal_size && flat_panel_info->vertical_size
+ && flat_panel_info->horizontal_size < 4096
+ && flat_panel_info->vertical_size < 4096)
{
*width = flat_panel_info->horizontal_size;
*height = flat_panel_info->vertical_size;
diff --git a/grub-core/video/video.c b/grub-core/video/video.c
index 67de85a..c36994f 100644
--- a/grub-core/video/video.c
+++ b/grub-core/video/video.c
@@ -415,7 +415,8 @@ grub_video_edid_preferred_mode (struct grub_video_edid_info *edid_info,
| (((unsigned int)
(edid_info->detailed_timings[0].vertical_hi & 0xf0))
<< 4);
- return GRUB_ERR_NONE;
+ if (*width && *height)
+ return GRUB_ERR_NONE;
}
return grub_error (GRUB_ERR_BAD_DEVICE, "no preferred mode available");