From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1IkyPC-0001XI-R3 for qemu-devel@nongnu.org; Thu, 25 Oct 2007 04:49:30 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1IkyPB-0001Ur-4c for qemu-devel@nongnu.org; Thu, 25 Oct 2007 04:49:30 -0400 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1IkyPB-0001Uj-0Q for qemu-devel@nongnu.org; Thu, 25 Oct 2007 04:49:29 -0400 Received: from os.inf.tu-dresden.de ([141.76.48.99]) by monty-python.gnu.org with esmtps (TLS-1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1IkyPA-0006vP-LL for qemu-devel@nongnu.org; Thu, 25 Oct 2007 04:49:28 -0400 Received: from erwin.inf.tu-dresden.de ([141.76.48.80] helo=chrom.inf.tu-dresden.de) by os.inf.tu-dresden.de with esmtps (TLSv1:AES256-SHA:256) (Exim 4.68) id 1IkyP8-0008JZ-4s for qemu-devel@nongnu.org; Thu, 25 Oct 2007 10:49:26 +0200 Received: from kauer by chrom.inf.tu-dresden.de with local (Exim 4.67) (envelope-from ) id 1IkyP7-0001qY-KK for qemu-devel@nongnu.org; Thu, 25 Oct 2007 10:49:25 +0200 Date: Thu, 25 Oct 2007 10:49:25 +0200 From: Bernhard Kauer Subject: Re: [Qemu-devel] [Patch] set boot sequence from command line Message-ID: <20071025084925.GC3182@chrom.inf.tu-dresden.de> References: <20071024084611.GA10261@karma.qumranet.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20071024084611.GA10261@karma.qumranet.com> Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org It is perhaps not the best idea to read behind the end of the boot_device string. It would be safer to declare boot_device as 'static char boot_device[4]' and use a strncpy. Bernhard > diff --git a/hw/pc.c b/hw/pc.c > index a0c824f..3c552ff 100644 > --- a/hw/pc.c > +++ b/hw/pc.c > + /* set boot devices, and disable floppy signature check if requested */ > + rtc_set_memory(s, 0x3d, > + boot_device2nible(boot_device[1]) << 4 | > + boot_device2nible(boot_device[0]) ); > + rtc_set_memory(s, 0x38, > + boot_device2nible(boot_device[2]) << 4 | (fd_bootchk ? 0x0 : 0x1)); > > /* floppy type */ > diff --git a/vl.c b/vl.c > index 6d8fe35..be0e06a 100644 > --- a/vl.c > +++ b/vl.c > + if (strlen(optarg) > 3) { > + fprintf(stderr, "qemu: too many boot devices\n"); > + exit(1); > + } > + boot_device = strdup(optarg); > + if (!strchr(boot_device, 'a') &&