commit 0fa37740758f22fe522feb75edaeb9cd3e0e8519
parent e894787dade9c53ad613dd9482be2187e5bd0edf
Author: Vincent Forest <vincent.forest@meso-star.com>
Date: Wed, 1 Jul 2015 11:19:47 +0200
Fix an issue in the RNG proxy
The RNG buckets provided min/max values that does not match the min/max values
of their underlying type.
Diffstat:
1 file changed, 10 insertions(+), 4 deletions(-)
diff --git a/src/ssp_rng_proxy.c b/src/ssp_rng_proxy.c
@@ -262,7 +262,7 @@ rng_bucket_entropy(const void* data)
return 0;
}
-static const struct ssp_rng_type rng_bucket = {
+static const struct ssp_rng_type RNG_BUCKET_NULL = {
rng_bucket_init,
rng_bucket_release,
rng_bucket_set,
@@ -273,8 +273,8 @@ static const struct ssp_rng_type rng_bucket = {
rng_bucket_read,
rng_bucket_write,
rng_bucket_entropy,
- 0, /* Dummy value */
- ULONG_MAX, /* Dummy value */
+ INT_MAX, /* Min dummy value */
+ 0, /* Max dummy value */
sizeof(struct rng_bucket)
};
@@ -448,6 +448,7 @@ ssp_rng_proxy_create_rng
struct ssp_rng** out_rng)
{
struct ssp_rng* rng = NULL;
+ struct ssp_rng_type type = RNG_BUCKET_NULL;
res_T res = RES_OK;
if(!proxy || ibucket >= sa_size(proxy->buckets) || !out_rng) {
@@ -460,7 +461,12 @@ ssp_rng_proxy_create_rng
goto error;
}
- res = ssp_rng_create(proxy->allocator, &rng_bucket, &rng);
+ /* Update the dummy rng bucket min/max value with the min/max values of the
+ * RNG type on which the proxy relies */
+ type.min = proxy->type.min;
+ type.max = proxy->type.max;
+
+ res = ssp_rng_create(proxy->allocator, &type, &rng);
if(res != RES_OK) goto error;
((struct rng_bucket*)rng->state)->name = ibucket;
((struct rng_bucket*)rng->state)->proxy = proxy;