| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent e389e86 commit e3538bb
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,26 +92,20 @@ Maybe<bool> PBKDF2Traits::AdditionalConfig( | |||
| 92 | 92 | ||
| 93 | 93 | params->iterations = args[offset + 2].As<Int32>()->Value(); | |
| 94 | 94 | if (params->iterations < 0) { | |
| 95 | - char msg[1024]; | ||
| 96 | - snprintf(msg, sizeof(msg), "iterations must be <= %d", INT_MAX); | ||
| 97 | - THROW_ERR_OUT_OF_RANGE(env, msg); | ||
| 95 | + THROW_ERR_OUT_OF_RANGE(env, "iterations must be <= %d", INT_MAX); | ||
| 98 | 96 | return Nothing<bool>(); | |
| 99 | 97 | } | |
| 100 | 98 | ||
| 101 | 99 | params->length = args[offset + 3].As<Int32>()->Value(); | |
| 102 | 100 | if (params->length < 0) { | |
| 103 | - char msg[1024]; | ||
| 104 | - snprintf(msg, sizeof(msg), "length must be <= %d", INT_MAX); | ||
| 105 | - THROW_ERR_OUT_OF_RANGE(env, msg); | ||
| 101 | + THROW_ERR_OUT_OF_RANGE(env, "length must be <= %d", INT_MAX); | ||
| 106 | 102 | return Nothing<bool>(); | |
| 107 | 103 | } | |
| 108 | 104 | ||
| 109 | 105 | Utf8Value name(args.GetIsolate(), args[offset + 4]); | |
| 110 | 106 | params->digest = EVP_get_digestbyname(*name); | |
| 111 | 107 | if (params->digest == nullptr) { | |
| 112 | - char errmsg[1024]; | ||
| 113 | - snprintf(errmsg, sizeof(errmsg), "Invalid digest: %s", *name); | ||
| 114 | - THROW_ERR_CRYPTO_INVALID_DIGEST(env, errmsg); | ||
| 108 | + THROW_ERR_CRYPTO_INVALID_DIGEST(env, "Invalid digest: %s", *name); | ||
| 115 | 109 | return Nothing<bool>(); | |
| 116 | 110 | } | |
| 117 | 111 | ||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -231,3 +231,15 @@ if (!common.hasOpenSSL3) { | |||
| 231 | 231 | runPBKDF2(new Uint8Array(10), 'salt', 8, 8, hash); | |
| 232 | 232 | }); | |
| 233 | 233 | } | |
| 234 | + | ||
| 235 | + { | ||
| 236 | + // This should not crash. | ||
| 237 | + assert.throws( | ||
| 238 | + () => crypto.pbkdf2Sync('1', '2', 1, 1, '%'), | ||
| 239 | + { | ||
| 240 | + code: 'ERR_CRYPTO_INVALID_DIGEST', | ||
| 241 | + name: 'TypeError', | ||
| 242 | + message: 'Invalid digest: %' | ||
| 243 | + } | ||
| 244 | + ); | ||
| 245 | + } | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments