Skip to content

fix/cmd-injection-dvi-export - #2

Merged
yuri-schmaltz merged 1 commit into
masterfrom
fix/cmd-injection-dvi-export
Jul 28, 2026
Merged

fix/cmd-injection-dvi-export#2
yuri-schmaltz merged 1 commit into
masterfrom
fix/cmd-injection-dvi-export

Conversation

@yuri-schmaltz

Copy link
Copy Markdown
Owner

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 explicit argv[]; splits -s and the page list, strips trailing comma

Diff stat

 backend/dvi/dvi-document.c | 48 ++++++++++++++++++++++++++++++----------------
 1 file changed, 31 insertions(+), 17 deletions(-)

Upstream discussion context: linuxmint#725

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant