bneradt commented on code in PR #13397:
URL: https://github.com/apache/trafficserver/pull/13397#discussion_r3708919387
##########
src/iocore/net/quic/QUICConfig.cc:
##########
@@ -23,23 +23,158 @@
#include "iocore/net/quic/QUICConfig.h"
+#include <openssl/crypto.h>
+#include <openssl/rand.h>
#if TS_HAS_OPENSSL_QUIC
#include <openssl/quic.h>
#endif
#include <openssl/ssl.h>
#include "mgmt/config/ConfigContextDiags.h"
+#include "mgmt/config/ConfigRegistry.h"
#include "records/RecHttp.h"
+#include "tscore/Layout.h"
+#include "tscore/MatcherUtils.h"
+#include "tscore/ink_memory.h"
#include "../P_SSLConfig.h"
#include "../P_TLSKeyLogger.h"
#include "iocore/net/quic/QUICGlobals.h"
#include "iocore/net/quic/QUICTransportParameters.h"
+int QUICTokenKeyConfig::_config_id = 0;
int QUICConfig::_config_id = 0;
int QUICConfigParams::_connection_table_size = 65521;
+QUICTokenKeyConfigParams::~QUICTokenKeyConfigParams()
+{
+ if (!m_keys.empty()) {
+ OPENSSL_cleanse(m_keys.data(), m_keys.size() * sizeof(Key));
+ }
+}
+
+bool
+QUICTokenKeyConfigParams::load(const char *path, ConfigContext ctx)
+{
+ int key_data_len = 0;
+ ats_scoped_str key_data{readIntoBuffer(path, __func__, &key_data_len)};
+
+ if (!key_data) {
+ CfgLoadFail(ctx, "Could not load QUIC token key from %s", path);
+ return false;
+ }
+
+ if (key_data_len < static_cast<int>(KEY_LENGTH) || key_data_len % KEY_LENGTH
!= 0) {
+ CfgLoadFail(ctx, "QUIC token key file %s must contain one or more %zu-byte
keys", path, KEY_LENGTH);
+ OPENSSL_cleanse(key_data.get(), key_data_len);
+ return false;
+ }
+
+ m_keys.resize(key_data_len / KEY_LENGTH);
+ memcpy(m_keys.data(), key_data.get(), key_data_len);
+ OPENSSL_cleanse(key_data.get(), key_data_len);
+ m_filename = path;
+ return true;
Review Comment:
Fixed. The load path now rejects a negative narrowed byte count before any
size-based operation, then converts the validated count to size_t for
validation, allocation, copying, and cleansing.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]