Skip to content

fix: crash on windows when UTF-8 is in path#48898

Merged
codebytere merged 1 commit intoelectron:mainfrom
indutny-signal:fix/crash-on-utf8
Nov 13, 2025
Merged

fix: crash on windows when UTF-8 is in path#48898
codebytere merged 1 commit intoelectron:mainfrom
indutny-signal:fix/crash-on-utf8

Conversation

@indutny-signal
Copy link
Copy Markdown
Contributor

Description of Change

In 6399527 we changed the path strings that node_modules.cc operates on from single-byte to wide strings. Unfortunately this means that generic_path() that the "fix: ensure TraverseParent bails on resource path exit" patch was calling was no longer a safe method to call on Windows if the underlying string has unicode characters in it.

Here we fix it by using ConvertGenericPathToUTF8 from the Node.js internal utilities.

cc @codebytere @deepak1556 @VerteDinde

Checklist

Release Notes

Notes: fix crash on windows when UTF-8 is in path

@indutny-signal indutny-signal requested a review from a team as a code owner November 11, 2025 17:38
@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Nov 11, 2025
- bool did_original_path_start_with_resources_path = starts_with(check_path.
- generic_string(), resources_path);
+ bool did_original_path_start_with_resources_path = starts_with(
+ ConvertGenericPathToUTF8(check_path), resources_path);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm... I might actually need to look into how resources_path computed when strings has unicode in it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nvm, it is UTF-8 for both of them so we should be good!

@deepak1556
Copy link
Copy Markdown
Member

Can you move the changes to https://github.com/electron/electron/blob/main/patches/node/fix_ensure_traverseparent_bails_on_resource_path_exit.patch, it will allow for src_use_cp_utf8_for_wide_file_names_on_win32.patch to be dropped when node version with the change is adopted.

@indutny-signal
Copy link
Copy Markdown
Contributor Author

@deepak1556 good idea. Had to reorder patches for this to make more sense sequentially. Thanks!

Copy link
Copy Markdown
Member

@deepak1556 deepak1556 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@deepak1556 deepak1556 added semver/patch backwards-compatible bug fixes target/38-x-y PR should also be added to the "38-x-y" branch. target/39-x-y PR should also be added to the "39-x-y" branch. target/40-x-y PR should also be added to the "40-x-y" branch. labels Nov 11, 2025
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Nov 12, 2025
In 6399527 we changed the path strings
that `node_modules.cc` operates on from single-byte to wide strings.
Unfortunately this means that `generic_path()` that the
"fix: ensure TraverseParent bails on resource path exit" patch was
calling was no longer a safe method to call on Windows if the underlying
string has unicode characters in it.

Here we fix it by using `ConvertGenericPathToUTF8` from the Node.js
internal utilities.
@codebytere codebytere merged commit b9d3f15 into electron:main Nov 13, 2025
148 of 150 checks passed
@release-clerk
Copy link
Copy Markdown

release-clerk bot commented Nov 13, 2025

Release Notes Persisted

fix crash on windows when UTF-8 is in path

@trop
Copy link
Copy Markdown
Contributor

trop bot commented Nov 13, 2025

I was unable to backport this PR to "39-x-y" cleanly;
you will need to perform this backport manually.

@trop trop bot removed the target/39-x-y PR should also be added to the "39-x-y" branch. label Nov 13, 2025
@trop
Copy link
Copy Markdown
Contributor

trop bot commented Nov 13, 2025

I was unable to backport this PR to "38-x-y" cleanly;
you will need to perform this backport manually.

@trop trop bot added needs-manual-bp/39-x-y needs-manual-bp/38-x-y and removed target/38-x-y PR should also be added to the "38-x-y" branch. labels Nov 13, 2025
@trop
Copy link
Copy Markdown
Contributor

trop bot commented Nov 13, 2025

I have automatically backported this PR to "40-x-y", please check out #48942

@trop trop bot added in-flight/40-x-y and removed target/40-x-y PR should also be added to the "40-x-y" branch. labels Nov 13, 2025
@indutny-signal indutny-signal deleted the fix/crash-on-utf8 branch November 13, 2025 18:16
@indutny-signal
Copy link
Copy Markdown
Contributor Author

Ah, manual backport here we go.

@trop
Copy link
Copy Markdown
Contributor

trop bot commented Nov 13, 2025

@indutny-signal has manually backported this PR to "39-x-y", please check out #48944

@indutny-signal
Copy link
Copy Markdown
Contributor Author

Opened #48944 . Thank you so much!

@trop
Copy link
Copy Markdown
Contributor

trop bot commented Nov 13, 2025

@indutny-signal has manually backported this PR to "38-x-y", please check out #48947

@trop trop bot added in-flight/38-x-y merged/40-x-y PR was merged to the "40-x-y" branch. merged/39-x-y PR was merged to the "39-x-y" branch. needs-manual-bp/38-x-y merged/38-x-y PR was merged to the "38-x-y" branch. and removed needs-manual-bp/38-x-y in-flight/40-x-y in-flight/39-x-y in-flight/38-x-y labels Nov 13, 2025
nilayarya pushed a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
In 6399527 we changed the path strings
that `node_modules.cc` operates on from single-byte to wide strings.
Unfortunately this means that `generic_path()` that the
"fix: ensure TraverseParent bails on resource path exit" patch was
calling was no longer a safe method to call on Windows if the underlying
string has unicode characters in it.

Here we fix it by using `ConvertGenericPathToUTF8` from the Node.js
internal utilities.
nilayarya added a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
In 6399527 we changed the path strings
that `node_modules.cc` operates on from single-byte to wide strings.
Unfortunately this means that `generic_path()` that the
"fix: ensure TraverseParent bails on resource path exit" patch was
calling was no longer a safe method to call on Windows if the underlying
string has unicode characters in it.

Here we fix it by using `ConvertGenericPathToUTF8` from the Node.js
internal utilities.
nilayarya added a commit to nilayarya/electron that referenced this pull request Nov 21, 2025
In 6399527 we changed the path strings
that `node_modules.cc` operates on from single-byte to wide strings.
Unfortunately this means that `generic_path()` that the
"fix: ensure TraverseParent bails on resource path exit" patch was
calling was no longer a safe method to call on Windows if the underlying
string has unicode characters in it.

Here we fix it by using `ConvertGenericPathToUTF8` from the Node.js
internal utilities.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/38-x-y PR was merged to the "38-x-y" branch. merged/39-x-y PR was merged to the "39-x-y" branch. merged/40-x-y PR was merged to the "40-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants