From: Jim Meyering <jim@meyering.net>
To: qemu-devel@nongnu.org
Cc: Jim Meyering <meyering@redhat.com>
Subject: [Qemu-devel] [PATCHv3 06/20] hw/9pfs: avoid buffer overrun
Date: Thu, 4 Oct 2012 13:09:49 +0200 [thread overview]
Message-ID: <1349349003-15672-7-git-send-email-jim@meyering.net> (raw)
In-Reply-To: <1349349003-15672-1-git-send-email-jim@meyering.net>
From: Jim Meyering <meyering@redhat.com>
v9fs_add_dir_node and qemu_v9fs_synth_add_file used strncpy
to form node->name, which requires NUL-termination, but
strncpy does not ensure NUL-termination.
Use pstrcpy, which does.
Acked-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
Signed-off-by: Jim Meyering <meyering@redhat.com>
---
hw/9pfs/virtio-9p-synth.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/hw/9pfs/virtio-9p-synth.c b/hw/9pfs/virtio-9p-synth.c
index 92e0b09..e95a856 100644
--- a/hw/9pfs/virtio-9p-synth.c
+++ b/hw/9pfs/virtio-9p-synth.c
@@ -58,7 +58,7 @@ static V9fsSynthNode *v9fs_add_dir_node(V9fsSynthNode *parent, int mode,
node->attr->read = NULL;
}
node->private = node;
- strncpy(node->name, name, sizeof(node->name));
+ pstrcpy(node->name, sizeof(node->name), name);
QLIST_INSERT_HEAD_RCU(&parent->child, node, sibling);
return node;
}
@@ -132,7 +132,7 @@ int qemu_v9fs_synth_add_file(V9fsSynthNode *parent, int mode,
node->attr->write = write;
node->attr->mode = mode;
node->private = arg;
- strncpy(node->name, name, sizeof(node->name));
+ pstrcpy(node->name, sizeof(node->name), name);
QLIST_INSERT_HEAD_RCU(&parent->child, node, sibling);
ret = 0;
err_out:
--
1.8.0.rc0.18.gf84667d
next prev parent reply other threads:[~2012-10-04 11:11 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-10-04 11:09 [Qemu-devel] [PATCHv3 00/20] strncpy: best avoided Jim Meyering
2012-10-04 11:09 ` [Qemu-devel] [PATCHv3 01/20] scsi, pci, qdev, isa-bus, sysbus: don't let *_get_fw_dev_path return NULL Jim Meyering
2012-10-05 21:17 ` Anthony Liguori
2012-10-04 11:09 ` [Qemu-devel] [PATCHv3 02/20] sparc: use g_strdup in place of unchecked strdup Jim Meyering
2012-10-04 11:09 ` [Qemu-devel] [PATCHv3 03/20] block: avoid buffer overrun by using pstrcpy, not strncpy Jim Meyering
2012-10-04 11:09 ` [Qemu-devel] [PATCHv3 04/20] sheepdog: avoid a few buffer overruns Jim Meyering
2012-10-04 11:09 ` [Qemu-devel] [PATCHv3 05/20] vmdk: relative_path: use pstrcpy in place of strncpy Jim Meyering
2012-10-04 11:09 ` Jim Meyering [this message]
2012-10-04 11:09 ` [Qemu-devel] [PATCHv3 07/20] lm32: avoid buffer overrun Jim Meyering
2012-10-04 11:09 ` [Qemu-devel] [PATCHv3 08/20] os-posix: " Jim Meyering
2012-10-04 11:09 ` [Qemu-devel] [PATCHv3 09/20] ppc: avoid buffer overrun: use pstrcpy, not strncpy Jim Meyering
2012-10-04 11:09 ` [Qemu-devel] [PATCHv3 10/20] linux-user: remove two unchecked uses of strdup Jim Meyering
2012-10-04 11:09 ` [Qemu-devel] [PATCHv3 11/20] ui/vnc: simplify and avoid strncpy Jim Meyering
2012-10-04 18:48 ` Peter Maydell
2012-10-04 18:56 ` Jim Meyering
2012-10-04 19:02 ` Peter Maydell
2012-10-04 11:09 ` [Qemu-devel] [PATCHv3 12/20] bt: replace fragile snprintf use and unwarranted strncpy Jim Meyering
2012-10-04 11:09 ` [Qemu-devel] [PATCHv3 13/20] virtio-9p: avoid unwarranted uses of strncpy Jim Meyering
2012-10-04 11:09 ` [Qemu-devel] [PATCHv3 14/20] vscsi: avoid unwarranted strncpy Jim Meyering
2012-10-04 11:09 ` [Qemu-devel] [PATCHv3 15/20] qemu-ga: prefer pstrcpy: consistently NUL-terminate ifreq.ifr_name Jim Meyering
2012-10-04 11:09 ` [Qemu-devel] [PATCHv3 16/20] libcacard/vcard_emul_nss: use pstrcpy in place of strncpy Jim Meyering
2012-10-04 11:10 ` [Qemu-devel] [PATCHv3 17/20] acpi: remove strzcpy (strncpy-identical) function; just use strncpy Jim Meyering
2012-10-04 11:10 ` [Qemu-devel] [PATCHv3 18/20] qcow2: mark this file's sole strncpy use as justified Jim Meyering
2012-10-04 11:10 ` [Qemu-devel] [PATCHv3 19/20] hw/r2d: add comment: this strncpy use is ok Jim Meyering
2012-10-04 11:10 ` [Qemu-devel] [PATCHv3 20/20] doc: update HACKING wrt strncpy/pstrcpy Jim Meyering
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1349349003-15672-7-git-send-email-jim@meyering.net \
--to=jim@meyering.net \
--cc=meyering@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).