Skip to content

Commit 3159e9f

Browse files
vanwinkeljannashif
authored andcommitted
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 <[email protected]> Signed-off-by: Andrzej Puzdrowski <[email protected]>
1 parent 24f8232 commit 3159e9f

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

subsys/fs/fcb/fcb_append.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,9 @@ fcb_append(struct fcb *fcb, u16_t len, struct fcb_entry *append_loc)
6161
{
6262
struct flash_sector *sector;
6363
struct fcb_entry *active;
64-
u8_t tmp_str[2];
6564
int cnt;
6665
int rc;
66+
u8_t tmp_str[8];
6767

6868
cnt = fcb_put_len(tmp_str, len);
6969
if (cnt < 0) {
@@ -72,6 +72,8 @@ fcb_append(struct fcb *fcb, u16_t len, struct fcb_entry *append_loc)
7272
cnt = fcb_len_in_flash(fcb, cnt);
7373
len = fcb_len_in_flash(fcb, len) + fcb_len_in_flash(fcb, FCB_CRC_SZ);
7474

75+
__ASSERT_NO_MSG(cnt <= sizeof(tmp_str));
76+
7577
rc = k_mutex_lock(&fcb->f_mtx, K_FOREVER);
7678
if (rc) {
7779
return FCB_ERR_ARGS;

0 commit comments

Comments
 (0)