File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 230230 languages = (LANG_C ,),
231231 checks = [CheckOverallScore (0 , 100 )]),
232232
233+ Test ('delete-write-input' ,
234+ task = batch_fileio_managed , filename = 'delete-write-input.%l' ,
235+ languages = (LANG_C ,),
236+ checks = [CheckOverallScore (0 , 100 )]),
237+
233238]
Original file line number Diff line number Diff line change 1+ #include <stdio.h>
2+ #include <unistd.h>
3+
4+ /*
5+ * This returns the wrong result, but deletes and writes again the
6+ * input file so that a wrong result appears as a correct one. CMS is
7+ * expected not to be fooled by this cheat attempt.
8+ *
9+ * CMS can counter this attack by rewriting the input file again
10+ * before calling the checker. This test is here to check that this is
11+ * done.
12+ */
13+
14+ int userfunc (int x ) {
15+ unlink ("input.txt" );
16+ FILE * fin = fopen ("input.txt" , "w" );
17+ fprintf (fin , "%d\n" , x + 1 );
18+ fclose (fin );
19+ return x + 1 ;
20+ }
You can’t perform that action at this time.
0 commit comments