MCPcopy Create free account
hub / github.com/apache/arrow / RandBytes

Function RandBytes

cpp/src/parquet/encryption/encryption_internal.cc:764–780  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

762}
763
764void RandBytes(unsigned char* buf, size_t num) {
765 if (num > static_cast<size_t>(std::numeric_limits<int>::max())) {
766 std::stringstream ss;
767 ss << "Length " << num << " for RandBytes overflows int";
768 throw ParquetException(ss.str());
769 }
770 openssl::EnsureInitialized();
771 int status = RAND_bytes(buf, static_cast<int>(num));
772 if (status != 1) {
773 const auto error_code = ERR_get_error();
774 char buffer[256];
775 ERR_error_string_n(error_code, buffer, sizeof(buffer));
776 std::stringstream ss;
777 ss << "Failed to generate random bytes: " << buffer;
778 throw ParquetException(ss.str());
779 }
780}
781
782void EnsureBackendInitialized() { openssl::EnsureInitialized(); }
783

Calls 3

ParquetExceptionFunction · 0.85
EnsureInitializedFunction · 0.85
strMethod · 0.80

Tested by

no test coverage detected