TT#111150 Add an alternative implementation for taint_func

When the compiler does not have support for the __error__ attribute,
fallback to use the GCC posion pragma, which works on both gcc and
clang. It ha the advantage of being more portable and working at the
preprocessor level, which means is not affected by symbol redirection
due to builtin conversion or stack-protector remapping, at the cost of
worse diagnostics.

Change-Id: I322396f8a0d1b993637e8aca27f27f6868ecba3c
Warned-by: clang-12
pull/1262/head
Guillem Jover 5 years ago
parent 87e83467cd
commit c09b379f41

@ -244,8 +244,17 @@ INLINE int rlim(int res, rlim_t val) {
/*** TAINT FUNCTIONS ***/
#if __has_attribute(__error__)
/* This is not supported in clang, and on gcc it might become inert if the
* symbol gets remapped to a builtin or stack protected function, but it
* otherwise gives better diagnostics. */
#define taint_func(symbol, reason) \
__typeof__(symbol) symbol __attribute__((__error__(reason)))
#else
#define taint_pragma(str) _Pragma(#str)
#define taint_pragma_expand(str) taint_pragma(str)
#define taint_func(symbol, reason) taint_pragma_expand(GCC poison symbol)
#endif
taint_func(rand, "use ssl_random() instead");
taint_func(random, "use ssl_random() instead");

Loading…
Cancel
Save