From 61ca57f0cfccb656759370dd7d9ab43b534d3940 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Fri, 7 Jul 2023 14:19:53 -0400 Subject: [PATCH] MT#56374 move ssl_random to auxlib The poller (now also in lib) depends on this. Change-Id: I8185e514c7a7aeef80c905136795904340ff60dc --- include/helpers.h | 26 -------------------------- lib/auxlib.h | 29 +++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 26 deletions(-) diff --git a/include/helpers.h b/include/helpers.h index ac8f1b234..6d009e99d 100644 --- a/include/helpers.h +++ b/include/helpers.h @@ -220,12 +220,6 @@ INLINE int strmemcmp(const void *mem, int len, const char *s) { return memcmp(mem, s, len); } -INLINE long unsigned int ssl_random(void) { - long unsigned int ret; - random_string((void *) &ret, sizeof(ret)); - return ret; -} - INLINE const char *__get_enum_array_text(const char * const *array, unsigned int idx, unsigned int len, const char *deflt) { @@ -267,26 +261,6 @@ 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"); -taint_func(srandom, "use RAND_seed() instead"); - - - /*** INET ADDRESS HELPERS ***/ #define IPF "%u.%u.%u.%u" diff --git a/lib/auxlib.h b/lib/auxlib.h index 44cf1de32..bff865ed7 100644 --- a/lib/auxlib.h +++ b/lib/auxlib.h @@ -390,4 +390,33 @@ INLINE gboolean g_hash_table_steal_extended(GHashTable *ht, gconstpointer lookup #endif +/*** MISC ***/ + +INLINE long unsigned int ssl_random(void) { + long unsigned int ret; + random_string((void *) &ret, sizeof(ret)); + return ret; +} + + +/*** 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"); +taint_func(srandom, "use rtpe_ssl_init() instead"); + + + #endif