mirror of
https://github.com/github/codeql.git
synced 2026-05-02 04:05:14 +02:00
C++: Remove some irrelevant macro logic and main functions.
This commit is contained in:
@@ -7,7 +7,6 @@
|
||||
|
||||
typedef size_t time_t;
|
||||
time_t time(time_t *timer);
|
||||
void srand(unsigned int seed);
|
||||
|
||||
typedef struct {} FILE;
|
||||
extern FILE *stdin;
|
||||
@@ -130,35 +129,3 @@ static void goodG2B2()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void good()
|
||||
{
|
||||
goodG2B1();
|
||||
goodG2B2();
|
||||
}
|
||||
|
||||
} /* close namespace */
|
||||
|
||||
/* Below is the main(). It is only used when building this testcase on
|
||||
its own for testing or for building a binary to use in testing binary
|
||||
analysis tools. It is not used when compiling all the testcases as one
|
||||
application, which is how source code analysis tools are tested. */
|
||||
|
||||
using namespace CWE23_Relative_Path_Traversal__char_console_fopen_11; /* so that we can use good and bad easily */
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
/* seed randomness */
|
||||
srand( (unsigned)time(NULL) );
|
||||
#ifndef OMITGOOD
|
||||
printLine("Calling good()...");
|
||||
good();
|
||||
printLine("Finished good()");
|
||||
#endif /* OMITGOOD */
|
||||
#ifndef OMITBAD
|
||||
printLine("Calling bad()...");
|
||||
bad();
|
||||
printLine("Finished bad()");
|
||||
#endif /* OMITBAD */
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -12,12 +12,9 @@ size_t strlen(const char *s);
|
||||
char *fgets(char *s, int n, FILE *stream);
|
||||
int fprintf(FILE *stream, const char *format, ...);
|
||||
char *strcpy(char *s1, const char *s2);
|
||||
void srand(unsigned int seed);
|
||||
|
||||
void printLine(char *);
|
||||
|
||||
#ifndef OMITBAD
|
||||
|
||||
void CWE134_Uncontrolled_Format_String__char_console_fprintf_01_bad()
|
||||
{
|
||||
char * data;
|
||||
@@ -52,10 +49,6 @@ void CWE134_Uncontrolled_Format_String__char_console_fprintf_01_bad()
|
||||
fprintf(stdout, data);
|
||||
}
|
||||
|
||||
#endif /* OMITBAD */
|
||||
|
||||
#ifndef OMITGOOD
|
||||
|
||||
/* goodG2B uses the GoodSource with the BadSink */
|
||||
static void goodG2B()
|
||||
{
|
||||
@@ -102,37 +95,3 @@ static void goodB2G()
|
||||
/* FIX: Specify the format disallowing a format string vulnerability */
|
||||
fprintf(stdout, "%s\n", data);
|
||||
}
|
||||
|
||||
void CWE134_Uncontrolled_Format_String__char_console_fprintf_01_good()
|
||||
{
|
||||
goodG2B();
|
||||
goodB2G();
|
||||
}
|
||||
|
||||
#endif /* OMITGOOD */
|
||||
|
||||
/* Below is the main(). It is only used when building this testcase on
|
||||
its own for testing or for building a binary to use in testing binary
|
||||
analysis tools. It is not used when compiling all the testcases as one
|
||||
application, which is how source code analysis tools are tested. */
|
||||
|
||||
#ifdef INCLUDEMAIN
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
/* seed randomness */
|
||||
srand( (unsigned)time(NULL) );
|
||||
#ifndef OMITGOOD
|
||||
printLine("Calling good()...");
|
||||
CWE134_Uncontrolled_Format_String__char_console_fprintf_01_good();
|
||||
printLine("Finished good()");
|
||||
#endif /* OMITGOOD */
|
||||
#ifndef OMITBAD
|
||||
printLine("Calling bad()...");
|
||||
CWE134_Uncontrolled_Format_String__char_console_fprintf_01_bad();
|
||||
printLine("Finished bad()");
|
||||
#endif /* OMITBAD */
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -7,20 +7,15 @@
|
||||
typedef struct {} FILE;
|
||||
typedef unsigned long size_t;
|
||||
extern FILE * stdout;
|
||||
void srand(unsigned int seed);
|
||||
size_t strlen(const char *s);
|
||||
char *getenv(const char *name);
|
||||
char *strcpy(char *s1, const char *s2);
|
||||
char *strncat(char *s1, const char *s2, size_t n);
|
||||
int fprintf(FILE *stream, const char *format, ...);
|
||||
|
||||
void printLine(char *);
|
||||
|
||||
#define ENV_VARIABLE "ADD"
|
||||
#define GETENV getenv
|
||||
|
||||
#ifndef OMITBAD
|
||||
|
||||
void CWE134_Uncontrolled_Format_String__char_environment_fprintf_01_bad()
|
||||
{
|
||||
char * data;
|
||||
@@ -41,10 +36,6 @@ void CWE134_Uncontrolled_Format_String__char_environment_fprintf_01_bad()
|
||||
fprintf(stdout, data);
|
||||
}
|
||||
|
||||
#endif /* OMITBAD */
|
||||
|
||||
#ifndef OMITGOOD
|
||||
|
||||
/* goodG2B uses the GoodSource with the BadSink */
|
||||
static void goodG2B()
|
||||
{
|
||||
@@ -77,37 +68,3 @@ static void goodB2G()
|
||||
/* FIX: Specify the format disallowing a format string vulnerability */
|
||||
fprintf(stdout, "%s\n", data);
|
||||
}
|
||||
|
||||
void CWE134_Uncontrolled_Format_String__char_environment_fprintf_01_good()
|
||||
{
|
||||
goodG2B();
|
||||
goodB2G();
|
||||
}
|
||||
|
||||
#endif /* OMITGOOD */
|
||||
|
||||
/* Below is the main(). It is only used when building this testcase on
|
||||
its own for testing or for building a binary to use in testing binary
|
||||
analysis tools. It is not used when compiling all the testcases as one
|
||||
application, which is how source code analysis tools are tested. */
|
||||
|
||||
#ifdef INCLUDEMAIN
|
||||
|
||||
int main(int argc, char * argv[])
|
||||
{
|
||||
/* seed randomness */
|
||||
srand( (unsigned)time(NULL) );
|
||||
#ifndef OMITGOOD
|
||||
printLine("Calling good()...");
|
||||
CWE134_Uncontrolled_Format_String__char_environment_fprintf_01_good();
|
||||
printLine("Finished good()");
|
||||
#endif /* OMITGOOD */
|
||||
#ifndef OMITBAD
|
||||
printLine("Calling bad()...");
|
||||
CWE134_Uncontrolled_Format_String__char_environment_fprintf_01_bad();
|
||||
printLine("Finished bad()");
|
||||
#endif /* OMITBAD */
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user