diff options
| author | Nathaniel Brough <[email protected]> | 2023-01-13 13:37:55 -0800 |
|---|---|---|
| committer | Nathaniel Brough <[email protected]> | 2023-01-13 15:20:32 -0800 |
| commit | 2e47210c1af88b88b6f2d92fe2b6d08117041363 (patch) | |
| tree | 7215930f85dd6fcdb0e92a896f3231b3cc57fe2f /src/common | |
| parent | 8775d55adc7c9b0812b7d593b24518c046dd3d82 (diff) | |
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.
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/tusb_common.h | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/src/common/tusb_common.h b/src/common/tusb_common.h index b1ee40a1a..78fdcfe36 100644 --- a/src/common/tusb_common.h +++ b/src/common/tusb_common.h @@ -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) { |
