Skip to content

Commit d1ab2d2

Browse files
committed
C++: Remove some irrelevant macro logic and main functions.
1 parent fdb4a2a commit d1ab2d2

File tree

3 files changed

+0
-117
lines changed

3 files changed

+0
-117
lines changed

cpp/ql/test/query-tests/Security/CWE/CWE-022/SAMATE/CWE23_Relative_Path_Traversal__char_console_fopen_11.cpp

Lines changed: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
typedef size_t time_t;
99
time_t time(time_t *timer);
10-
void srand(unsigned int seed);
1110

1211
typedef struct {} FILE;
1312
extern FILE *stdin;
@@ -130,35 +129,3 @@ static void goodG2B2()
130129
}
131130
}
132131
}
133-
134-
void good()
135-
{
136-
goodG2B1();
137-
goodG2B2();
138-
}
139-
140-
} /* close namespace */
141-
142-
/* Below is the main(). It is only used when building this testcase on
143-
its own for testing or for building a binary to use in testing binary
144-
analysis tools. It is not used when compiling all the testcases as one
145-
application, which is how source code analysis tools are tested. */
146-
147-
using namespace CWE23_Relative_Path_Traversal__char_console_fopen_11; /* so that we can use good and bad easily */
148-
149-
int main(int argc, char * argv[])
150-
{
151-
/* seed randomness */
152-
srand( (unsigned)time(NULL) );
153-
#ifndef OMITGOOD
154-
printLine("Calling good()...");
155-
good();
156-
printLine("Finished good()");
157-
#endif /* OMITGOOD */
158-
#ifndef OMITBAD
159-
printLine("Calling bad()...");
160-
bad();
161-
printLine("Finished bad()");
162-
#endif /* OMITBAD */
163-
return 0;
164-
}

cpp/ql/test/query-tests/Security/CWE/CWE-134/SAMATE/console_fprintf_01/test.c

Lines changed: 0 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,9 @@ size_t strlen(const char *s);
1212
char *fgets(char *s, int n, FILE *stream);
1313
int fprintf(FILE *stream, const char *format, ...);
1414
char *strcpy(char *s1, const char *s2);
15-
void srand(unsigned int seed);
1615

1716
void printLine(char *);
1817

19-
#ifndef OMITBAD
20-
2118
void CWE134_Uncontrolled_Format_String__char_console_fprintf_01_bad()
2219
{
2320
char * data;
@@ -52,10 +49,6 @@ void CWE134_Uncontrolled_Format_String__char_console_fprintf_01_bad()
5249
fprintf(stdout, data);
5350
}
5451

55-
#endif /* OMITBAD */
56-
57-
#ifndef OMITGOOD
58-
5952
/* goodG2B uses the GoodSource with the BadSink */
6053
static void goodG2B()
6154
{
@@ -102,37 +95,3 @@ static void goodB2G()
10295
/* FIX: Specify the format disallowing a format string vulnerability */
10396
fprintf(stdout, "%s\n", data);
10497
}
105-
106-
void CWE134_Uncontrolled_Format_String__char_console_fprintf_01_good()
107-
{
108-
goodG2B();
109-
goodB2G();
110-
}
111-
112-
#endif /* OMITGOOD */
113-
114-
/* Below is the main(). It is only used when building this testcase on
115-
its own for testing or for building a binary to use in testing binary
116-
analysis tools. It is not used when compiling all the testcases as one
117-
application, which is how source code analysis tools are tested. */
118-
119-
#ifdef INCLUDEMAIN
120-
121-
int main(int argc, char * argv[])
122-
{
123-
/* seed randomness */
124-
srand( (unsigned)time(NULL) );
125-
#ifndef OMITGOOD
126-
printLine("Calling good()...");
127-
CWE134_Uncontrolled_Format_String__char_console_fprintf_01_good();
128-
printLine("Finished good()");
129-
#endif /* OMITGOOD */
130-
#ifndef OMITBAD
131-
printLine("Calling bad()...");
132-
CWE134_Uncontrolled_Format_String__char_console_fprintf_01_bad();
133-
printLine("Finished bad()");
134-
#endif /* OMITBAD */
135-
return 0;
136-
}
137-
138-
#endif

cpp/ql/test/query-tests/Security/CWE/CWE-134/SAMATE/environment_fprintf_01/test.c

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -7,20 +7,15 @@
77
typedef struct {} FILE;
88
typedef unsigned long size_t;
99
extern FILE * stdout;
10-
void srand(unsigned int seed);
1110
size_t strlen(const char *s);
1211
char *getenv(const char *name);
1312
char *strcpy(char *s1, const char *s2);
1413
char *strncat(char *s1, const char *s2, size_t n);
1514
int fprintf(FILE *stream, const char *format, ...);
1615

17-
void printLine(char *);
18-
1916
#define ENV_VARIABLE "ADD"
2017
#define GETENV getenv
2118

22-
#ifndef OMITBAD
23-
2419
void CWE134_Uncontrolled_Format_String__char_environment_fprintf_01_bad()
2520
{
2621
char * data;
@@ -41,10 +36,6 @@ void CWE134_Uncontrolled_Format_String__char_environment_fprintf_01_bad()
4136
fprintf(stdout, data);
4237
}
4338

44-
#endif /* OMITBAD */
45-
46-
#ifndef OMITGOOD
47-
4839
/* goodG2B uses the GoodSource with the BadSink */
4940
static void goodG2B()
5041
{
@@ -77,37 +68,3 @@ static void goodB2G()
7768
/* FIX: Specify the format disallowing a format string vulnerability */
7869
fprintf(stdout, "%s\n", data);
7970
}
80-
81-
void CWE134_Uncontrolled_Format_String__char_environment_fprintf_01_good()
82-
{
83-
goodG2B();
84-
goodB2G();
85-
}
86-
87-
#endif /* OMITGOOD */
88-
89-
/* Below is the main(). It is only used when building this testcase on
90-
its own for testing or for building a binary to use in testing binary
91-
analysis tools. It is not used when compiling all the testcases as one
92-
application, which is how source code analysis tools are tested. */
93-
94-
#ifdef INCLUDEMAIN
95-
96-
int main(int argc, char * argv[])
97-
{
98-
/* seed randomness */
99-
srand( (unsigned)time(NULL) );
100-
#ifndef OMITGOOD
101-
printLine("Calling good()...");
102-
CWE134_Uncontrolled_Format_String__char_environment_fprintf_01_good();
103-
printLine("Finished good()");
104-
#endif /* OMITGOOD */
105-
#ifndef OMITBAD
106-
printLine("Calling bad()...");
107-
CWE134_Uncontrolled_Format_String__char_environment_fprintf_01_bad();
108-
printLine("Finished bad()");
109-
#endif /* OMITBAD */
110-
return 0;
111-
}
112-
113-
#endif

0 commit comments

Comments
 (0)