Skip to content

Commit 3da1292

Browse files
committed
dtls: take the psk error message as a string_view
ReportPSKError took a const char* and passed it to ToV8Value(), which already has a std::string_view overload. Every call site hands it a literal, so the length is known rather than recovered with strlen(). Signed-off-by: James M Snell <jasnell@gmail.com>
1 parent c3c5fef commit 3da1292

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

src/dtls/dtls_context.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -663,7 +663,7 @@ void DTLSContext::SetSNIContexts(const FunctionCallbackInfo<Value>& args) {
663663
// as an uncaughtException. The exception must not still be pending when
664664
// control returns to OpenSSL, which goes on to build an alert and unwind
665665
// through Cycle()'s error path.
666-
void DTLSContext::ReportPSKError(SSL* ssl, const char* message) {
666+
void DTLSContext::ReportPSKError(SSL* ssl, std::string_view message) {
667667
DTLSSession* session = static_cast<DTLSSession*>(SSL_get_app_data(ssl));
668668
if (session == nullptr) return;
669669

src/dtls/dtls_context.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <openssl/ssl.h>
1515

1616
#include <string>
17+
#include <string_view>
1718
#include <unordered_map>
1819
#include <vector>
1920

@@ -94,7 +95,7 @@ class DTLSContext final : public BaseObject {
9495
// Report a PSK callback that did not throw but gave back something
9596
// unusable. Returning 0 to OpenSSL is the "no PSK" signal, so without this
9697
// the caller's mistake arrives as a handshake failure naming no cause.
97-
static void ReportPSKError(SSL* ssl, const char* message);
98+
static void ReportPSKError(SSL* ssl, std::string_view message);
9899

99100
DTLSContext* SelectSNIContextFromCallback(SSL* ssl, const char* servername);
100101
// Recover the context a callback without an argument slot belongs to.

0 commit comments

Comments
 (0)