fix: Replace device calls to memcpy with tu_memcpy_s

Introduces a new function tu_memcpy_s, which is effectively
a backport of memcpy_s. The change also refactors calls
to memcpy over to the more secure tu_memcpy_s.
This commit is contained in:
Nathaniel Brough
2023-01-13 13:37:55 -08:00
parent 8775d55adc
commit 2e47210c1a
9 changed files with 50 additions and 26 deletions

View File

@@ -83,6 +83,14 @@
#define tu_memclr(buffer, size) memset((buffer), 0, (size))
#define tu_varclr(_var) tu_memclr(_var, sizeof(*(_var)))
// This is a backport of memset_s from c11
int32_t tu_memset_s(void *dest, size_t destsz, int ch, size_t count);
// This is a backport of memcpy_s from c11
int32_t tu_memcpy_s(void *dest, size_t destsz,
const void * src, size_t count );
//------------- Bytes -------------//
TU_ATTR_ALWAYS_INLINE static inline uint32_t tu_u32(uint8_t b3, uint8_t b2, uint8_t b1, uint8_t b0)
{