Tidy dcb_free (prefer use of dcb_close) and remove from test code; add good random number generator.

This commit is contained in:
counterpoint
2015-08-26 15:43:21 +01:00
parent 72b301785b
commit 1f6b544f33
7 changed files with 14 additions and 23 deletions

View File

@ -23,6 +23,7 @@
#include <ctype.h>
#include <mysql_client_server_protocol.h>
#include <gwdirs.h>
#include <random.h>
/** Defined in log_manager.cc */
extern int lm_enabled_logfiles_bitmask;
@ -36,15 +37,13 @@ extern __thread log_info_t tls_log_info;
static unsigned char
secrets_randomchar()
{
return (char)((rand() % ('~' - ' ')) + ' ');
return (char)((random_jkiss() % ('~' - ' ')) + ' ');
}
static int
secrets_random_str(unsigned char *output, int len)
{
int i;
srand((unsigned long )time(0L) ^ (unsigned long )output);
for ( i = 0; i < len; ++i )
{
output[i] = secrets_randomchar();
@ -273,7 +272,6 @@ if(strlen(path) > PATH_MAX)
}
close(randfd);
srand(randval);
secrets_random_str(key.enckey, MAXSCALE_KEYLEN);
secrets_random_str(key.initvector, MAXSCALE_IV_LEN);