From: Simon Horman <horms@verge.net.au>
To: "Dirk Müller" <dirk@dmllr.de>
Cc: kexec@lists.infradead.org
Subject: Re: [PATCH] Avoid buffer overflow on strncat usage
Date: Tue, 4 Feb 2014 21:37:12 +0900 [thread overview]
Message-ID: <20140204123712.GF17028@verge.net.au> (raw)
In-Reply-To: <CAL5wTH52b74cixBSfx84w5HH08hieo=pn8vGTnF_9x4GwMPv9w@mail.gmail.com>
On Tue, Feb 04, 2014 at 01:03:42PM +0100, Dirk Müller wrote:
> Hi Simon,
>
> > I don't think you need the -1 as filename will have a trailing '\0'
> > which is not counted in the return value of strlen()
>
> Thats true, but strncat always writes a trailing NUL, and to avoid
> that this one overflows the buffer, you need to subtract -1.
>
> However, this code in particular can be rewrittten to use snprintf(),
> which avoids
> the overflow and is also a bit more readable.
>
> How about the attached patch?
Looks good, I have applied it.
_______________________________________________
kexec mailing list
kexec@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/kexec
prev parent reply other threads:[~2014-02-04 12:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-03 17:54 [PATCH] Avoid buffer overflow on strncat usage Dirk Müller
2014-02-04 8:30 ` Simon Horman
2014-02-04 12:03 ` Dirk Müller
2014-02-04 12:37 ` Simon Horman [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=20140204123712.GF17028@verge.net.au \
--to=horms@verge.net.au \
--cc=dirk@dmllr.de \
--cc=kexec@lists.infradead.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.