* [U-Boot] [PATCH] common: env_flags: fix loop condition when using env_flags_varaccess_mask
@ 2016-01-12 9:23 Peng Fan
2016-01-13 20:09 ` Simon Glass
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Peng Fan @ 2016-01-12 9:23 UTC (permalink / raw)
To: u-boot
From: Peng Fan <peng.fan@nxp.com>
We should use ARRAY_SIZE, but not sizeof. The size of
env_flags_varaccess_mask is 16bytes, but we only need 4 loops.
If using 16 as the end condition, we may access memory that
not belong to array env_flags_varaccess_mask.
Signed-off-by: Peng Fan <peng.fan@nxp.com>
Cc: Joe Hershberger <joe.hershberger@ni.com>
Cc: York Sun <yorksun@freescale.com>
Cc: Simon Glass <sjg@chromium.org>
Cc: Tom Rini <trini@konsulko.com>
---
common/env_flags.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/env_flags.c b/common/env_flags.c
index 7719355..9c3aed1 100644
--- a/common/env_flags.c
+++ b/common/env_flags.c
@@ -152,7 +152,7 @@ enum env_flags_varaccess env_flags_parse_varaccess_from_binflags(int binflags)
{
int i;
- for (i = 0; i < sizeof(env_flags_varaccess_mask); i++)
+ for (i = 0; i < ARRAY_SIZE(env_flags_varaccess_mask); i++)
if (env_flags_varaccess_mask[i] ==
(binflags & ENV_FLAGS_VARACCESS_BIN_MASK))
return (enum env_flags_varaccess)i;
--
2.6.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] common: env_flags: fix loop condition when using env_flags_varaccess_mask
2016-01-12 9:23 [U-Boot] [PATCH] common: env_flags: fix loop condition when using env_flags_varaccess_mask Peng Fan
@ 2016-01-13 20:09 ` Simon Glass
2016-01-13 20:39 ` Joe Hershberger
2016-01-14 13:22 ` [U-Boot] " Tom Rini
2 siblings, 0 replies; 4+ messages in thread
From: Simon Glass @ 2016-01-13 20:09 UTC (permalink / raw)
To: u-boot
On 12 January 2016 at 02:23, Peng Fan <van.freenix@gmail.com> wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> We should use ARRAY_SIZE, but not sizeof. The size of
> env_flags_varaccess_mask is 16bytes, but we only need 4 loops.
> If using 16 as the end condition, we may access memory that
> not belong to array env_flags_varaccess_mask.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: York Sun <yorksun@freescale.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> ---
> common/env_flags.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] [PATCH] common: env_flags: fix loop condition when using env_flags_varaccess_mask
2016-01-12 9:23 [U-Boot] [PATCH] common: env_flags: fix loop condition when using env_flags_varaccess_mask Peng Fan
2016-01-13 20:09 ` Simon Glass
@ 2016-01-13 20:39 ` Joe Hershberger
2016-01-14 13:22 ` [U-Boot] " Tom Rini
2 siblings, 0 replies; 4+ messages in thread
From: Joe Hershberger @ 2016-01-13 20:39 UTC (permalink / raw)
To: u-boot
On Tue, Jan 12, 2016 at 3:23 AM, Peng Fan <van.freenix@gmail.com> wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> We should use ARRAY_SIZE, but not sizeof. The size of
> env_flags_varaccess_mask is 16bytes, but we only need 4 loops.
> If using 16 as the end condition, we may access memory that
> not belong to array env_flags_varaccess_mask.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: York Sun <yorksun@freescale.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> ---
Acked-by: Joe Hershberger <joe.hershberger@ni.com>
^ permalink raw reply [flat|nested] 4+ messages in thread
* [U-Boot] common: env_flags: fix loop condition when using env_flags_varaccess_mask
2016-01-12 9:23 [U-Boot] [PATCH] common: env_flags: fix loop condition when using env_flags_varaccess_mask Peng Fan
2016-01-13 20:09 ` Simon Glass
2016-01-13 20:39 ` Joe Hershberger
@ 2016-01-14 13:22 ` Tom Rini
2 siblings, 0 replies; 4+ messages in thread
From: Tom Rini @ 2016-01-14 13:22 UTC (permalink / raw)
To: u-boot
On Tue, Jan 12, 2016 at 05:23:12PM +0800, Peng Fan wrote:
> From: Peng Fan <peng.fan@nxp.com>
>
> We should use ARRAY_SIZE, but not sizeof. The size of
> env_flags_varaccess_mask is 16bytes, but we only need 4 loops.
> If using 16 as the end condition, we may access memory that
> not belong to array env_flags_varaccess_mask.
>
> Signed-off-by: Peng Fan <peng.fan@nxp.com>
> Cc: Joe Hershberger <joe.hershberger@ni.com>
> Cc: York Sun <yorksun@freescale.com>
> Cc: Simon Glass <sjg@chromium.org>
> Cc: Tom Rini <trini@konsulko.com>
> Reviewed-by: Simon Glass <sjg@chromium.org>
> Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Applied to u-boot/master, thanks!
--
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20160114/2883e166/attachment.sig>
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2016-01-14 13:22 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-12 9:23 [U-Boot] [PATCH] common: env_flags: fix loop condition when using env_flags_varaccess_mask Peng Fan
2016-01-13 20:09 ` Simon Glass
2016-01-13 20:39 ` Joe Hershberger
2016-01-14 13:22 ` [U-Boot] " Tom Rini
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.