From: Alex Elder <aelder@sgi.com>
To: Poyo VL <poyo_vl@yahoo.com>
Cc: xfs@oss.sgi.com
Subject: Re: [PATCH] 2.6.35.4: Fixed simple warning (array subscript is above array bounds)
Date: Thu, 16 Sep 2010 11:42:02 -0500 [thread overview]
Message-ID: <1284655322.2153.22.camel@doink> (raw)
In-Reply-To: <388312.90213.qm@web45811.mail.sp1.yahoo.com>
On Thu, 2010-09-02 at 02:10 -0700, Poyo VL wrote:
> From: Ionut Gabriel Popescu <poyo_vl@yahoo.com>
>
> When I tried to compile, I got the following warning:
> fs/xfs/xfs_dir2_block.c: In function ‘xfs_dir2_sf_to_block’:
> fs/xfs/xfs_dir2_block.c:1153:26: warning: array subscript is above array bounds
> The code (fs/xfs/xfs_dir2_block.c line 1153) is:
> dep->name[0] = dep->name[1] = '.';
> dep is a pointer to a xfs_dir2_data_entry_t structure where name is defined as:
> __u8 name[1]; /* name bytes, no null */
> So it is a single element array, name[0] not also name[1] so I got that warning.
> Patching is a simple replacement of 1 with 2.
It looks to me like this will work. But I would like
a second opinion on that before I commit this change.
An xfs_dir2_data_entry structure is defined the way
it is to be informative; its physical representation
is different when it's actually used. The name array
is sized based on the actual name length, and the tag
lies somewhere after that--at the very end of the
(dynamically-sized) data entry.
Additionally, the alignment of the overall structure
will be 64 bits because of hte inumber field. Expanding
the name field by another byte will not change that.
So I think this change is OK. Can anyone else
back me up?
Reviewed-by: Alex Elder <aelder@sgi.com>
> Signed-off-by: Ionut Gabriel Popescu <poyo_vl@yahoo.com>
> ---
>
> --- a/fs/xfs/xfs_dir2_data.h 2010-09-02 11:13:11.632007536 +0300
> +++ b/fs/xfs/xfs_dir2_data.h 2010-09-02 11:13:28.080006488 +0300
> @@ -87,7 +87,7 @@
> typedef struct xfs_dir2_data_entry {
> __be64 inumber; /* inode number */
> __u8 namelen; /* name length */
> - __u8 name[1]; /* name bytes, no null */
> + __u8 name[2]; /* name bytes, no null */
> /* variable offset */
> __be16 tag; /* starting offset of us */
> } xfs_dir2_data_entry_t;
>
>
>
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next prev parent reply other threads:[~2010-09-16 16:41 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-09-02 9:10 [PATCH] 2.6.35.4: Fixed simple warning (array subscript is above array bounds) Poyo VL
2010-09-16 16:42 ` Alex Elder [this message]
2010-09-16 16:48 ` Christoph Hellwig
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=1284655322.2153.22.camel@doink \
--to=aelder@sgi.com \
--cc=poyo_vl@yahoo.com \
--cc=xfs@oss.sgi.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