From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=58587 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OKFnq-0001qY-Cb for qemu-devel@nongnu.org; Thu, 03 Jun 2010 15:10:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OKFno-00035t-6Y for qemu-devel@nongnu.org; Thu, 03 Jun 2010 15:10:05 -0400 Received: from mail-iw0-f173.google.com ([209.85.214.173]:36315) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OKFno-00035l-3j for qemu-devel@nongnu.org; Thu, 03 Jun 2010 15:10:04 -0400 Received: by iwn41 with SMTP id 41so308208iwn.4 for ; Thu, 03 Jun 2010 12:10:03 -0700 (PDT) Message-ID: <4C07FE08.9020708@codemonkey.ws> Date: Thu, 03 Jun 2010 14:10:00 -0500 From: Anthony Liguori MIME-Version: 1.0 References: <4BAAF58E.4050507@redhat.com> In-Reply-To: <4BAAF58E.4050507@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] Re: [PATCH 2/4] Add virtio disk identification support List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: john cooper Cc: Rusty Russell , Marc Haber , qemu-devel@nongnu.org On 03/25/2010 12:33 AM, john cooper wrote: > Fix bug which truncated serial string to 8 bytes, nul terminate. > > Signed-off-by: john cooper > --- > > diff --git a/vl.c b/vl.c > index d69250c..b74cbba 100644 > --- a/vl.c > +++ b/vl.c > @@ -1162,7 +1162,7 @@ DriveInfo *drive_init(QemuOpts *opts, void *opaque, > dinfo->on_write_error = on_write_error; > dinfo->opts = opts; > if (serial) > - strncpy(dinfo->serial, serial, sizeof(serial)); > + strncpy(dinfo->serial, serial, sizeof(dinfo->serial) - 1); > You need to explicitly add a null terminator. Far better to just never use strncpy(). Regards, Anthony Liguori > QTAILQ_INSERT_TAIL(&drives, dinfo, next); > > switch(type) { > >