File tree Expand file tree Collapse file tree
cpp/ql/test/experimental/query-tests/Security/CWE/CWE-200/semmle/tests Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ typedef int FILE;
2+ FILE *fopen (const char *filename, const char *mode);
3+ int umask (int pmode);
4+ int chmod (char * filename,int pmode);
5+ int fprintf (FILE *fp,const char *fmt, ...);
6+ int fclose (FILE *stream);
7+
8+ int main (int argc, char *argv[])
9+ {
10+ // umask(0022);
11+ FILE *fp;
12+ fp = fopen (" myFile.txt" ," w" ); // BAD
13+ // chmod("myFile.txt",0644);
14+ fprintf (fp," %s\n " ," data to file" );
15+ fclose (fp);
16+ return 0 ;
17+ }
Original file line number Diff line number Diff line change 1+ typedef int FILE;
2+ FILE *fopen (const char *filename, const char *mode);
3+ int umask (int pmode);
4+ int chmod (char * filename,int pmode);
5+ int fprintf (FILE *fp,const char *fmt, ...);
6+ char *fgets (char *str, int num, FILE *stream);
7+ int fclose (FILE *stream);
8+
9+ int main (int argc, char *argv[])
10+ {
11+ FILE *fp;
12+ char buf[128 ];
13+ fp = fopen (" myFile.txt" ," w" ); // BAD [NOT DETECTED]
14+ fgets (buf,128 ,fp);
15+ fprintf (fp," %s\n " ," data to file" );
16+ fclose (fp);
17+ return 0 ;
18+ }
You can’t perform that action at this time.
0 commit comments