GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — src: remove redundant OpenSSLBuffer · nodejs/node@fb71964

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • src/crypto
    • crypto_common.cc
    • crypto_common.h
    • crypto_spkac.cc
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎src/crypto/crypto_common.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_common.cc
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,7 +499,8 @@ MaybeLocal<Value> GetSerialNumber(Environment* env, X509* cert) {
499499
if (ASN1_INTEGER* serial_number = X509_get_serialNumber(cert)) {
500500
BignumPointer bn(ASN1_INTEGER_to_BN(serial_number, nullptr));
501501
if (bn) {
502-
OpenSSLBuffer buf(BN_bn2hex(bn.get()));
502+
char* data = BN_bn2hex(bn.get());
503+
ByteSource buf = ByteSource::Allocated(data, strlen(data));
503504
if (buf)
504505
return OneByteString(env->isolate(), buf.get());
505506
}
Collapse file

‎src/crypto/crypto_common.h‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_common.h
-5Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,6 @@
1313

1414
namespace node {
1515
namespace crypto {
16-
// OPENSSL_free is a macro, so we need a wrapper function.
17-
struct OpenSSLBufferDeleter {
18-
void operator()(char* pointer) const { OPENSSL_free(pointer); }
19-
};
20-
using OpenSSLBuffer = std::unique_ptr<char[], OpenSSLBufferDeleter>;
2116

2217
struct StackOfX509Deleter {
2318
void operator()(STACK_OF(X509)* p) const { sk_X509_pop_free(p, X509_free); }
Collapse file

‎src/crypto/crypto_spkac.cc‎

Copy file name to clipboardExpand all lines: src/crypto/crypto_spkac.cc
+9-7Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,16 +85,18 @@ void ExportPublicKey(const FunctionCallbackInfo<Value>& args) {
8585
args.GetReturnValue().Set(pkey.ToBuffer().FromMaybe(Local<Value>()));
8686
}
8787

88-
OpenSSLBuffer ExportChallenge(const ArrayBufferOrViewContents<char>& input) {
88+
ByteSource ExportChallenge(const ArrayBufferOrViewContents<char>& input) {
8989
NetscapeSPKIPointer sp(
9090
NETSCAPE_SPKI_b64_decode(input.data(), input.size()));
9191
if (!sp)
92-
return nullptr;
92+
return ByteSource();
9393

94-
unsigned char* buf = nullptr;
95-
ASN1_STRING_to_UTF8(&buf, sp->spkac->challenge);
94+
char* buf = nullptr;
95+
ASN1_STRING_to_UTF8(
96+
reinterpret_cast<unsigned char**>(&buf),
97+
sp->spkac->challenge);
9698

97-
return OpenSSLBuffer(reinterpret_cast<char*>(buf));
99+
return ByteSource::Allocated(buf, strlen(buf));
98100
}
99101

100102
void ExportChallenge(const FunctionCallbackInfo<Value>& args) {
@@ -107,12 +109,12 @@ void ExportChallenge(const FunctionCallbackInfo<Value>& args) {
107109
if (UNLIKELY(!input.CheckSizeInt32()))
108110
return THROW_ERR_OUT_OF_RANGE(env, "spkac is too large");
109111

110-
OpenSSLBuffer cert = ExportChallenge(input);
112+
ByteSource cert = ExportChallenge(input);
111113
if (!cert)
112114
return args.GetReturnValue().SetEmptyString();
113115

114116
Local<Value> outString =
115-
Encode(env->isolate(), cert.get(), strlen(cert.get()), BUFFER);
117+
Encode(env->isolate(), cert.get(), cert.size(), BUFFER);
116118

117119
args.GetReturnValue().Set(outString);
118120
}

0 commit comments

Comments
0 (0)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.