'source3/selftest/ktest-krb5_ccache-2',
'source3/selftest/ktest-krb5_ccache-3',
'third_party/pep8/testsuite/latin-1.py',
+ 'testdata/source-chars-bad.c',
}
IGNORED_EXTENSIONS = {
if is_bad_char(c):
self.fail(f"{name} has potentially bad format characters!")
+ def test_unexpected_format_chars_do_fail(self):
+ """Test the test"""
+ for name, n_bad in [
+ ('testdata/source-chars-bad.c', 3)
+ ]:
+ fullname = os.path.join(ROOT, name)
+ with open(fullname) as f:
+ s = f.read()
+ chars = set(s)
+ bad_chars = [c for c in chars if is_bad_char(c)]
+ self.assertEqual(len(bad_chars), n_bad)
+
def check_file_text():
"""If called directly as a script, count the found characters."""
--- /dev/null
+/*
+ * "Trojan Source" CVE-2021-42574 test.
+ *
+ * Based on an example from https://lwn.net/Articles/874951/
+ */
+#include <stdio.h>
+
+int main(int argc, char *argv[])
+{
+ int isAdmin = 0;
+
+#if 0
+ /* This is what is really there. */
+
+ /*«RLO» } «LRI»if (isAdmin)«PDI» «LRI» begin admins only */
+ puts("hello admin");
+ /* end admin only «RLO» { «LRI»*/
+#else
+ /* } if (isAdmin) begin admins only */
+ puts("hello admin");
+ /* end admin only { */
+#endif
+}