Fix shell command safety: replace popen() with g_spawn functions#1314
Merged
Conversation
Replace two popen() calls with GLib's g_spawn_async() and g_spawn_sync() to avoid passing arguments through a shell. This prevents filenames or other data containing shell metacharacters from being interpreted as shell commands. - src/main/url.cc show_separate_image(): use g_spawn_async() with an argument array and G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL flags, matching the original redirect-to-devnull behavior. Report errors via GError. - src/gtk/menu_popup.c on_rename_perscomm_activate(): use g_spawn_sync() with sed invoked via argument array. Capture stdout and write the result via g_file_set_contents(). Check exit status and GError.
Contributor
Author
|
@karlkleinpaste If you have a private way of contacting you I can share additional information about this fix and impact. Thank you. |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Replace two popen() calls with GLib's g_spawn_async() and g_spawn_sync() to avoid passing arguments through a shell. This prevents filenames or other data containing shell metacharacters from being interpreted as shell commands.
src/main/url.cc show_separate_image(): use g_spawn_async() with an argument array and G_SPAWN_STDOUT_TO_DEV_NULL | G_SPAWN_STDERR_TO_DEV_NULL flags, matching the original redirect-to-devnull behavior. Report errors via GError.
src/gtk/menu_popup.c on_rename_perscomm_activate(): use g_spawn_sync() with sed invoked via argument array. Capture stdout and write the result via g_file_set_contents(). Check exit status and GError.