[syslinux:dynamic-sector] installer: Update and correct generate_extents()

syslinux-bot for H. Peter Anvin hpa at linux.intel.com
Tue Apr 5 14:27:32 PDT 2011


Commit-ID:  3c123fd0201e0421386aefa02a362ca2a1f860e5
Gitweb:     http://syslinux.zytor.com/commit/3c123fd0201e0421386aefa02a362ca2a1f860e5
Author:     H. Peter Anvin <hpa at linux.intel.com>
AuthorDate: Tue, 5 Apr 2011 14:24:07 -0700
Committer:  H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Tue, 5 Apr 2011 14:24:07 -0700

installer: Update and correct generate_extents()

1. Make sure extents are strictly less than 64K in size
2. Make sure extents do not cross 64K boundaries

Signed-off-by: H. Peter Anvin <hpa at linux.intel.com>


---
 libinstaller/syslxmod.c |   21 ++++++++++++---------
 1 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/libinstaller/syslxmod.c b/libinstaller/syslxmod.c
index a68f19f..8847b73 100644
--- a/libinstaller/syslxmod.c
+++ b/libinstaller/syslxmod.c
@@ -33,26 +33,29 @@
 static void generate_extents(struct syslinux_extent *ex, int nptrs,
 			     const sector_t *sectp, int nsect)
 {
-    uint32_t addr = 0x7c00 + 2*SECTOR_SIZE;
+    uint32_t addr = 0x8000;	/* ldlinux.sys starts loading here */
     uint32_t base;
     sector_t sect, lba;
     unsigned int len;
 
-    len = lba = base = 0;
+    base = addr;
+    len = lba = 0;
 
     memset(ex, 0, nptrs * sizeof *ex);
 
     while (nsect) {
 	sect = *sectp++;
 
-	if (len && sect == lba + len &&
-	    ((addr ^ (base + len * SECTOR_SIZE)) & 0xffff0000) == 0) {
-	    /* We can add to the current extent */
-	    len++;
-	    goto next;
-	}
-
 	if (len) {
+	    uint32_t xbytes = (len + 1) * SECTOR_SIZE;
+
+	    if (sect == lba + len && xbytes < 65536 &&
+		((addr ^ (base + xbytes - 1)) & 0xffff0000) == 0) {
+		/* We can add to the current extent */
+		len++;
+		goto next;
+	    }
+
 	    set_64_sl(&ex->lba, lba);
 	    set_16_sl(&ex->len, len);
 	    ex++;



More information about the Syslinux-commits mailing list