Skip to content

Commit 8aa7e20

Browse files
committed
Escape problematic characters in CREDITS files
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.
1 parent 6bd0175 commit 8aa7e20

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

win32/build/confutils.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,7 @@ function generate_version_info_resource(makefiletarget, basename, creditspath, s
10931093
if (thanks == null) {
10941094
thanks = "";
10951095
} else {
1096-
thanks = "Thanks to " + thanks;
1096+
thanks = "Thanks to " + thanks.replace(/([<>&|%])/g, "^$1").replace(/"/g, '\\"\\"');
10971097
}
10981098
credits.Close();
10991099
}

0 commit comments

Comments
 (0)