From: Joel Becker <Joel.Becker@oracle.com>
To: ocfs2-devel@oss.oracle.com
Subject: [Ocfs2-devel] [PATCH 4/4] ocfs2: add array bounds checking
Date: Thu, 23 Oct 2008 02:30:26 -0700 [thread overview]
Message-ID: <20081023093026.GG1580@mail.oracle.com> (raw)
In-Reply-To: <1224750884-10976-1-git-send-email-tiger.yang@oracle.com>
On Thu, Oct 23, 2008 at 04:34:44PM +0800, Tiger Yang wrote:
> This could avoid arry bounds exceeded issue.
>
> Signed-off-by: Tiger Yang <tiger.yang@oracle.com>
> ---
> fs/ocfs2/xattr.c | 2 +-
> 1 files changed, 1 insertions(+), 1 deletions(-)
>
> diff --git a/fs/ocfs2/xattr.c b/fs/ocfs2/xattr.c
> index 754e5fa..888641d 100644
> --- a/fs/ocfs2/xattr.c
> +++ b/fs/ocfs2/xattr.c
> @@ -164,7 +164,7 @@ static inline const char *ocfs2_xattr_prefix(int name_index)
> {
> struct xattr_handler *handler = NULL;
>
> - if (name_index > 0 && name_index < OCFS2_XATTR_MAX)
> + if (name_index > 0 && name_index < ARRAY_SIZE(ocfs2_xattr_handler_map))
> handler = ocfs2_xattr_handler_map[name_index];
Another option is to define the map as:
static struct xattr_handler *ocfs2_xattr_handler_map[OCFS2_ATTR_MAX] = {
This reuses our nice OCFS2_XATTR_MAX value. But both methods work.
Joel
--
"You cannot bring about prosperity by discouraging thrift. You cannot
strengthen the weak by weakening the strong. You cannot help the wage
earner by pulling down the wage payer. You cannot further the
brotherhood of man by encouraging class hatred. You cannot help the
poor by destroying the rich. You cannot build character and courage by
taking away a man's initiative and independence. You cannot help men
permanently by doing for them what they could and should do for
themselves."
- Abraham Lincoln
Joel Becker
Principal Software Developer
Oracle
E-mail: joel.becker at oracle.com
Phone: (650) 506-8127
next prev parent reply other threads:[~2008-10-23 9:30 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-10-23 8:26 [Ocfs2-devel] ocfs2: some xattr fixes Tiger Yang
2008-10-23 8:33 ` [Ocfs2-devel] [PATCH 1/4] ocfs2: fix license in xattr Tiger Yang
2008-10-23 9:22 ` Joel Becker
2008-10-23 8:33 ` [Ocfs2-devel] [PATCH 2/4] ocfs2: fix function declaration and definition " Tiger Yang
2008-10-23 9:23 ` Joel Becker
2008-10-23 8:34 ` [Ocfs2-devel] [PATCH 3/4] ocfs2: remove duplicate " Tiger Yang
2008-10-23 9:25 ` Joel Becker
2008-10-23 8:34 ` [Ocfs2-devel] [PATCH 4/4] ocfs2: add array bounds checking Tiger Yang
2008-10-23 9:30 ` Joel Becker [this message]
2008-10-23 10:06 ` Tiger Yang
2008-10-23 22:09 ` Joel Becker
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=20081023093026.GG1580@mail.oracle.com \
--to=joel.becker@oracle.com \
--cc=ocfs2-devel@oss.oracle.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.