From: H. Peter Anvin Date: Tue, 29 Dec 2009 00:24:48 +0000 (-0800) Subject: chain.c: do a proper copy operation for the cmldr signature X-Git-Tag: syslinux-3.85-pre1~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7b23d156550f3c6ad239c88912d7727b2b615aa8;p=platform%2Fupstream%2Fsyslinux.git 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 --- diff --git a/com32/modules/chain.c b/com32/modules/chain.c index 1ae20d4..c515488 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 */