fru: fixup array bounds checking

Fixup the following array bounds checking bugs:
[lib/ipmi_fru.c:1003]: (style) Array index 'i' is
used before limits check.
[lib/ipmi_fru.c:1127]: (style) Array index 'i' is
used before limits check.
[lib/ipmi_fru.c:1262]: (style) Array index 'i' is
used before limits check.

Signed-off-by: Patrick Venture <venture@google.com>
This commit is contained in:
Patrick Venture 2018-11-26 12:38:04 -08:00 committed by Alexander Amelkin
parent 7941806a9b
commit 6d515dd06b
2 changed files with 5 additions and 6 deletions

View File

@ -42,6 +42,8 @@
# include <config.h>
#endif
#define FRU_END_OF_FIELDS 0xc1
#define GET_FRU_INFO 0x10
#define GET_FRU_DATA 0x11
#define SET_FRU_DATA 0x12

View File

@ -1000,8 +1000,7 @@ fru_area_print_chassis(struct ipmi_intf * intf, struct fru_info * fru,
}
/* read any extra fields */
while ((fru_data[i] != 0xc1) && (i < fru_len))
{
while ((i < fru_len) && (fru_data[i] != FRU_END_OF_FIELDS)) {
int j = i;
fru_area = get_fru_area_str(fru_data, &i);
if (fru_area) {
@ -1124,8 +1123,7 @@ fru_area_print_board(struct ipmi_intf * intf, struct fru_info * fru,
}
/* read any extra fields */
while ((fru_data[i] != 0xc1) && (i < fru_len))
{
while ((i < fru_len) && (fru_data[i] != FRU_END_OF_FIELDS)) {
int j = i;
fru_area = get_fru_area_str(fru_data, &i);
if (fru_area) {
@ -1259,8 +1257,7 @@ fru_area_print_product(struct ipmi_intf * intf, struct fru_info * fru,
}
/* read any extra fields */
while ((fru_data[i] != 0xc1) && (i < fru_len))
{
while ((i < fru_len) && (fru_data[i] != FRU_END_OF_FIELDS)) {
int j = i;
fru_area = get_fru_area_str(fru_data, &i);
if (fru_area) {