10000 fix: in GTK open dialog, do not preview huge files by ckerr · Pull Request #31799 · electron/electron · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

fix: in GTK open dialog, do not preview huge files #31799

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 15, 2021

Conversation

ckerr
Copy link
Member
@ckerr ckerr commented Nov 11, 2021

Description of Change

Fixes #31630.

Adds a size check to the image file before previewing it. I've set the cutoff at 100 MB since "100 MB ought to be enough for anybody" but if there's a strong use case for previewing 100 MB image files we could increase it.

CC @codebytere

Checklist

Release Notes

Notes: Fixed crash in GTK open dialog when trying to preview huge image files.

Previewing images whose files are larger than a GB can crash Electron.
@ckerr ckerr self-assigned this Nov 11, 2021
@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Nov 11, 2021
// Setting an arbitrary filesize max t at 100 MB here.
constexpr off_t ArbitraryMax = 100000000ULL;
if (st.st_size >= ArbitraryMax) {
return false;
Copy link
Member

Choose a reason for hiding this comment

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

tiny nit but we can probably just

return st.st_size < ArbitraryMax;

here!

Copy link
Member Author

Choose a reason for hiding this comment

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

SGTM. 9578048

@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Nov 12, 2021
@codebytere codebytere merged commit c8ba3b4 into main Nov 15, 2021
@codebytere codebytere deleted the fix/etoobig-gtk-file-previews branch November 15, 2021 07:17
@release-clerk
Copy link
release-clerk bot commented Nov 15, 2021

Release Notes Persisted

Fixed crash in GTK open dialog when trying to preview huge image files.

@trop
Copy link
Contributor
trop bot commented Nov 15, 2021

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

@trop
Copy link
Contributor
trop bot commented Nov 15, 2021

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

@trop
Copy link
Contributor
trop bot commented Nov 15, 2021

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component/dialog semver/patch backwards-compatible bug fixes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug]: Image preview during dialog.showOpenDialog() crashes app on large image files
3 participants
0