common: env_flags: fix loop condition when using env_flags_varaccess_mask
PATCH 1/1 common: env_flags: fix loop condition when using env_flags_varaccess_mask
From: Peng Fan <[email protected]>
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.
--- common/env_flags.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
common/env_flags.c +1 -1
@@ -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;
Signature · 1 line
2.6.2
PATCH 1/1 common: env_flags: fix loop condition when using env_flags_varaccess_mask
Quoted 7 lines · Peng Fan
From: Peng Fan <[email protected]>
We should use
ARRAY_SIZE, but not sizeof. The size ofenv_flags_varaccess_maskis 16bytes, but we only need 4 loops. If using 16 as the end condition, we may access memory that not belong to arrayenv_flags_varaccess_mask.
Quoted 8 lines
Signed-off-by Peng Fan <[email protected]>Cc Joe Hershberger <[email protected]>Cc York Sun <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>--- common/env_flags.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH 1/1 common: env_flags: fix loop condition when using env_flags_varaccess_mask
In reply to Peng FanQuoted 7 lines · Peng Fan
From: Peng Fan <[email protected]>
We should use
ARRAY_SIZE, but not sizeof. The size ofenv_flags_varaccess_maskis 16bytes, but we only need 4 loops. If using 16 as the end condition, we may access memory that not belong to arrayenv_flags_varaccess_mask.
Quoted 6 lines
Signed-off-by Peng Fan <[email protected]>Cc Joe Hershberger <[email protected]>Cc York Sun <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>---
Quoted 7 lines · Peng Fan
From: Peng Fan <[email protected]>
We should use
ARRAY_SIZE, but not sizeof. The size ofenv_flags_varaccess_maskis 16bytes, but we only need 4 loops. If using 16 as the end condition, we may access memory that not belong to arrayenv_flags_varaccess_mask.
Quoted 7 lines
Signed-off-by Peng Fan <[email protected]>Cc Joe Hershberger <[email protected]>Cc York Sun <[email protected]>Cc Simon Glass <[email protected]>Cc Tom Rini <[email protected]>Reviewed-by Simon Glass <[email protected]>Acked-by Joe Hershberger <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
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>