diff options
-rw-r--r-- | meta-oe/recipes-devtools/nodejs/nodejs/0003-Crypto-reduce-memory-usage-of-SignFinal.patch | 122 | ||||
-rw-r--r-- | meta-oe/recipes-devtools/nodejs/nodejs_10.17.0.bb (renamed from meta-oe/recipes-devtools/nodejs/nodejs_10.16.3.bb) | 5 |
2 files changed, 2 insertions, 125 deletions
diff --git a/meta-oe/recipes-devtools/nodejs/nodejs/0003-Crypto-reduce-memory-usage-of-SignFinal.patch b/meta-oe/recipes-devtools/nodejs/nodejs/0003-Crypto-reduce-memory-usage-of-SignFinal.patch deleted file mode 100644 index ed3bac39bd..0000000000 --- a/meta-oe/recipes-devtools/nodejs/nodejs/0003-Crypto-reduce-memory-usage-of-SignFinal.patch +++ /dev/null | |||
@@ -1,122 +0,0 @@ | |||
1 | From 20282b1cb0389553421c4c5b14de198c5dfff50b Mon Sep 17 00:00:00 2001 | ||
2 | From: Anna Henningsen <anna@addaleax.net> | ||
3 | Date: Sat, 20 Oct 2018 05:24:54 +0200 | ||
4 | Subject: [PATCH] src: use more explicit return type in Sign::SignFinal() | ||
5 | MIME-Version: 1.0 | ||
6 | Content-Type: text/plain; charset=UTF-8 | ||
7 | Content-Transfer-Encoding: 8bit | ||
8 | |||
9 | Using the non-indexed variant of `std::get<>` broke Travis CI. | ||
10 | Also, this allows us to be a bit more concise when returning | ||
11 | from `SignFinal()` due to some error condition. | ||
12 | |||
13 | Refs: https://github.com/nodejs/node/pull/23427 | ||
14 | |||
15 | PR-URL: https://github.com/nodejs/node/pull/23779 | ||
16 | Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com> | ||
17 | Reviewed-By: Tobias Nießen <tniessen@tnie.de> | ||
18 | Reviewed-By: Refael Ackermann <refack@gmail.com> | ||
19 | Reviewed-By: Colin Ihrig <cjihrig@gmail.com> | ||
20 | --- | ||
21 | src/node_crypto.cc | 23 +++++++++++------------ | ||
22 | src/node_crypto.h | 12 +++++++++++- | ||
23 | 2 files changed, 22 insertions(+), 13 deletions(-) | ||
24 | |||
25 | diff --git a/src/node_crypto.cc b/src/node_crypto.cc | ||
26 | index bd8d9e032554..ec7d4f2bb5be 100644 | ||
27 | --- a/src/node_crypto.cc | ||
28 | +++ b/src/node_crypto.cc | ||
29 | @@ -3562,22 +3562,20 @@ static MallocedBuffer<unsigned char> Node_SignFinal(EVPMDPointer&& mdctx, | ||
30 | return MallocedBuffer<unsigned char>(); | ||
31 | } | ||
32 | |||
33 | -std::pair<SignBase::Error, MallocedBuffer<unsigned char>> Sign::SignFinal( | ||
34 | +Sign::SignResult Sign::SignFinal( | ||
35 | const char* key_pem, | ||
36 | int key_pem_len, | ||
37 | const char* passphrase, | ||
38 | int padding, | ||
39 | int salt_len) { | ||
40 | - MallocedBuffer<unsigned char> buffer; | ||
41 | - | ||
42 | if (!mdctx_) | ||
43 | - return std::make_pair(kSignNotInitialised, std::move(buffer)); | ||
44 | + return SignResult(kSignNotInitialised); | ||
45 | |||
46 | EVPMDPointer mdctx = std::move(mdctx_); | ||
47 | |||
48 | BIOPointer bp(BIO_new_mem_buf(const_cast<char*>(key_pem), key_pem_len)); | ||
49 | if (!bp) | ||
50 | - return std::make_pair(kSignPrivateKey, std::move(buffer)); | ||
51 | + return SignResult(kSignPrivateKey); | ||
52 | |||
53 | EVPKeyPointer pkey(PEM_read_bio_PrivateKey(bp.get(), | ||
54 | nullptr, | ||
55 | @@ -3588,7 +3586,7 @@ std::pair<SignBase::Error, MallocedBuffer<unsigned char>> Sign::SignFinal( | ||
56 | // without `pkey` being set to nullptr; | ||
57 | // cf. the test of `test_bad_rsa_privkey.pem` for an example. | ||
58 | if (!pkey || 0 != ERR_peek_error()) | ||
59 | - return std::make_pair(kSignPrivateKey, std::move(buffer)); | ||
60 | + return SignResult(kSignPrivateKey); | ||
61 | |||
62 | #ifdef NODE_FIPS_MODE | ||
63 | /* Validate DSA2 parameters from FIPS 186-4 */ | ||
64 | @@ -3612,9 +3610,10 @@ std::pair<SignBase::Error, MallocedBuffer<unsigned char>> Sign::SignFinal( | ||
65 | } | ||
66 | #endif // NODE_FIPS_MODE | ||
67 | |||
68 | - buffer = Node_SignFinal(std::move(mdctx), pkey, padding, salt_len); | ||
69 | + MallocedBuffer<unsigned char> buffer = | ||
70 | + Node_SignFinal(std::move(mdctx), pkey, padding, salt_len); | ||
71 | Error error = buffer.is_empty() ? kSignPrivateKey : kSignOk; | ||
72 | - return std::make_pair(error, std::move(buffer)); | ||
73 | + return SignResult(error, std::move(buffer)); | ||
74 | } | ||
75 | |||
76 | |||
77 | @@ -3639,18 +3638,18 @@ void Sign::SignFinal(const FunctionCallbackInfo<Value>& args) { | ||
78 | |||
79 | ClearErrorOnReturn clear_error_on_return; | ||
80 | |||
81 | - std::pair<Error, MallocedBuffer<unsigned char>> ret = sign->SignFinal( | ||
82 | + SignResult ret = sign->SignFinal( | ||
83 | buf, | ||
84 | buf_len, | ||
85 | len >= 2 && !args[1]->IsNull() ? *passphrase : nullptr, | ||
86 | padding, | ||
87 | salt_len); | ||
88 | |||
89 | - if (std::get<Error>(ret) != kSignOk) | ||
90 | - return sign->CheckThrow(std::get<Error>(ret)); | ||
91 | + if (ret.error != kSignOk) | ||
92 | + return sign->CheckThrow(ret.error); | ||
93 | |||
94 | MallocedBuffer<unsigned char> sig = | ||
95 | - std::move(std::get<MallocedBuffer<unsigned char>>(ret)); | ||
96 | + std::move(ret.signature); | ||
97 | |||
98 | Local<Object> rc = | ||
99 | Buffer::New(env, reinterpret_cast<char*>(sig.release()), sig.size) | ||
100 | diff --git a/src/node_crypto.h b/src/node_crypto.h | ||
101 | index 6fcf737f6c43..0c26c1f6ff1d 100644 | ||
102 | --- a/src/node_crypto.h | ||
103 | +++ b/src/node_crypto.h | ||
104 | @@ -518,7 +518,17 @@ class Sign : public SignBase { | ||
105 | public: | ||
106 | static void Initialize(Environment* env, v8::Local<v8::Object> target); | ||
107 | |||
108 | - std::pair<Error, MallocedBuffer<unsigned char>> SignFinal( | ||
109 | + struct SignResult { | ||
110 | + Error error; | ||
111 | + MallocedBuffer<unsigned char> signature; | ||
112 | + | ||
113 | + explicit SignResult( | ||
114 | + Error err, | ||
115 | + MallocedBuffer<unsigned char>&& sig = MallocedBuffer<unsigned char>()) | ||
116 | + : error(err), signature(std::move(sig)) {} | ||
117 | + }; | ||
118 | + | ||
119 | + SignResult SignFinal( | ||
120 | const char* key_pem, | ||
121 | int key_pem_len, | ||
122 | const char* passphrase, | ||
diff --git a/meta-oe/recipes-devtools/nodejs/nodejs_10.16.3.bb b/meta-oe/recipes-devtools/nodejs/nodejs_10.17.0.bb index 97a1967cc2..58d3cce310 100644 --- a/meta-oe/recipes-devtools/nodejs/nodejs_10.16.3.bb +++ b/meta-oe/recipes-devtools/nodejs/nodejs_10.17.0.bb | |||
@@ -17,7 +17,6 @@ COMPATIBLE_HOST_riscv32 = "null" | |||
17 | 17 | ||
18 | SRC_URI = "http://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz \ | 18 | SRC_URI = "http://nodejs.org/dist/v${PV}/node-v${PV}.tar.xz \ |
19 | file://0001-Disable-running-gyp-files-for-bundled-deps.patch \ | 19 | file://0001-Disable-running-gyp-files-for-bundled-deps.patch \ |
20 | file://0003-Crypto-reduce-memory-usage-of-SignFinal.patch \ | ||
21 | file://0004-Make-compatibility-with-gcc-4.8.patch \ | 20 | file://0004-Make-compatibility-with-gcc-4.8.patch \ |
22 | file://0005-Link-atomic-library.patch \ | 21 | file://0005-Link-atomic-library.patch \ |
23 | file://0006-Use-target-ldflags.patch \ | 22 | file://0006-Use-target-ldflags.patch \ |
@@ -26,8 +25,8 @@ SRC_URI_append_class-target = " \ | |||
26 | file://0002-Using-native-torque.patch \ | 25 | file://0002-Using-native-torque.patch \ |
27 | " | 26 | " |
28 | 27 | ||
29 | SRC_URI[md5sum] = "b41275a018e670947c1950b12f050a2f" | 28 | SRC_URI[md5sum] = "d5a56d0abf764a91f627f0690cd4b9f3" |
30 | SRC_URI[sha256sum] = "7bf1123d7415964775b8f81fe6ec6dd5c3c08abb42bb71dfe4409dbeeba26bbd" | 29 | SRC_URI[sha256sum] = "412667d76bd5273c07cb69c215998109fd5bb35c874654f93e6a0132d666c58e" |
31 | 30 | ||
32 | S = "${WORKDIR}/node-v${PV}" | 31 | S = "${WORKDIR}/node-v${PV}" |
33 | 32 | ||