summaryrefslogtreecommitdiff
path: root/blockdev.c
diff options
context:
space:
mode:
authorFloris Bos <bos@je-eigen-domein.nl>2012-03-12 21:05:10 +0100
committerKevin Wolf <kwolf@redhat.com>2012-04-05 14:54:39 +0200
commitaa2c91bdfebbfa314e9522573a9656626e21ac67 (patch)
treea2a3b4d00a58a145f0be146b3a03de1f0fcf4101 /blockdev.c
parent27e0c9a1bbd166a67c16291016fba298a8e47140 (diff)
downloadqemu-aa2c91bdfebbfa314e9522573a9656626e21ac67.tar.gz
ide: Change serial number strncpy() to pstrcpy()
strncpy may not null-terminate the destination string. Cc: kwolf@redhat.com Signed-off-by: Floris Bos <dev@noc-ps.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'blockdev.c')
-rw-r--r--blockdev.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/blockdev.c b/blockdev.c
index 1a500b830d..f5e7dba90c 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -532,8 +532,9 @@ DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
dinfo->unit = unit_id;
dinfo->opts = opts;
dinfo->refcount = 1;
- if (serial)
- strncpy(dinfo->serial, serial, sizeof(dinfo->serial) - 1);
+ if (serial) {
+ pstrcpy(dinfo->serial, sizeof(dinfo->serial), serial);
+ }
QTAILQ_INSERT_TAIL(&drives, dinfo, next);
bdrv_set_on_error(dinfo->bdrv, on_read_error, on_write_error);