From 88cdcad1f68fd6250554d75fdb7946e7c268dca4 Mon Sep 17 00:00:00 2001 From: Christoph von Wittich Date: Mon, 7 Sep 2015 08:37:11 +0000 Subject: [PATCH] [XDK][PSDK] add security checks for PSDK as well svn path=/trunk/; revision=69081 --- reactos/include/psdk/ntdef.h | 7 ++++++- reactos/include/psdk/winnt.h | 7 ++++++- reactos/include/xdk/ntbasedef.h | 4 +++- 3 files changed, 15 insertions(+), 3 deletions(-) diff --git a/reactos/include/psdk/ntdef.h b/reactos/include/psdk/ntdef.h index 966555fbac5..133f127bf64 100644 --- a/reactos/include/psdk/ntdef.h +++ b/reactos/include/psdk/ntdef.h @@ -768,8 +768,13 @@ typedef struct _GROUP_AFFINITY { #define RTL_NUMBER_OF_V2(A) \ (({ int _check_array_type[__builtin_types_compatible_p(typeof(A), typeof(&A[0])) ? -1 : 1]; (void)_check_array_type; }), \ RTL_NUMBER_OF_V1(A)) +#elif defined(__cplusplus) +extern "C++" { + template + static char (& SAFE_RTL_NUMBER_OF(T (&)[N]))[N]; +} + #define RTL_NUMBER_OF_V2(A) sizeof(SAFE_RTL_NUMBER_OF(A)) #else - /// \todo implement security checks for cplusplus / MSVC #define RTL_NUMBER_OF_V2(A) RTL_NUMBER_OF_V1(A) #endif diff --git a/reactos/include/psdk/winnt.h b/reactos/include/psdk/winnt.h index 4020e54862c..88ef5568e33 100644 --- a/reactos/include/psdk/winnt.h +++ b/reactos/include/psdk/winnt.h @@ -702,8 +702,13 @@ typedef struct _GROUP_AFFINITY { #define RTL_NUMBER_OF_V2(A) \ (({ int _check_array_type[__builtin_types_compatible_p(typeof(A), typeof(&A[0])) ? -1 : 1]; (void)_check_array_type; }), \ RTL_NUMBER_OF_V1(A)) +#elif defined(__cplusplus) +extern "C++" { + template + static char (& SAFE_RTL_NUMBER_OF(T (&)[N]))[N]; +} + #define RTL_NUMBER_OF_V2(A) sizeof(SAFE_RTL_NUMBER_OF(A)) #else - /// \todo implement security checks for cplusplus / MSVC #define RTL_NUMBER_OF_V2(A) RTL_NUMBER_OF_V1(A) #endif diff --git a/reactos/include/xdk/ntbasedef.h b/reactos/include/xdk/ntbasedef.h index ff8d6ec06c3..79c802410e4 100644 --- a/reactos/include/xdk/ntbasedef.h +++ b/reactos/include/xdk/ntbasedef.h @@ -681,8 +681,10 @@ typedef struct _GROUP_AFFINITY { (({ int _check_array_type[__builtin_types_compatible_p(typeof(A), typeof(&A[0])) ? -1 : 1]; (void)_check_array_type; }), \ RTL_NUMBER_OF_V1(A)) #elif defined(__cplusplus) +extern "C++" { template - char (& SAFE_RTL_NUMBER_OF(T (&)[N]))[N]; + static char (& SAFE_RTL_NUMBER_OF(T (&)[N]))[N]; +} #define RTL_NUMBER_OF_V2(A) sizeof(SAFE_RTL_NUMBER_OF(A)) #else #define RTL_NUMBER_OF_V2(A) RTL_NUMBER_OF_V1(A)