Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7853462

Browse filesBrowse files
lemireaduh95
authored andcommitted
src: provide workaround for container-overflow
PR-URL: #55591 Refs: #55584 Reviewed-By: Shelley Vohr <shelley.vohr@gmail.com> Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 10b68ed commit 7853462
Copy full SHA for 7853462

File tree

Expand file treeCollapse file tree

1 file changed

+13
-1
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+13
-1
lines changed
Open diff view settings
Collapse file

‎src/node_modules.cc‎

Copy file name to clipboardExpand all lines: src/node_modules.cc
+13-1Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,23 @@ const BindingData::PackageConfig* BindingData::GetPackageJSON(
100100
if (ReadFileSync(&package_config.raw_json, path.data()) < 0) {
101101
return nullptr;
102102
}
103+
// In some systems, std::string is annotated to generate an
104+
// AddressSanitizer: container-overflow error when reading beyond the end of
105+
// the string even when we are still within the capacity of the string.
106+
// https://github.com/google/sanitizers/wiki/AddressSanitizerContainerOverflow
107+
// https://github.com/nodejs/node/issues/55584
108+
// The next lines are a workaround to avoid this false positive.
109+
size_t json_length = package_config.raw_json.size();
110+
package_config.raw_json.append(simdjson::SIMDJSON_PADDING, ' ');
111+
simdjson::padded_string_view json_view(package_config.raw_json.data(),
112+
json_length,
113+
package_config.raw_json.size());
114+
// End of workaround
103115

104116
simdjson::ondemand::document document;
105117
simdjson::ondemand::object main_object;
106118
simdjson::error_code error =
107-
binding_data->json_parser.iterate(package_config.raw_json).get(document);
119+
binding_data->json_parser.iterate(json_view).get(document);
108120

109121
const auto throw_invalid_package_config = [error_context, path, realm]() {
110122
if (error_context == nullptr) {

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.