summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2016-07-15 21:38:02 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2016-07-15 21:38:39 +0200
commit76bdb7093c1b336612a58b307167f338f2142acc (patch)
tree5b0bfc36a0cbb750fabae9d3f929d20a3ee64f7f
parent035081d96ab2bca05dd8e652ef9b1c82eeb4f550 (diff)
downloadgnutls-76bdb7093c1b336612a58b307167f338f2142acc.tar.gz
rnd-linux: added sanity check in getrandom output
-rw-r--r--lib/nettle/rnd-linux.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/lib/nettle/rnd-linux.c b/lib/nettle/rnd-linux.c
index 87b325f893..45b9890c70 100644
--- a/lib/nettle/rnd-linux.c
+++ b/lib/nettle/rnd-linux.c
@@ -83,6 +83,12 @@ static int _rnd_get_system_entropy_getrandom(void* _rnd, size_t size)
strerror(errno));
return GNUTLS_E_RANDOM_DEVICE_ERROR;
}
+
+ /* This function is only used internally for small sizes which
+ * should be delivered by getrandom(). */
+ if ((size_t)ret != size)
+ return gnutls_assert_val(GNUTLS_E_RANDOM_DEVICE_ERROR);
+
return 0;
}
#else