Commit 420788d38f9d9ff1db38cccc42d415211bd8ddfb

Authored by Peng Fan
Committed by guoyin.chen
1 parent 72f69ee87c

MLK-12201 common: env: fix out of bounds read

We should use ARRAY_SIZE, but not directly sizeof, otherwise
we may access memory that is not belong the array env_flags_varaccess_mask.

Coverity ID: 17949

Signed-off-by: Peng Fan <peng.fan@nxp.com>

Showing 1 changed file with 1 additions and 1 deletions Side-by-side Diff

... ... @@ -152,7 +152,7 @@
152 152 {
153 153 int i;
154 154  
155   - for (i = 0; i < sizeof(env_flags_varaccess_mask); i++)
  155 + for (i = 0; i < ARRAY_SIZE(env_flags_varaccess_mask); i++)
156 156 if (env_flags_varaccess_mask[i] ==
157 157 (binflags & ENV_FLAGS_VARACCESS_BIN_MASK))
158 158 return (enum env_flags_varaccess)i;