From: Tobias Brunner Date: Mon, 12 Oct 2015 09:04:55 +0000 (+0200) Subject: random: Properly handle errors when reading from /dev/[u]random X-Git-Tag: 5.3.4dr1~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=35dbf8af7a9048f3384af181613c352b718f8d8e;p=thirdparty%2Fstrongswan.git random: Properly handle errors when reading from /dev/[u]random If -1 was returned on the first call to read() `done` got SIZE_MAX and the function returned TRUE even though no actual random data had been allocated. Fixes #1156. --- diff --git a/src/libstrongswan/plugins/random/random_rng.c b/src/libstrongswan/plugins/random/random_rng.c index 36d5446b88..177b3c2e5c 100644 --- a/src/libstrongswan/plugins/random/random_rng.c +++ b/src/libstrongswan/plugins/random/random_rng.c @@ -56,6 +56,7 @@ METHOD(rng_t, get_bytes, bool, DBG1(DBG_LIB, "reading from random FD %d failed: %s, retrying...", this->fd, strerror(errno)); sleep(1); + continue; } done += got; }