From: "Aneesh Kumar K.V" <aneesh.kumar@linux.vnet.ibm.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] fsdev: Fix overrun after readlink() fills buffer completely
Date: Wed, 26 Feb 2014 12:25:32 +0530 [thread overview]
Message-ID: <87sir6fjmj.fsf@linux.vnet.ibm.com> (raw)
In-Reply-To: <1393000989-8502-1-git-send-email-armbru@redhat.com>
Markus Armbruster <armbru@redhat.com> writes:
> 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>
applied.
> ---
> 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 713a7b2..bfecb87 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.1.4
prev parent reply other threads:[~2014-02-26 6:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-21 16:43 [Qemu-devel] [PATCH] fsdev: Fix overrun after readlink() fills buffer completely Markus Armbruster
2014-02-26 6:55 ` Aneesh Kumar K.V [this message]
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=87sir6fjmj.fsf@linux.vnet.ibm.com \
--to=aneesh.kumar@linux.vnet.ibm.com \
--cc=armbru@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).