If we get zero bytes from an entropy source, we should obviously do
nothing with this input. But it's not clear that entropy_processor()
really ignores zero bytes as expected, so let's explicitly ignore
such input.

Signed-off-by: Nadav Har'El <n...@scylladb.com>
---
 bsd/sys/dev/random/live_entropy_sources.cc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/bsd/sys/dev/random/live_entropy_sources.cc 
b/bsd/sys/dev/random/live_entropy_sources.cc
index bc7a0e9..b36d0ac 100644
--- a/bsd/sys/dev/random/live_entropy_sources.cc
+++ b/bsd/sys/dev/random/live_entropy_sources.cc
@@ -171,6 +171,9 @@ live_entropy_sources_feed(int rounds, event_proc_f 
entropy_processor)
                        /* FIXME: Whine loudly if this didn't work. */
                        n = les->rsource->read(buf, sizeof(buf));
                        n = MIN(n, HARVESTSIZE);
+                       if (n == 0) {
+                               continue;
+                       }
 
                        event.somecounter = get_cyclecount();
                        event.size = n;
@@ -209,4 +212,4 @@ SYSINIT(random_adaptors, SI_SUB_DRIVERS, SI_ORDER_FIRST,
     live_entropy_sources_init, NULL);
 SYSUNINIT(random_adaptors, SI_SUB_DRIVERS, SI_ORDER_FIRST,
     live_entropy_sources_deinit, NULL);
-#endif
\ No newline at end of file
+#endif
-- 
2.7.4

-- 
You received this message because you are subscribed to the Google Groups "OSv 
Development" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to osv-dev+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to