fs: fcb: Increase temporary buffer in fcb_append

Increase temporary buffer size to 8 bytes in fcb_append to prevent
stack overflow in case flash alignment is bigger then 2 bytes.

Signed-off-by: Jan Van Winkel <jan.van_winkel@dxplore.eu>
This commit is contained in:
Jan Van Winkel 2019-08-24 20:30:54 +02:00 committed by Carles Cufí
commit 0b30dc3478

View file

@ -61,9 +61,9 @@ fcb_append(struct fcb *fcb, u16_t len, struct fcb_entry *append_loc)
{
struct flash_sector *sector;
struct fcb_entry *active;
u8_t tmp_str[2];
int cnt;
int rc;
u8_t tmp_str[8];
cnt = fcb_put_len(tmp_str, len);
if (cnt < 0) {
@ -72,6 +72,8 @@ fcb_append(struct fcb *fcb, u16_t len, struct fcb_entry *append_loc)
cnt = fcb_len_in_flash(fcb, cnt);
len = fcb_len_in_flash(fcb, len) + fcb_len_in_flash(fcb, FCB_CRC_SZ);
__ASSERT_NO_MSG(cnt <= sizeof(tmp_str));
rc = k_mutex_lock(&fcb->f_mtx, K_FOREVER);
if (rc) {
return FCB_ERR_ARGS;