All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Koeppe <format_c@online.de>
To: roel.kluin@gmail.com
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] fat: Read buffer overflow
Date: Sat, 08 Aug 2009 15:01:29 +0200	[thread overview]
Message-ID: <4A7D7729.50502@online.de> (raw)
In-Reply-To: <d6Gqb-2HX-3@gated-at.bofh.it>

Roel Kluin schrieb:
> If len is less or equal to 0, this results in a read of s[-1].
> 
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c
> index 6f27853..114ff6d 100644
> --- a/fs/fat/namei_vfat.c
> +++ b/fs/fat/namei_vfat.c
> @@ -202,6 +202,9 @@ static inline int vfat_is_used_badchars(const wchar_t *s, int len)
>  {
>  	int i;
>  
> +	if (len <= 0)
> +		return -EINVAL;
> +
>  	for (i = 0; i < len; i++)
>  		if (vfat_bad_char(s[i]))
>  			return -EINVAL;
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/

This seem to be a bit redundant code.
If len is 0 or less, the loop won't iterate even one time and hence
not read outside the buffer.
The only advantage is, that re function signals the invalid argument.

-- A.Koeppe

       reply	other threads:[~2009-08-08 13:00 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <d6Gqb-2HX-3@gated-at.bofh.it>
2009-08-08 13:01 ` Alexander Koeppe [this message]
2009-08-07 22:48 [PATCH] fat: Read buffer overflow Roel Kluin
2009-08-07 23:06 ` OGAWA Hirofumi
2009-08-08  6:56   ` Pekka Enberg
2009-08-08 10:10     ` OGAWA Hirofumi
2009-08-08 10:12       ` Pekka Enberg
2009-08-08 10:18       ` OGAWA Hirofumi

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=4A7D7729.50502@online.de \
    --to=format_c@online.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roel.kluin@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 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.