From a574b43eb81a7792f2e7cdba1051e69f699f414e Mon Sep 17 00:00:00 2001 From: Adriaan de Groot Date: Wed, 29 Jan 2020 16:08:33 +0100 Subject: [PATCH] [libcalamares] Also report empty buffer as no-entropy --- src/libcalamares/utils/Entropy.cpp | 5 +++++ src/libcalamares/utils/Entropy.h | 1 + 2 files changed, 6 insertions(+) diff --git a/src/libcalamares/utils/Entropy.cpp b/src/libcalamares/utils/Entropy.cpp index adba7478c..21ee25115 100644 --- a/src/libcalamares/utils/Entropy.cpp +++ b/src/libcalamares/utils/Entropy.cpp @@ -26,6 +26,11 @@ CalamaresUtils::EntropySource CalamaresUtils::getEntropy( int size, QByteArray& b ) { b.clear(); + if ( size < 1) + { + return EntropySource::None; + } + b.resize( size ); char* buffer = b.data(); std::fill( buffer, buffer + size, 0xcb ); diff --git a/src/libcalamares/utils/Entropy.h b/src/libcalamares/utils/Entropy.h index da2236266..2983e0e24 100644 --- a/src/libcalamares/utils/Entropy.h +++ b/src/libcalamares/utils/Entropy.h @@ -28,6 +28,7 @@ namespace CalamaresUtils /// @brief Which entropy source was actually used for the entropy. enum class EntropySource { + None, ///< Buffer is empty, no random data URandom, ///< Read from /dev/urandom Twister ///< Generated by pseudo-random };