Skip to content

Commit ff5014c

Browse files
committed
fix(s2): Support C23 for secure memset (for MacOS clang-17)
The previously introduced patch break MacOS support, this transition code to C23 make it usable on both OS (Linux, MacOS). Note that current version of gcc-12 in debian stable is not supporting this C23 function, so it fallback to the safer option for memset in this release. Origin: SiliconLabsSoftware#139 Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#85 Relate-to: SiliconLabsSoftware#137 Signed-off-by: Philippe Coval <[email protected]>
1 parent d86373f commit ff5014c

File tree

1 file changed

+10
-0
lines changed
  • applications/zpc/components/zwave/zwave_transports/s2/libs/zw-libs2/protocol

1 file changed

+10
-0
lines changed

applications/zpc/components/zwave/zwave_transports/s2/libs/zw-libs2/protocol/S2.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,7 +1279,17 @@ S2_init_ctx(uint32_t home)
12791279
return 0;
12801280
}
12811281
#endif
1282+
1283+
// Erase sensitive memory safely
1284+
#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202311L
1285+
memset_explicit(ctx, 0, sizeof(struct S2));
1286+
#elif defined(HAVE_EXPLICIT_BZERO) // for gcc-12
12821287
explicit_bzero(ctx, sizeof(struct S2));
1288+
#elif defined(__APPLE__) // for MacOS
1289+
memset_s(ctx, 0, sizeof(struct S2));
1290+
#else
1291+
memset(ctx, 0, sizeof(struct S2)); //NOSONAR: Fallback option
1292+
#endif
12831293

12841294
ctx->my_home_id = home;
12851295
ctx->loaded_keys = 0;

0 commit comments

Comments
 (0)