From 74a552e8c7d9570243def76250657831aa6bb7ca Mon Sep 17 00:00:00 2001 From: Jake Carter Date: Tue, 18 Jun 2024 16:52:05 -0600 Subject: [PATCH] fix(PeriphDrivers): Fix `MXC_SYS_GetUSN` Buffer Overflow (#1016) --- Libraries/PeriphDrivers/Source/SYS/sys_ai85.c | 2 +- Libraries/PeriphDrivers/Source/SYS/sys_ai87.c | 2 +- Libraries/PeriphDrivers/Source/SYS/sys_me12.c | 2 +- Libraries/PeriphDrivers/Source/SYS/sys_me14.c | 2 +- Libraries/PeriphDrivers/Source/SYS/sys_me15.c | 2 +- Libraries/PeriphDrivers/Source/SYS/sys_me16.c | 2 +- Libraries/PeriphDrivers/Source/SYS/sys_me17.c | 2 +- Libraries/PeriphDrivers/Source/SYS/sys_me18.c | 2 +- Libraries/PeriphDrivers/Source/SYS/sys_me21.c | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Libraries/PeriphDrivers/Source/SYS/sys_ai85.c b/Libraries/PeriphDrivers/Source/SYS/sys_ai85.c index da47775af8..b58d1eb1a2 100644 --- a/Libraries/PeriphDrivers/Source/SYS/sys_ai85.c +++ b/Libraries/PeriphDrivers/Source/SYS/sys_ai85.c @@ -75,7 +75,7 @@ int MXC_SYS_GetUSN(uint8_t *usn, uint8_t *checksum) uint32_t _usn_32[MXC_SYS_USN_CHECKSUM_LEN / 4]; // ^ Declare as uint32_t to preserve mem alignment uint8_t *_usn_8 = (uint8_t *)_usn_32; - memset(_usn_8, 0, MXC_SYS_USN_CHECKSUM_LEN); + memset(_usn_8, 0, MXC_SYS_USN_LEN); _usn_8[0] = (infoblock[0] & 0x007F8000) >> 15; _usn_8[1] = (infoblock[0] & 0x7F800000) >> 23; diff --git a/Libraries/PeriphDrivers/Source/SYS/sys_ai87.c b/Libraries/PeriphDrivers/Source/SYS/sys_ai87.c index fdb03567b2..808705d1f3 100644 --- a/Libraries/PeriphDrivers/Source/SYS/sys_ai87.c +++ b/Libraries/PeriphDrivers/Source/SYS/sys_ai87.c @@ -75,7 +75,7 @@ int MXC_SYS_GetUSN(uint8_t *usn, uint8_t *checksum) uint32_t _usn_32[MXC_SYS_USN_CHECKSUM_LEN / 4]; // ^ Declare as uint32_t to preserve mem alignment uint8_t *_usn_8 = (uint8_t *)_usn_32; - memset(_usn_8, 0, MXC_SYS_USN_CHECKSUM_LEN); + memset(_usn_8, 0, MXC_SYS_USN_LEN); _usn_8[0] = (infoblock[0] & 0x007F8000) >> 15; _usn_8[1] = (infoblock[0] & 0x7F800000) >> 23; diff --git a/Libraries/PeriphDrivers/Source/SYS/sys_me12.c b/Libraries/PeriphDrivers/Source/SYS/sys_me12.c index f2881904cb..4d0cd9117d 100644 --- a/Libraries/PeriphDrivers/Source/SYS/sys_me12.c +++ b/Libraries/PeriphDrivers/Source/SYS/sys_me12.c @@ -70,7 +70,7 @@ int MXC_SYS_GetUSN(uint8_t *usn, uint8_t *checksum) /* Read the USN from the info block */ MXC_FLC_UnlockInfoBlock(MXC_INFO0_MEM_BASE); - memset(usn, 0, MXC_SYS_USN_CHECKSUM_LEN); + memset(usn, 0, MXC_SYS_USN_LEN); usn[0] = (infoblock[0] & 0x007F8000) >> 15; usn[1] = (infoblock[0] & 0x7F800000) >> 23; diff --git a/Libraries/PeriphDrivers/Source/SYS/sys_me14.c b/Libraries/PeriphDrivers/Source/SYS/sys_me14.c index 520f5bf91b..d22d481b1a 100644 --- a/Libraries/PeriphDrivers/Source/SYS/sys_me14.c +++ b/Libraries/PeriphDrivers/Source/SYS/sys_me14.c @@ -64,7 +64,7 @@ int MXC_SYS_GetUSN(uint8_t *usn, uint8_t *checksum) /* Read the USN from the info block */ MXC_FLC_UnlockInfoBlock(MXC_INFO0_MEM_BASE); - memset(usn, 0, MXC_SYS_USN_CHECKSUM_LEN); + memset(usn, 0, MXC_SYS_USN_LEN); usn[0] = (infoblock[0] & 0x007F8000) >> 15; usn[1] = (infoblock[0] & 0x7F800000) >> 23; diff --git a/Libraries/PeriphDrivers/Source/SYS/sys_me15.c b/Libraries/PeriphDrivers/Source/SYS/sys_me15.c index 6ffab731d0..a1c8a07cec 100644 --- a/Libraries/PeriphDrivers/Source/SYS/sys_me15.c +++ b/Libraries/PeriphDrivers/Source/SYS/sys_me15.c @@ -76,7 +76,7 @@ int MXC_SYS_GetUSN(uint8_t *usn, uint8_t *checksum) /* Read the USN from the info block */ MXC_FLC_UnlockInfoBlock(MXC_INFO0_MEM_BASE); - memset(usn, 0, MXC_SYS_USN_CHECKSUM_LEN); + memset(usn, 0, MXC_SYS_USN_LEN); usn[0] = (infoblock[0] & 0x007F8000) >> 15; usn[1] = (infoblock[0] & 0x7F800000) >> 23; diff --git a/Libraries/PeriphDrivers/Source/SYS/sys_me16.c b/Libraries/PeriphDrivers/Source/SYS/sys_me16.c index b9268fc263..bb5974685a 100644 --- a/Libraries/PeriphDrivers/Source/SYS/sys_me16.c +++ b/Libraries/PeriphDrivers/Source/SYS/sys_me16.c @@ -62,7 +62,7 @@ int MXC_SYS_GetUSN(uint8_t *usn, uint8_t *checksum) /* Read the USN from the info block */ MXC_FLC_UnlockInfoBlock(MXC_INFO0_MEM_BASE); - memset(usn, 0, MXC_SYS_USN_CHECKSUM_LEN); + memset(usn, 0, MXC_SYS_USN_LEN); usn[0] = (infoblock[0] & 0x007F8000) >> 15; usn[1] = (infoblock[0] & 0x7F800000) >> 23; diff --git a/Libraries/PeriphDrivers/Source/SYS/sys_me17.c b/Libraries/PeriphDrivers/Source/SYS/sys_me17.c index 9f2b06d85b..d3484141d4 100644 --- a/Libraries/PeriphDrivers/Source/SYS/sys_me17.c +++ b/Libraries/PeriphDrivers/Source/SYS/sys_me17.c @@ -72,7 +72,7 @@ int MXC_SYS_GetUSN(uint8_t *usn, uint8_t *checksum) /* Read the USN from the info block */ MXC_FLC_UnlockInfoBlock(MXC_INFO0_MEM_BASE); - memset(usn, 0, MXC_SYS_USN_CHECKSUM_LEN); + memset(usn, 0, MXC_SYS_USN_LEN); usn[0] = (infoblock[0] & 0x007F8000) >> 15; usn[1] = (infoblock[0] & 0x7F800000) >> 23; diff --git a/Libraries/PeriphDrivers/Source/SYS/sys_me18.c b/Libraries/PeriphDrivers/Source/SYS/sys_me18.c index 9b39a6bc91..02ea843df3 100644 --- a/Libraries/PeriphDrivers/Source/SYS/sys_me18.c +++ b/Libraries/PeriphDrivers/Source/SYS/sys_me18.c @@ -71,7 +71,7 @@ int MXC_SYS_GetUSN(uint8_t *usn, uint8_t *checksum) /* Read the USN from the info block */ MXC_FLC_UnlockInfoBlock(MXC_INFO0_MEM_BASE); - memset(usn, 0, MXC_SYS_USN_CHECKSUM_LEN); + memset(usn, 0, MXC_SYS_USN_LEN); usn[0] = (infoblock[0] & 0x007F8000) >> 15; usn[1] = (infoblock[0] & 0x7F800000) >> 23; diff --git a/Libraries/PeriphDrivers/Source/SYS/sys_me21.c b/Libraries/PeriphDrivers/Source/SYS/sys_me21.c index da04b656a3..b0463ee872 100644 --- a/Libraries/PeriphDrivers/Source/SYS/sys_me21.c +++ b/Libraries/PeriphDrivers/Source/SYS/sys_me21.c @@ -68,7 +68,7 @@ int MXC_SYS_GetUSN(uint8_t *usn, uint8_t *checksum) /* Read the USN from the info block */ MXC_FLC_UnlockInfoBlock(MXC_INFO0_MEM_BASE); - memset(usn, 0, MXC_SYS_USN_CHECKSUM_LEN); + memset(usn, 0, MXC_SYS_USN_LEN); usn[0] = (infoblock[0] & 0x007F8000) >> 15; usn[1] = (infoblock[0] & 0x7F800000) >> 23;