◐ Shell
clean mode source ↗

url: process crash via malformed UNC hostname in pathToFileURL() · nodejs/node@9a25fc8

@@ -93,7 +93,6 @@ constexpr auto lookup_table = []() consteval {

9393

case CHAR: \

9494

result[i] = {{'%', HEX_DIGIT_2, HEX_DIGIT_1, 0}}; \

9595

break;

96-9796

ENCODE_CHAR('\0', '0', '0') // '\0' == 0x00

9897

ENCODE_CHAR('\t', '0', '9') // '\t' == 0x09

9998

ENCODE_CHAR('\n', '0', 'A') // '\n' == 0x0A

@@ -169,7 +168,11 @@ void BindingData::PathToFileURL(const FunctionCallbackInfo<Value>& args) {

169168

[[unlikely]] {

170169

CHECK(args[2]->IsString());

171170

Utf8Value hostname(isolate, args[2]);

172-

CHECK(out->set_hostname(hostname.ToStringView()));

171+

if (!out->set_hostname(hostname.ToStringView())) {

172+

return ThrowInvalidURL(realm->env(),

173+

input.ToStringView(),

174+

std::string(hostname.ToStringView()));

175+

}

173176

}

174177175178

binding_data->UpdateComponents(out->get_components(), out->type);