syslinux: fix sector arrays
authorAlek Du <alek.du@intel.com>
Thu, 20 May 2010 10:24:35 +0000 (18:24 +0800)
committerH. Peter Anvin <hpa@zytor.com>
Fri, 21 May 2010 02:57:44 +0000 (19:57 -0700)
The first sector ptr is in bs->NextSector not in the array in
the patch_area. And actually the ADV sectors counting is wrong for a
while ...

Signed-off-by: Alek Du <alek.du@intel.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
core/adv.inc
extlinux/main.c
libinstaller/syslxmod.c

index 2dc1633..6725261 100644 (file)
@@ -77,8 +77,8 @@ adv_init:
                mov bx,[DataSectors]
                shl bx,2
                mov ecx,[bsHidden]
-               mov eax,[bx+SectorPtrs]         ; First ADV sector
-               mov edx,[bx+SectorPtrs+4]       ; Second ADV sector
+               mov eax,[bx+SectorPtrs-4]; First ADV sector
+               mov edx,[bx+SectorPtrs] ; Second ADV sector
                add eax,ecx
                add edx,ecx
                mov [ADVSec0],eax
index dea2d19..6bf6872 100644 (file)
@@ -561,7 +561,7 @@ int patch_file_and_bootblock(int fd, const char *dir, int devfd)
     nptrs = get_16(&patcharea->secptrcnt);
 
     memset(wp, 0, nptrs * 4);
-    while (nsect--)
+    while (--nsect) /* the first sector in bs->NextSector */
        set_32(wp++, *sectp++);
 
     /* Poke in the base directory path */
index e18d8a6..be06b9a 100644 (file)
@@ -269,7 +269,7 @@ int syslinux_patch(const uint32_t * sectors, int nsectors,
                       get_16_sl(&patcharea->secptroffset));
     nptrs = get_16_sl(&patcharea->secptrcnt);
 
-    while (nsect--) {
+    while (--nsect) { /* the first sector is in bs->NextSector */
        set_32_sl(wp++, *sectors++);
        nptrs--;
     }