aboutsummaryrefslogtreecommitdiffstats
path: root/com32/modules
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2009-12-28 16:24:48 -0800
committerH. Peter Anvin <hpa@zytor.com>2009-12-28 16:24:48 -0800
commit7b23d156550f3c6ad239c88912d7727b2b615aa8 (patch)
tree27bc3d148b271be135edf4c050f803775716d91f /com32/modules
parent72755af2664dcea9d699fa6b8e0af72867bb5d72 (diff)
downloadsyslinux.git-7b23d156550f3c6ad239c88912d7727b2b615aa8.tar.gz
syslinux.git-7b23d156550f3c6ad239c88912d7727b2b615aa8.tar.xz
syslinux.git-7b23d156550f3c6ad239c88912d7727b2b615aa8.zip
chain.c: do a proper copy operation for the cmldr signature
Instead of writing into memory that we might not own, create a proper copy operation using syslinux_add_movelist(). Signed-off-by: H. Peter Anvin <hpa@zytor.com>
Diffstat (limited to 'com32/modules')
-rw-r--r--com32/modules/chain.c23
1 files changed, 14 insertions, 9 deletions
diff --git a/com32/modules/chain.c b/com32/modules/chain.c
index 1ae20d4a..c5154888 100644
--- a/com32/modules/chain.c
+++ b/com32/modules/chain.c
@@ -455,6 +455,7 @@ static void do_boot(void *boot_sector, size_t boot_size,
uint8_t swapdrive = driveno & 0x80;
int i;
addr_t loadbase = opt.seg ? (opt.seg << 4) : 0x7c00;
+ static const char cmldr_signature[8] = "cmdcons";
mmap = syslinux_memory_map();
@@ -470,10 +471,21 @@ static void do_boot(void *boot_sector, size_t boot_size,
endimage = loadbase + boot_size;
- if (syslinux_add_movelist
- (&mlist, loadbase, (addr_t) boot_sector, boot_size))
+ if (syslinux_add_movelist(&mlist, loadbase,
+ (addr_t) boot_sector, boot_size))
goto enomem;
+ /*
+ * To boot the Recovery Console of Windows NT/2K/XP we need to write
+ * the string "cmdcons\0" to memory location 0000:7C03.
+ * Memory location 0000:7C00 contains the bootsector of the partition.
+ */
+ if (opt.cmldr) {
+ if (syslinux_add_movelist(&mlist, 0x7c03, (addr_t)cmldr_signature,
+ sizeof cmldr_signature))
+ goto enomem;
+ }
+
if (opt.swap && driveno != swapdrive) {
static const uint8_t swapstub_master[] = {
/* The actual swap code */
@@ -886,13 +898,6 @@ int main(int argc, char *argv[])
}
}
- /* To boot the Recovery Console of Windows NT/2K/XP we need to write
- the string "cmdcons\0" to memory location 0000:7C03.
- Memory location 0000:7C00 contains the bootsector of the partition.
- */
- if (opt.cmldr)
- strcpy((char *) 0x7c03, "cmdcons");
-
} else if (partinfo) {
/* Actually read the boot sector */
/* Pick the first buffer that isn't already in use */