MT#56374 move ssl_random to auxlib

The poller (now also in lib) depends on this.

Change-Id: I8185e514c7a7aeef80c905136795904340ff60dc
pull/1694/head
Richard Fuchs 2 years ago
parent 84f4467241
commit 61ca57f0cf

@ -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"

@ -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

Loading…
Cancel
Save