From patchwork Wed Jun 2 20:46:31 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: block: Fix serial number assignment Date: Wed, 02 Jun 2010 10:46:31 -0000 From: Luiz Capitulino X-Patchwork-Id: 54433 Message-Id: <20100602174631.2f681a4c@redhat.com> To: qemu-devel@nongnu.org Cc: kwolf@redhat.com 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) {