Received: from [140.186.70.92] (port=53957 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OK4Pr-00061F-Kq for qemu-devel@nongnu.org; Thu, 03 Jun 2010 03:00:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OK4Pq-0001xU-J6 for qemu-devel@nongnu.org; Thu, 03 Jun 2010 03:00:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50026) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OK4Pq-0001xL-BF for qemu-devel@nongnu.org; Thu, 03 Jun 2010 03:00:34 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o5370XJx001673 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 3 Jun 2010 03:00:33 -0400 From: Markus Armbruster Subject: Re: [Qemu-devel] [PATCH] block: Fix serial number assignment References: <20100602174631.2f681a4c@redhat.com> Date: Thu, 03 Jun 2010 09:00:29 +0200 In-Reply-To: <20100602174631.2f681a4c@redhat.com> (Luiz Capitulino's message of "Wed, 2 Jun 2010 17:46:31 -0300") Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Luiz Capitulino Cc: kwolf@redhat.com, qemu-devel@nongnu.org Luiz Capitulino writes: > We should use 'dinfo->serial' length, 'serial' is a pointer, so > the serial number length is currently limited to the pointer size. > > This fixes https://bugs.launchpad.net/qemu/+bug/584143 and is also > valid for stable. > > Signed-off-by: Luiz Capitulino > --- > vl.c | 2 +- > 1 files changed, 1 insertions(+), 1 deletions(-) > > diff --git a/vl.c b/vl.c > index 417554f..3de2166 100644 > --- a/vl.c > +++ b/vl.c > @@ -1060,7 +1060,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); > QTAILQ_INSERT_TAIL(&drives, dinfo, next); > > switch(type) { Correct, because dinfo->serial[] is zero-initialized. Patch conflicts with my "blockdev: Collect block device code in new blockdev.c", but resolution is trivial.