Skip to content

Commit

Permalink
fru: Fix crashes on 6-bit ASCII strings
Browse files Browse the repository at this point in the history
Fix calculation of the buffer size for decoded 6-bit ASCII
strings. Previously the program could allocate too a short buffer
that caused buffer overflows and segmentation fault crashes on
certain FRU contents.

Signed-off-by: Alexander Amelkin <alexander@amelkin.msk.ru>
  • Loading branch information
AlexanderAmelkin committed Sep 16, 2020
1 parent 50d8c36 commit 1245aaa
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/ipmi_fru.c
Original file line number Diff line number Diff line change
Expand Up @@ -175,8 +175,8 @@ char * get_fru_area_str(uint8_t * data, uint32_t * offset)
size = (len * 2);
break;
case 2: /* 10b: 6-bit ASCII */
/* 4 chars per group of 1-3 bytes */
size = (((len * 4 + 2) / 3) & ~3);
/* 4 chars per group of 1-3 bytes, round up to 4 bytes boundary */
size = (len / 3 + 1) * 4;
break;
case 3: /* 11b: 8-bit ASCII */
/* no length adjustment */
Expand Down

0 comments on commit 1245aaa

Please sign in to comment.