File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14461,6 +14461,9 @@ WOLFSSL_SESSION* ClientSessionToSession(const WOLFSSL_SESSION* session)
1446114461 WOLFSSL_MSG("Client cache serverRow or serverIdx invalid");
1446214462 error = -1;
1446314463 }
14464+ /* Prevent memory access before clientSession->serverRow and
14465+ * clientSession->serverIdx are sanitized. */
14466+ XFENCE();
1446414467 if (error == 0) {
1446514468 /* Lock row */
1446614469 sessRow = &SessionCache[clientSession->serverRow];
Original file line number Diff line number Diff line change @@ -1180,6 +1180,33 @@ WOLFSSL_ABI WOLFSSL_API int wolfCrypt_Cleanup(void);
11801180 #endif
11811181#endif
11821182
1183+ #ifdef WOLF_C99
1184+ /* use alternate keyword for compatibility with -std=c99 */
1185+ #define XASM_VOLATILE (a ) __asm__ volatile(a)
1186+ #elif defined(__IAR_SYSTEMS_ICC__ )
1187+ #define XASM_VOLATILE (a ) asm volatile(a)
1188+ #elif defined(__KEIL__ )
1189+ #define XASM_VOLATILE (a ) __asm volatile(a)
1190+ #else
1191+ #define XASM_VOLATILE (a ) __asm__ __volatile__(a)
1192+ #endif
1193+
1194+ #ifndef WOLFSSL_NO_FENCE
1195+ #if defined (__i386__ ) || defined(__x86_64__ )
1196+ #define XFENCE () XASM_VOLATILE("lfence")
1197+ #elif defined (__arm__ ) || defined(__aarch64__ )
1198+ #define XFENCE () XASM_VOLATILE("isb")
1199+ #elif defined(__riscv )
1200+ #define XFENCE () XASM_VOLATILE("fence")
1201+ #elif defined(__PPC__ )
1202+ #define XFENCE () XASM_VOLATILE("isync; sync")
1203+ #else
1204+ #define XFENCE () do{}while(0)
1205+ #endif
1206+ #else
1207+ #define XFENCE () do{}while(0)
1208+ #endif
1209+
11831210
11841211 /* AFTER user_settings.h is loaded,
11851212 ** determine if POSIX multi-threaded: HAVE_PTHREAD */
You can’t perform that action at this time.
0 commit comments