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:
parent
571b42e74e
commit
0b30dc3478
1 changed files with 3 additions and 1 deletions
|
@ -61,9 +61,9 @@ fcb_append(struct fcb *fcb, u16_t len, struct fcb_entry *append_loc)
|
||||||
{
|
{
|
||||||
struct flash_sector *sector;
|
struct flash_sector *sector;
|
||||||
struct fcb_entry *active;
|
struct fcb_entry *active;
|
||||||
u8_t tmp_str[2];
|
|
||||||
int cnt;
|
int cnt;
|
||||||
int rc;
|
int rc;
|
||||||
|
u8_t tmp_str[8];
|
||||||
|
|
||||||
cnt = fcb_put_len(tmp_str, len);
|
cnt = fcb_put_len(tmp_str, len);
|
||||||
if (cnt < 0) {
|
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);
|
cnt = fcb_len_in_flash(fcb, cnt);
|
||||||
len = fcb_len_in_flash(fcb, len) + fcb_len_in_flash(fcb, FCB_CRC_SZ);
|
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);
|
rc = k_mutex_lock(&fcb->f_mtx, K_FOREVER);
|
||||||
if (rc) {
|
if (rc) {
|
||||||
return FCB_ERR_ARGS;
|
return FCB_ERR_ARGS;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue