aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/entropy/dev_random
diff options
context:
space:
mode:
authorlloyd <[email protected]>2014-04-24 22:58:26 +0000
committerlloyd <[email protected]>2014-04-24 22:58:26 +0000
commit39aa371f8eaf26d59d409919fc5f6cf38eb4059c (patch)
tree651d2fa049f1e2bc19f3b656379d040e3e86be47 /src/lib/entropy/dev_random
parentd56d0bb243bcb9af369a67dc2272a1d6c5ccd4b2 (diff)
Avoid crash if read returns an error. Canonical case is on the blocking device
with concurrent readers; if someone else got the entropy first we can get -1/errno=EAGAIN
Diffstat (limited to 'src/lib/entropy/dev_random')
-rw-r--r--src/lib/entropy/dev_random/dev_random.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/lib/entropy/dev_random/dev_random.cpp b/src/lib/entropy/dev_random/dev_random.cpp
index 832424acd..ef6bceaf7 100644
--- a/src/lib/entropy/dev_random/dev_random.cpp
+++ b/src/lib/entropy/dev_random/dev_random.cpp
@@ -89,7 +89,8 @@ void Device_EntropySource::poll(Entropy_Accumulator& accum)
if(FD_ISSET(m_devices[i], &read_set))
{
const ssize_t got = ::read(m_devices[i], &io_buffer[0], io_buffer.size());
- accum.add(&io_buffer[0], got, ENTROPY_BITS_PER_BYTE);
+ if(got > 0)
+ accum.add(&io_buffer[0], got, ENTROPY_BITS_PER_BYTE);
}
}
}