qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] Re: [PATCH 2/4] Add virtio disk identification support


From: Anthony Liguori
Subject: [Qemu-devel] Re: [PATCH 2/4] Add virtio disk identification support
Date: Thu, 03 Jun 2010 14:10:00 -0500
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.9) Gecko/20100423 Lightning/1.0b1 Thunderbird/3.0.4

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<address@hidden>
---

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) {





reply via email to

[Prev in Thread] Current Thread [Next in Thread]