Skip to content

Commit 1d76e54

Browse files
committed
Added safety margins for encoder misbehavior
This is a bit paranoid, but the encoder has been seen to overflow its output buffer in some corner cases, ignoring the max output byte limit.
1 parent 39383ba commit 1d76e54

File tree

1 file changed

+4
-1
lines changed
  • firmware/nRF51/tag-proximity/inc

1 file changed

+4
-1
lines changed

firmware/nRF51/tag-proximity/inc/log.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
/* compression */
3535
#define FLASH_LOG_COMPRESSION 1
3636
#define COMPRESS_CHUNK_SIZE 256
37-
#define BLOCK_SPACE_MIN 256
37+
#define BLOCK_SPACE_MIN (COMPRESS_CHUNK_SIZE + 32)
3838

3939
/* flash storage */
4040
#define BLOCK_PAGES 8
@@ -65,6 +65,9 @@ typedef struct
6565
{
6666
TLogBlockEnvelope env;
6767
uint8_t data[LOG_BLOCK_DATA_SIZE];
68+
69+
/* paranoid: padding in case heatshrink_encoder_poll() overflows the output buffer */
70+
uint8_t safety[COMPRESS_CHUNK_SIZE];
6871
} PACKED TLogBlock;
6972

7073

0 commit comments

Comments
 (0)