Commit 420788d38f9d9ff1db38cccc42d415211bd8ddfb
Committed by
guoyin.chen
1 parent
72f69ee87c
Exists in
smarc-imx_v2015.04_4.1.15_1.0.0_ga
and in
1 other branch
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
common/env_flags.c
... | ... | @@ -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; |