fix/cmd-injection-dvi-export - #2
Merged
Merged
Conversation
When exporting a DVI document to PDF, the previous code built a command-line string with g_strdup_printf() and ran it through g_spawn_command_line_sync(), which routes the string through /bin/sh -c. The argument values came from three places: * exporter_opts->str: built from page indices, low risk in practice * exporter_filename: chosen by the user in the export file dialog * context->filename: the path of the opened DVI document While the user-supplied values were shell-quoted with g_shell_quote(), this is the same fragile pattern that was recently patched in ev_spawn (commit 50052ea) and that the print previewer path also used. Build the argv[] array directly instead: argv = { dvipdfm, -s, <pages>, -o, exporter_filename, context->filename, NULL } The "-s <pages>" pair is split from exporter_opts and the trailing comma appended by do_page() is stripped, so dvipdfm receives the pages list as a single argument exactly as it would have through the shell. No shell, no tokenizer on our side: each element is forwarded verbatim to the child.
This was referenced Jul 30, 2026
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.
Fork-only PR. Mirrors the changes from PR linuxmint#725 against linuxmint/xreader, which was closed because the author's workflow for this repo is fork-only.
Changes
backend/dvi/dvi-document.c: dvipdfm export —g_spawn_command_line_sync()→g_spawn_sync()with explicitargv[]; splits-sand the page list, strips trailing commaDiff stat
Upstream discussion context: linuxmint#725