Skip to content

Commit

Permalink
when forwarding call to versioned binary, always quote arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
h-vetinari committed Aug 22, 2024
1 parent 121ed44 commit 84ed6fc
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions recipe/win_forwarder.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,14 @@ int _tmain( int argc, TCHAR *argv[] )
// set null-terminator to finish the string early
forwarded[len-4] = '\0';
strcat(forwarded, "-{{ majorversion }}.exe");
// rest stays the same
// rest stays the same, but wrap everything in quotes, because
// the contents of argv[i] get stripped of those, which fails
// if there's any argument that relies on atomicity, e.g. paths
// with spaces in them (c.f. "C:\Program Files\...")
for (int i = 1; i < argc; i++) {
strcat(forwarded, " ");
strcat(forwarded, " \"");
strcat(forwarded, argv[i]);
strcat(forwarded, "\"");
}

// Start the child process.
Expand Down

0 comments on commit 84ed6fc

Please sign in to comment.