From: Ian Kent <raven@themaw.net>
To: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
Cc: autofs@vger.kernel.org
Subject: Re: [PATCH] automount: Fix size arg of fgets(3)
Date: Wed, 06 Jul 2016 18:02:06 +0800 [thread overview]
Message-ID: <1467799326.4580.54.camel@themaw.net> (raw)
In-Reply-To: <1467642685-2117-1-git-send-email-kusumi.tomohiro@gmail.com>
On Mon, 2016-07-04 at 23:31 +0900, Tomohiro Kusumi wrote:
> Since fgets(3) reads at most 1 less than size arg, it should
> probably pass MAX_LINE_LEN+1 given that the conditional in the
> next line tests if strlen() exceeds MAX_LINE_LEN.
> (i.e. MAX_LINE_LEN isn't designed to include terminating \0)
>
> buf has MAX_LINE_LEN+2 bytes, so passing MAX_LINE_LEN+1 is ok.
And also added.
>
> Signed-off-by: Tomohiro Kusumi <kusumi.tomohiro@gmail.com>
> ---
> lib/defaults.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/defaults.c b/lib/defaults.c
> index 0e48a78..ae76513 100644
> --- a/lib/defaults.c
> +++ b/lib/defaults.c
> @@ -879,7 +879,7 @@ static int read_config(unsigned int to_syslog, FILE *f,
> const char *name)
> char *res;
>
> new_sec = NULL;
> - while ((res = fgets(buf, MAX_LINE_LEN, f))) {
> + while ((res = fgets(buf, MAX_LINE_LEN + 1, f))) {
> char *sec, *key, *value;
>
> if (strlen(res) > MAX_LINE_LEN) {
--
To unsubscribe from this list: send the line "unsubscribe autofs" in
prev parent reply other threads:[~2016-07-06 10:02 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-04 14:31 [PATCH] automount: Fix size arg of fgets(3) Tomohiro Kusumi
2016-07-06 10:02 ` Ian Kent [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=1467799326.4580.54.camel@themaw.net \
--to=raven@themaw.net \
--cc=autofs@vger.kernel.org \
--cc=kusumi.tomohiro@gmail.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 read-only IMAP folder(s) and NNTP newsgroup(s).