Skip to content

Commit

Permalink
Escape problematic characters in CREDITS files
Browse files Browse the repository at this point in the history
On Windows, the contents of the CREDITS files are passed to rc.exe via
the command line.  To avoid undesired behavior, we need to escape some
characters, most notably `<` (which is sometimes used in CREDITS to
enclose mail addresses), which otherwise is interpreted as redirection
operator, resulting in the hard to understand "The system cannot find
the file specified."

Even more dangerous is not properly escaping percent signs, which makes
it possible for a malicious CREDITS file to inject the values of
environment variables of the build system into the generated binaries.
This is particularly bad, because as of Windows Vista, the comments can
no longer be inspected via explorer.exe, although the binaries still
contain these comments.

We also cater to double-quotes, which need to be escaped as `\"\"` in
this context.

Closes GH-8767.
  • Loading branch information
cmb69 committed Jun 20, 2022
1 parent 6bd0175 commit 8aa7e20
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion win32/build/confutils.js
Expand Up @@ -1093,7 +1093,7 @@ function generate_version_info_resource(makefiletarget, basename, creditspath, s
if (thanks == null) {
thanks = "";
} else {
thanks = "Thanks to " + thanks;
thanks = "Thanks to " + thanks.replace(/([<>&|%])/g, "^$1").replace(/"/g, '\\"\\"');
}
credits.Close();
}
Expand Down

0 comments on commit 8aa7e20

Please sign in to comment.