diff options
author | Jay Berkenbilt <ejb@ql.org> | 2022-04-02 23:14:10 +0200 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2022-04-04 14:10:40 +0200 |
commit | 12f1eb15ca3fed6310402847559a7c99d3c77847 (patch) | |
tree | 8935675b623c6f3b4914b8b44f7fa5f2816a9241 /libqpdf/InsecureRandomDataProvider.cc | |
parent | f20fa61eb4c323eb1642c69c236b3d9a1f8b2cdb (diff) | |
download | qpdf-12f1eb15ca3fed6310402847559a7c99d3c77847.tar.zst |
Programmatically apply new formatting to code
Run this:
for i in **/*.cc **/*.c **/*.h **/*.hh; do
clang-format < $i >| $i.new && mv $i.new $i
done
Diffstat (limited to 'libqpdf/InsecureRandomDataProvider.cc')
-rw-r--r-- | libqpdf/InsecureRandomDataProvider.cc | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/libqpdf/InsecureRandomDataProvider.cc b/libqpdf/InsecureRandomDataProvider.cc index 4077a35f..b29b0f9f 100644 --- a/libqpdf/InsecureRandomDataProvider.cc +++ b/libqpdf/InsecureRandomDataProvider.cc @@ -1,7 +1,7 @@ #include <qpdf/InsecureRandomDataProvider.hh> -#include <qpdf/qpdf-config.h> #include <qpdf/QUtil.hh> +#include <qpdf/qpdf-config.h> #include <stdlib.h> InsecureRandomDataProvider::InsecureRandomDataProvider() : @@ -16,8 +16,7 @@ InsecureRandomDataProvider::~InsecureRandomDataProvider() void InsecureRandomDataProvider::provideRandomData(unsigned char* data, size_t len) { - for (size_t i = 0; i < len; ++i) - { + for (size_t i = 0; i < len; ++i) { data[i] = static_cast<unsigned char>((this->random() & 0xff0) >> 4); } } @@ -25,13 +24,12 @@ InsecureRandomDataProvider::provideRandomData(unsigned char* data, size_t len) long InsecureRandomDataProvider::random() { - if (! this->seeded_random) - { + if (!this->seeded_random) { // Seed the random number generator with something simple, but // just to be interesting, don't use the unmodified current // time. It would be better if this were a more secure seed. - unsigned int seed = static_cast<unsigned int>( - QUtil::get_current_time() ^ 0xcccc); + unsigned int seed = + static_cast<unsigned int>(QUtil::get_current_time() ^ 0xcccc); #ifdef HAVE_RANDOM ::srandom(seed); #else @@ -40,11 +38,11 @@ InsecureRandomDataProvider::random() this->seeded_random = true; } -# ifdef HAVE_RANDOM +#ifdef HAVE_RANDOM return ::random(); -# else +#else return rand(); -# endif +#endif } RandomDataProvider* |