[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[2597] 2009-09-15 Vladimir Serbinenko <address@hidden>
From: |
Vladimir Serbinenko |
Subject: |
[2597] 2009-09-15 Vladimir Serbinenko <address@hidden> |
Date: |
Tue, 15 Sep 2009 10:36:29 +0000 |
Revision: 2597
http://svn.sv.gnu.org/viewvc/?view=rev&root=grub&revision=2597
Author: phcoder
Date: 2009-09-15 10:36:29 +0000 (Tue, 15 Sep 2009)
Log Message:
-----------
2009-09-15 Vladimir Serbinenko <address@hidden>
* partmap/pc.c (pc_partition_map_iterate): Detect and break loops.
Modified Paths:
--------------
trunk/grub2/ChangeLog
trunk/grub2/partmap/msdos.c
Modified: trunk/grub2/ChangeLog
===================================================================
--- trunk/grub2/ChangeLog 2009-09-14 19:57:45 UTC (rev 2596)
+++ trunk/grub2/ChangeLog 2009-09-15 10:36:29 UTC (rev 2597)
@@ -1,3 +1,7 @@
+2009-09-15 Vladimir Serbinenko <address@hidden>
+
+ * partmap/pc.c (pc_partition_map_iterate): Detect and break loops.
+
2009-09-14 Colin Watson <address@hidden>
* commands/test.c (get_fileinfo): Return immediately if
Modified: trunk/grub2/partmap/msdos.c
===================================================================
--- trunk/grub2/partmap/msdos.c 2009-09-14 19:57:45 UTC (rev 2596)
+++ trunk/grub2/partmap/msdos.c 2009-09-15 10:36:29 UTC (rev 2597)
@@ -97,6 +97,8 @@
struct grub_msdos_partition_mbr mbr;
struct grub_msdos_partition_disk_label label;
struct grub_disk raw;
+ int labeln = 0;
+ grub_disk_addr_t lastaddr;
/* Enforce raw disk access. */
raw = *disk;
@@ -117,6 +119,18 @@
if (grub_disk_read (&raw, p.offset, 0, sizeof (mbr), &mbr))
goto finish;
+ /* This is our loop-detection algorithm. It works the following way:
+ It saves last position which was a power of two. Then it compares the
+ saved value with a current one. This way it's guaranteed that the loop
+ will be broken by at most third walk.
+ */
+ if (labeln && lastaddr == p.offset)
+ return grub_error (GRUB_ERR_BAD_PART_TABLE, "loop detected");
+
+ labeln++;
+ if ((labeln & (labeln - 1)) == 0)
+ lastaddr = p.offset;
+
/* Check if it is valid. */
if (mbr.signature != grub_cpu_to_le16 (GRUB_PC_PARTITION_SIGNATURE))
return grub_error (GRUB_ERR_BAD_PART_TABLE, "no signature");
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [2597] 2009-09-15 Vladimir Serbinenko <address@hidden>,
Vladimir Serbinenko <=