From: NeilBrown <neilb@suse.de>
To: Thomas Jarosch <thomas.jarosch@intra2net.com>
Cc: linux-raid@vger.kernel.org
Subject: Re: [mdadm PATCH 2/2] Fix unterminated buffer after readlink() call
Date: Mon, 17 Oct 2011 11:19:19 +1100 [thread overview]
Message-ID: <20111017111919.41c8157c@notabene.brown> (raw)
In-Reply-To: <201110131122.14099.thomas.jarosch@intra2net.com>
[-- Attachment #1: Type: text/plain, Size: 949 bytes --]
On Thu, 13 Oct 2011 11:22:13 +0200 Thomas Jarosch
<thomas.jarosch@intra2net.com> wrote:
>
> Signed-off-by: Thomas Jarosch <thomas.jarosch@intra2net.com>
> ---
> mdopen.c | 6 +++++-
> 1 files changed, 5 insertions(+), 1 deletions(-)
>
> diff --git a/mdopen.c b/mdopen.c
> index 0a17421..555ab84 100644
> --- a/mdopen.c
> +++ b/mdopen.c
> @@ -360,8 +360,12 @@ int create_mddev(char *dev, char *name, int autof, int trustworthy,
>
> if (lstat(chosen, &stb) == 0) {
> char buf[300];
> + ssize_t link_len = readlink(chosen, buf, sizeof(buf)-1);
> + if (link_len >= 0)
> + buf[link_len] = '\0';
> +
> if ((stb.st_mode & S_IFMT) != S_IFLNK ||
> - readlink(chosen, buf, 300) <0 ||
> + link_len < 0 ||
> strcmp(buf, devname) != 0) {
> fprintf(stderr, Name ": %s exists - ignoring\n",
> chosen);
Thanks. I've applied this and the other one.
NeilBrown
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 828 bytes --]
prev parent reply other threads:[~2011-10-17 0:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-13 9:22 [mdadm PATCH 2/2] Fix unterminated buffer after readlink() call Thomas Jarosch
2011-10-17 0:19 ` NeilBrown [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=20111017111919.41c8157c@notabene.brown \
--to=neilb@suse.de \
--cc=linux-raid@vger.kernel.org \
--cc=thomas.jarosch@intra2net.com \
/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).