qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: anthony@codemonkey.ws, peter.maydell@linaro.org
Cc: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>,
	qemu-devel@nongnu.org, Markus Armbruster <armbru@redhat.com>
Subject: [Qemu-devel] [PATCH 1/5] fsdev: Fix overrun after readlink() fills buffer completely
Date: Fri,  7 Mar 2014 20:46:16 +0530	[thread overview]
Message-ID: <1394205380-31875-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com> (raw)
In-Reply-To: <1394205380-31875-1-git-send-email-aneesh.kumar@linux.vnet.ibm.com>

From: Markus Armbruster <armbru@redhat.com>

readlink() returns the number of bytes written to the buffer, and it
doesn't write a terminating null byte.  do_readlink() writes it
itself.  Overruns the buffer when readlink() filled it completely.

Fix by reserving space for the null byte when calling readlink(), like
we do elsewhere.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.vnet.ibm.com>
---
 fsdev/virtfs-proxy-helper.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fsdev/virtfs-proxy-helper.c b/fsdev/virtfs-proxy-helper.c
index 713a7b2b87a4..bfecb8706c85 100644
--- a/fsdev/virtfs-proxy-helper.c
+++ b/fsdev/virtfs-proxy-helper.c
@@ -595,7 +595,7 @@ static int do_readlink(struct iovec *iovec, struct iovec *out_iovec)
     }
     buffer = g_malloc(size);
     v9fs_string_init(&target);
-    retval = readlink(path.data, buffer, size);
+    retval = readlink(path.data, buffer, size - 1);
     if (retval > 0) {
         buffer[retval] = '\0';
         v9fs_string_sprintf(&target, "%s", buffer);
-- 
1.8.3.2

  reply	other threads:[~2014-03-07 15:16 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-07 15:16 [Qemu-devel] [PULL] VirtFS update Aneesh Kumar K.V
2014-03-07 15:16 ` Aneesh Kumar K.V [this message]
2014-03-07 15:16 ` [Qemu-devel] [PATCH 2/5] hw/9pfs/virtio-9p-local.c: move v9fs_string_free() to below "err_out:" Aneesh Kumar K.V
2014-03-07 15:16 ` [Qemu-devel] [PATCH 3/5] hw/9pfs/virtio-9p-local.c: use snprintf() instead of sprintf() Aneesh Kumar K.V
2014-03-07 15:16 ` [Qemu-devel] [PATCH 4/5] hw/9pfs: use g_strdup_printf() instead of PATH_MAX limitation Aneesh Kumar K.V
2014-03-08 13:58   ` Chen Gang
2014-03-16 13:32     ` Chen Gang
2014-03-18  0:31       ` [Qemu-devel] [PATCH trivial] target-arm/gdbstub64.c: remove useless 'break' statement Chen Gang
2014-03-18  0:39         ` Peter Maydell
2014-03-18  0:53           ` Chen Gang
2014-03-18  5:14         ` Peter Crosthwaite
2014-03-19  3:25           ` Chen Gang
2014-03-23 13:27       ` [Qemu-devel] [PATCH 4/5] hw/9pfs: use g_strdup_printf() instead of PATH_MAX limitation Chen Gang
2014-03-07 15:16 ` [Qemu-devel] [PATCH 5/5] hw/9pfs: Include virtio-9p-device.o in build Aneesh Kumar K.V
2014-03-07 15:30   ` Andreas Färber
2014-03-07 17:07     ` Aneesh Kumar K.V
2014-03-08 12:52 ` [Qemu-devel] [PULL] VirtFS update Peter Maydell

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=1394205380-31875-2-git-send-email-aneesh.kumar@linux.vnet.ibm.com \
    --to=aneesh.kumar@linux.vnet.ibm.com \
    --cc=anthony@codemonkey.ws \
    --cc=armbru@redhat.com \
    --cc=peter.maydell@linaro.org \
    --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).