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 };