Dataset Viewer
Auto-converted to Parquet Duplicate
instance_id
stringlengths
25
91
cwe
stringclasses
118 values
type
stringclasses
118 values
line_number
int64
10
169
line_code
stringclasses
513 values
code
stringlengths
816
22.7k
bad
stringlengths
102
7.05k
good
stringlengths
0
14.7k
cwe680_integer_overflow_to_buffer_overflow__malloc_connect_socket_53d.c
CWE680
Integer Overflow to Buffer Overflow
56
intPointer[i] = 0; /* Potentially writes beyond the boundary of intPointer */
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_53d.c Label Definition File: CWE680_Integer_Overflow_to_Buffer_Overflow__malloc.label.xml Template File: sources-sink-53d.tmpl.c */ /* * @description * CWE: 680 Integer Overflow to Buffer Overflow * BadSou...
void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_53d_badSink(int data) { { size_t i; int *intPointer; /* POTENTIAL FLAW: if data * sizeof(int) > SIZE_MAX, overflows to a small value * so that the for loop doing the initialization causes a buffer overflow */ ...
void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_53d_goodG2BSink(int data) { { size_t i; int *intPointer; /* POTENTIAL FLAW: if data * sizeof(int) > SIZE_MAX, overflows to a small value * so that the for loop doing the initialization causes a buffer overflow */...
cwe190_integer_overflow__int64_t_fscanf_add_11.c
CWE190
Integer Overflow
36
int64_t result = data + 1;
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE190_Integer_Overflow__int64_t_fscanf_add_11.c Label Definition File: CWE190_Integer_Overflow.label.xml Template File: sources-sinks-11.tmpl.c */ /* * @description * CWE: 190 Integer Overflow * BadSource: fscanf Read data from the console using fscanf() * GoodSource: ...
void CWE190_Integer_Overflow__int64_t_fscanf_add_11_bad() { int64_t data; data = 0LL; if(globalReturnsTrue()) { /* POTENTIAL FLAW: Use a value input from the console */ fscanf (stdin, "%" SCNd64, &data); } if(globalReturnsTrue()) { { /* POTENTIAL FLAW: Add...
static void goodB2G1() { int64_t data; data = 0LL; if(globalReturnsTrue()) { /* POTENTIAL FLAW: Use a value input from the console */ fscanf (stdin, "%" SCNd64, &data); } if(globalReturnsFalse()) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ ...
cwe427_uncontrolled_search_path_element__wchar_t_connect_socket_74b.cpp
CWE427
Uncontrolled Search Path Element
41
PUTENV(data);
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE427_Uncontrolled_Search_Path_Element__wchar_t_connect_socket_74b.cpp Label Definition File: CWE427_Uncontrolled_Search_Path_Element.label.xml Template File: sources-sink-74b.tmpl.cpp */ /* * @description * CWE: 427 Uncontrolled Search Path Element * BadSource: connect...
void badSink(map<int, wchar_t *> dataMap) { /* copy data out of dataMap */ wchar_t * data = dataMap[2]; /* POTENTIAL FLAW: Set a new environment variable with a path that is possibly insecure */ PUTENV(data); }
void goodG2BSink(map<int, wchar_t *> dataMap) { wchar_t * data = dataMap[2]; /* POTENTIAL FLAW: Set a new environment variable with a path that is possibly insecure */ PUTENV(data); }
cwe127_buffer_underread__new_wchar_t_cpy_17.cpp
CWE127
Buffer Underread
46
wcscpy(dest, data);
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE127_Buffer_Underread__new_wchar_t_cpy_17.cpp Label Definition File: CWE127_Buffer_Underread__new.label.xml Template File: sources-sink-17.tmpl.cpp */ /* * @description * CWE: 127 Buffer Under-read * BadSource: Set data pointer to before the allocated memory buffer *...
void bad() { int i; wchar_t * data; data = NULL; for(i = 0; i < 1; i++) { { wchar_t * dataBuffer = new wchar_t[100]; wmemset(dataBuffer, L'A', 100-1); dataBuffer[100-1] = L'\0'; /* FLAW: Set data pointer to before the allocated memory buffer */...
static void goodG2B() { int h; wchar_t * data; data = NULL; for(h = 0; h < 1; h++) { { wchar_t * dataBuffer = new wchar_t[100]; wmemset(dataBuffer, L'A', 100-1); dataBuffer[100-1] = L'\0'; /* FIX: Set data pointer to the allocated memory buffer...
cwe121_stack_based_buffer_overflow__cwe805_struct_alloca_memmove_15.c
CWE121
Stack Based Buffer Overflow
50
memmove(data, source, 100*sizeof(twoIntsStruct));
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE121_Stack_Based_Buffer_Overflow__CWE805_struct_alloca_memmove_15.c Label Definition File: CWE121_Stack_Based_Buffer_Overflow__CWE805.label.xml Template File: sources-sink-15.tmpl.c */ /* * @description * CWE: 121 Stack Based Buffer Overflow * BadSource: Set data poin...
void CWE121_Stack_Based_Buffer_Overflow__CWE805_struct_alloca_memmove_15_bad() { twoIntsStruct * data; twoIntsStruct * dataBadBuffer = (twoIntsStruct *)ALLOCA(50*sizeof(twoIntsStruct)); twoIntsStruct * dataGoodBuffer = (twoIntsStruct *)ALLOCA(100*sizeof(twoIntsStruct)); switch(6) { case 6: ...
static void goodG2B1() { twoIntsStruct * data; twoIntsStruct * dataBadBuffer = (twoIntsStruct *)ALLOCA(50*sizeof(twoIntsStruct)); twoIntsStruct * dataGoodBuffer = (twoIntsStruct *)ALLOCA(100*sizeof(twoIntsStruct)); switch(5) { case 6: /* INCIDENTAL: CWE 561 Dead Code, the code below will...
cwe78_os_command_injection__wchar_t_file_execl_83_bad.cpp
CWE78
OS Command Injection
66
EXECL(COMMAND_INT_PATH, COMMAND_INT_PATH, COMMAND_ARG1, COMMAND_ARG3, NULL);
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE78_OS_Command_Injection__wchar_t_file_execl_83_bad.cpp Label Definition File: CWE78_OS_Command_Injection.strings.label.xml Template File: sources-sink-83_bad.tmpl.cpp */ /* * @description * CWE: 78 OS Command Injection * BadSource: file Read input from a file * GoodS...
namespace CWE78_OS_Command_Injection__wchar_t_file_execl_83 { CWE78_OS_Command_Injection__wchar_t_file_execl_83_bad::CWE78_OS_Command_Injection__wchar_t_file_execl_83_bad(wchar_t * dataCopy) { data = dataCopy; { /* Read input from a file */ size_t dataLen = wcslen(data); FILE * pFile; ...
cwe401_memory_leak__new_array_int_04.cpp
CWE401
Memory Leak
49
/* POTENTIAL FLAW: No deallocation */
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE401_Memory_Leak__new_array_int_04.cpp Label Definition File: CWE401_Memory_Leak__new_array.label.xml Template File: sources-sinks-04.tmpl.cpp */ /* * @description * CWE: 401 Memory Leak * BadSource: Allocate data using new[] * GoodSource: Point data to a stack buffe...
void bad() { int * data; data = NULL; if(STATIC_CONST_TRUE) { /* POTENTIAL FLAW: Allocate memory on the heap */ data = new int[100]; /* Initialize and make use of data */ data[0] = 5; printIntLine(data[0]); } if(STATIC_CONST_TRUE) { /* POTENTIA...
static void goodB2G1() { int * data; data = NULL; if(STATIC_CONST_TRUE) { /* POTENTIAL FLAW: Allocate memory on the heap */ data = new int[100]; /* Initialize and make use of data */ data[0] = 5; printIntLine(data[0]); } if(STATIC_CONST_FALSE) { ...
cwe121_stack_based_buffer_overflow__cwe806_wchar_t_alloca_memcpy_54e.c
CWE121
Stack Based Buffer Overflow
30
memcpy(dest, data, wcslen(data)*sizeof(wchar_t));
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_alloca_memcpy_54e.c Label Definition File: CWE121_Stack_Based_Buffer_Overflow__CWE806.label.xml Template File: sources-sink-54e.tmpl.c */ /* * @description * CWE: 121 Stack Based Buffer Overflow * BadSource: Initialize ...
void CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_alloca_memcpy_54e_badSink(wchar_t * data) { { wchar_t dest[50] = L""; /* POTENTIAL FLAW: Possible buffer overflow if data is larger than dest */ memcpy(dest, data, wcslen(data)*sizeof(wchar_t)); dest[50-1] = L'\0'; /* Ensure the...
void CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_alloca_memcpy_54e_goodG2BSink(wchar_t * data) { { wchar_t dest[50] = L""; /* POTENTIAL FLAW: Possible buffer overflow if data is larger than dest */ memcpy(dest, data, wcslen(data)*sizeof(wchar_t)); dest[50-1] = L'\0'; /* Ensure...
cwe90_ldap_injection__w32_char_file_15.c
CWE90
LDAP Injection
87
searchSuccess = ldap_search_ext_sA(
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE90_LDAP_Injection__w32_char_file_15.c Label Definition File: CWE90_LDAP_Injection__w32.label.xml Template File: sources-sink-15.tmpl.c */ /* * @description * CWE: 90 LDAP Injection * BadSource: file Read input from a file * GoodSource: Use a fixed string * Sink: * ...
void CWE90_LDAP_Injection__w32_char_file_15_bad() { char * data; char dataBuffer[256] = ""; data = dataBuffer; switch(6) { case 6: { /* Read input from a file */ size_t dataLen = strlen(data); FILE * pFile; /* if there is room in data, attempt to read the inpu...
static void goodG2B1() { char * data; char dataBuffer[256] = ""; data = dataBuffer; switch(5) { case 6: /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed string"); break; default: /* FIX: Use a fixed file name */ ...
cwe457_use_of_uninitialized_variable__double_array_malloc_partial_init_62a.cpp
CWE457
Use of Uninitialized Variable
39
printDoubleLine(data[i]);
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE457_Use_of_Uninitialized_Variable__double_array_malloc_partial_init_62a.cpp Label Definition File: CWE457_Use_of_Uninitialized_Variable.c_array.label.xml Template File: sources-sinks-62a.tmpl.cpp */ /* * @description * CWE: 457 Use of Uninitialized Variable * BadSourc...
void bad() { double * data; data = (double *)malloc(10*sizeof(double)); if (data == NULL) {exit(-1);} badSource(data); /* POTENTIAL FLAW: Use data without initializing it */ { int i; for(i=0; i<10; i++) { printDoubleLine(data[i]); } } }
static void goodG2B() { double * data; data = (double *)malloc(10*sizeof(double)); if (data == NULL) {exit(-1);} goodG2BSource(data); /* POTENTIAL FLAW: Use data without initializing it */ { int i; for(i=0; i<10; i++) { printDoubleLine(data[i]); } ...
cwe78_os_command_injection__wchar_t_connect_socket_execlp_03.c
CWE78
OS Command Injection
143
EXECLP(COMMAND_INT, COMMAND_INT, COMMAND_ARG1, COMMAND_ARG3, NULL);
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE78_OS_Command_Injection__wchar_t_connect_socket_execlp_03.c Label Definition File: CWE78_OS_Command_Injection.strings.label.xml Template File: sources-sink-03.tmpl.c */ /* * @description * CWE: 78 OS Command Injection * BadSource: connect_socket Read data using a conn...
void CWE78_OS_Command_Injection__wchar_t_connect_socket_execlp_03_bad() { wchar_t * data; wchar_t dataBuffer[100] = COMMAND_ARG2; data = dataBuffer; if(5==5) { { #ifdef _WIN32 WSADATA wsaData; int wsaDataInit = 0; #endif int recvResult; struct ...
static void goodG2B1() { wchar_t * data; wchar_t dataBuffer[100] = COMMAND_ARG2; data = dataBuffer; if(5!=5) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed string"); } else { /* FIX: Append a fixed string to data (not...
cwe563_unused_variable__unused_uninit_variable_char_21.c
CWE563
Unused Variable
31
/* do nothing */
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE563_Unused_Variable__unused_uninit_variable_char_21.c Label Definition File: CWE563_Unused_Variable__unused_uninit_variable.label.xml Template File: source-sinks-21.tmpl.c */ /* * @description * CWE: 563 Unused Variable * BadSource: Initialize data * Sinks: * Go...
static void badSink(char data) { if(badStatic) { /* FLAW: Do not use the variable */ /* do nothing */ ; /* empty statement needed for some flow variants */ } } void CWE563_Unused_Variable__unused_uninit_variable_char_21_bad() { char data; /* POTENTIAL FLAW: Do not initialize...
static void goodB2G1Sink(char data) { if(goodB2G1Static) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed string"); } else { /* FIX: Initialize then use data */ data = 'C'; printHexCharLine(data); } } static vo...
cwe191_integer_underflow__int64_t_min_sub_51b.c
CWE191
Integer Underflow
26
int64_t result = data - 1;
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE191_Integer_Underflow__int64_t_min_sub_51b.c Label Definition File: CWE191_Integer_Underflow.label.xml Template File: sources-sinks-51b.tmpl.c */ /* * @description * CWE: 191 Integer Underflow * BadSource: min Set data to the min value for int64_t * GoodSource: Set d...
void CWE191_Integer_Underflow__int64_t_min_sub_51b_badSink(int64_t data) { { /* POTENTIAL FLAW: Subtracting 1 from data could cause an underflow */ int64_t result = data - 1; printLongLongLine(result); } }
void CWE191_Integer_Underflow__int64_t_min_sub_51b_goodG2BSink(int64_t data) { { /* POTENTIAL FLAW: Subtracting 1 from data could cause an underflow */ int64_t result = data - 1; printLongLongLine(result); } } void CWE191_Integer_Underflow__int64_t_min_sub_51b_goodB2GSink(int64_t data) ...
cwe427_uncontrolled_search_path_element__char_listen_socket_62a.cpp
CWE427
Uncontrolled Search Path Element
43
PUTENV(data);
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE427_Uncontrolled_Search_Path_Element__char_listen_socket_62a.cpp Label Definition File: CWE427_Uncontrolled_Search_Path_Element.label.xml Template File: sources-sink-62a.tmpl.cpp */ /* * @description * CWE: 427 Uncontrolled Search Path Element * BadSource: listen_sock...
void bad() { char * data; char dataBuffer[250] = "PATH="; data = dataBuffer; badSource(data); /* POTENTIAL FLAW: Set a new environment variable with a path that is possibly insecure */ PUTENV(data); }
static void goodG2B() { char * data; char dataBuffer[250] = "PATH="; data = dataBuffer; goodG2BSource(data); /* POTENTIAL FLAW: Set a new environment variable with a path that is possibly insecure */ PUTENV(data); } void good() { goodG2B(); } int main(int argc, char * argv[]) { /* seed...
cwe775_missing_release_of_file_descriptor_or_handle__fopen_no_close_10.c
CWE775
Missing Release of File Descriptor or Handle
29
/* FLAW: No attempt to close the file */
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE775_Missing_Release_of_File_Descriptor_or_Handle__fopen_no_close_10.c Label Definition File: CWE775_Missing_Release_of_File_Descriptor_or_Handle__fopen_no_close.label.xml Template File: source-sinks-10.tmpl.c */ /* * @description * CWE: 775 Missing Release of File Desc...
void CWE775_Missing_Release_of_File_Descriptor_or_Handle__fopen_no_close_10_bad() { FILE * data; data = NULL; /* POTENTIAL FLAW: Open a file without closing it */ data = fopen("BadSource_fopen.txt", "w+"); if(globalTrue) { /* FLAW: No attempt to close the file */ ; /* empty state...
static void goodB2G1() { FILE * data; data = NULL; /* POTENTIAL FLAW: Open a file without closing it */ data = fopen("BadSource_fopen.txt", "w+"); if(globalFalse) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed string"); } els...
cwe124_buffer_underwrite__malloc_wchar_t_loop_53d.c
CWE124
Buffer Underwrite
35
data[i] = source[i];
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE124_Buffer_Underwrite__malloc_wchar_t_loop_53d.c Label Definition File: CWE124_Buffer_Underwrite__malloc.label.xml Template File: sources-sink-53d.tmpl.c */ /* * @description * CWE: 124 Buffer Underwrite * BadSource: Set data pointer to before the allocated memory bu...
void CWE124_Buffer_Underwrite__malloc_wchar_t_loop_53d_badSink(wchar_t * data) { { size_t i; wchar_t source[100]; wmemset(source, L'C', 100-1); /* fill with 'C's */ source[100-1] = L'\0'; /* null terminate */ /* POTENTIAL FLAW: Possibly copying data to memory before the desti...
void CWE124_Buffer_Underwrite__malloc_wchar_t_loop_53d_goodG2BSink(wchar_t * data) { { size_t i; wchar_t source[100]; wmemset(source, L'C', 100-1); /* fill with 'C's */ source[100-1] = L'\0'; /* null terminate */ /* POTENTIAL FLAW: Possibly copying data to memory before the d...
cwe78_os_command_injection__char_connect_socket_popen_84_bad.cpp
CWE78
OS Command Injection
130
pipe = POPEN(data, "w");
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE78_OS_Command_Injection__char_connect_socket_popen_84_bad.cpp Label Definition File: CWE78_OS_Command_Injection.one_string.label.xml Template File: sources-sink-84_bad.tmpl.cpp */ /* * @description * CWE: 78 OS Command Injection * BadSource: connect_socket Read data u...
namespace CWE78_OS_Command_Injection__char_connect_socket_popen_84 { CWE78_OS_Command_Injection__char_connect_socket_popen_84_bad::CWE78_OS_Command_Injection__char_connect_socket_popen_84_bad(char * dataCopy) { data = dataCopy; { #ifdef _WIN32 WSADATA wsaData; int wsaDataInit = 0; #endif ...
cwe90_ldap_injection__w32_wchar_t_console_73b.cpp
CWE90
LDAP Injection
56
searchSuccess = ldap_search_ext_sW(
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE90_LDAP_Injection__w32_wchar_t_console_73b.cpp Label Definition File: CWE90_LDAP_Injection__w32.label.xml Template File: sources-sink-73b.tmpl.cpp */ /* * @description * CWE: 90 LDAP Injection * BadSource: console Read input from the console * GoodSource: Use a fixed...
void badSink(list<wchar_t *> dataList) { /* copy data out of dataList */ wchar_t * data = dataList.back(); { LDAP* pLdapConnection = NULL; ULONG connectSuccess = 0L; ULONG searchSuccess = 0L; LDAPMessage *pMessage = NULL; wchar_t filter[256]; /* POTENTIAL FLAW...
void goodG2BSink(list<wchar_t *> dataList) { wchar_t * data = dataList.back(); { LDAP* pLdapConnection = NULL; ULONG connectSuccess = 0L; ULONG searchSuccess = 0L; LDAPMessage *pMessage = NULL; wchar_t filter[256]; /* POTENTIAL FLAW: data concatenated into LDAP se...
cwe762_mismatched_memory_management_routines__new_free_class_07.cpp
CWE762
Mismatched Memory Management Routines
44
free(data);
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE762_Mismatched_Memory_Management_Routines__new_free_class_07.cpp Label Definition File: CWE762_Mismatched_Memory_Management_Routines__new_free.label.xml Template File: sources-sinks-07.tmpl.cpp */ /* * @description * CWE: 762 Mismatched Memory Management Routines * Ba...
void bad() { TwoIntsClass * data; /* Initialize data*/ data = NULL; if(staticFive==5) { /* POTENTIAL FLAW: Allocate memory with a function that requires delete to free the memory */ data = new TwoIntsClass; } if(staticFive==5) { /* POTENTIAL FLAW: Deallocate memor...
static void goodB2G1() { TwoIntsClass * data; /* Initialize data*/ data = NULL; if(staticFive==5) { /* POTENTIAL FLAW: Allocate memory with a function that requires delete to free the memory */ data = new TwoIntsClass; } if(staticFive!=5) { /* INCIDENTAL: CWE 561 ...
cwe23_relative_path_traversal__char_connect_socket_ifstream_18.cpp
CWE23
Relative Path Traversal
132
inputFile.open((char *)data);
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE23_Relative_Path_Traversal__char_connect_socket_ifstream_18.cpp Label Definition File: CWE23_Relative_Path_Traversal.label.xml Template File: sources-sink-18.tmpl.cpp */ /* * @description * CWE: 23 Relative Path Traversal * BadSource: connect_socket Read data using a ...
void bad() { char * data; char dataBuffer[FILENAME_MAX] = BASEPATH; data = dataBuffer; goto source; source: { #ifdef _WIN32 WSADATA wsaData; int wsaDataInit = 0; #endif int recvResult; struct sockaddr_in service; char *replace; SOCKET connectSocket = I...
static void goodG2B() { char * data; char dataBuffer[FILENAME_MAX] = BASEPATH; data = dataBuffer; goto source; source: /* FIX: Use a fixed file name */ strcat(data, "file.txt"); { ifstream inputFile; /* POTENTIAL FLAW: Possibly opening a file without validating the file name ...
cwe78_os_command_injection__char_environment_w32_execvp_06.c
CWE78
OS Command Injection
77
EXECVP(COMMAND_INT, args);
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE78_OS_Command_Injection__char_environment_w32_execvp_06.c Label Definition File: CWE78_OS_Command_Injection.strings.label.xml Template File: sources-sink-06.tmpl.c */ /* * @description * CWE: 78 OS Command Injection * BadSource: environment Read input from an environm...
void CWE78_OS_Command_Injection__char_environment_w32_execvp_06_bad() { char * data; char dataBuffer[100] = COMMAND_ARG2; data = dataBuffer; if(STATIC_CONST_FIVE==5) { { /* Append input from an environment variable to data */ size_t dataLen = strlen(data); ...
static void goodG2B1() { char * data; char dataBuffer[100] = COMMAND_ARG2; data = dataBuffer; if(STATIC_CONST_FIVE!=5) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed string"); } else { /* FIX: Append a fixed string to...
cwe190_integer_overflow__char_max_add_53d.c
CWE190
Integer Overflow
26
char result = data + 1;
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE190_Integer_Overflow__char_max_add_53d.c Label Definition File: CWE190_Integer_Overflow.label.xml Template File: sources-sinks-53d.tmpl.c */ /* * @description * CWE: 190 Integer Overflow * BadSource: max Set data to the max value for char * GoodSource: Set data to a ...
void CWE190_Integer_Overflow__char_max_add_53d_badSink(char data) { { /* POTENTIAL FLAW: Adding 1 to data could cause an overflow */ char result = data + 1; printHexCharLine(result); } }
void CWE190_Integer_Overflow__char_max_add_53d_goodG2BSink(char data) { { /* POTENTIAL FLAW: Adding 1 to data could cause an overflow */ char result = data + 1; printHexCharLine(result); } } void CWE190_Integer_Overflow__char_max_add_53d_goodB2GSink(char data) { /* FIX: Add a check ...
cwe762_mismatched_memory_management_routines__new_delete_array_class_44.cpp
CWE762
Mismatched Memory Management Routines
29
delete [] data;
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE762_Mismatched_Memory_Management_Routines__new_delete_array_class_44.cpp Label Definition File: CWE762_Mismatched_Memory_Management_Routines__new_delete_array.label.xml Template File: sources-sinks-44.tmpl.cpp */ /* * @description * CWE: 762 Mismatched Memory Managemen...
static void badSink(TwoIntsClass * data) { /* POTENTIAL FLAW: Deallocate memory using delete [] - the source memory allocation function may * require a call to delete to deallocate the memory */ delete [] data; } void bad() { TwoIntsClass * data; /* define a function pointer */ void (*funcPtr)...
static void goodG2BSink(TwoIntsClass * data) { /* POTENTIAL FLAW: Deallocate memory using delete [] - the source memory allocation function may * require a call to delete to deallocate the memory */ delete [] data; } static void goodG2B() { TwoIntsClass * data; void (*funcPtr) (TwoIntsClass *) = g...
cwe195_signed_to_unsigned_conversion_error__fscanf_memcpy_73b.cpp
CWE195
Signed to Unsigned Conversion Error
40
memcpy(dest, source, data);
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_73b.cpp Label Definition File: CWE195_Signed_to_Unsigned_Conversion_Error.label.xml Template File: sources-sink-73b.tmpl.cpp */ /* * @description * CWE: 195 Signed to Unsigned Conversion Error * BadSource: fscanf ...
void badSink(list<int> dataList) { /* copy data out of dataList */ int data = dataList.back(); { char source[100]; char dest[100] = ""; memset(source, 'A', 100-1); source[100-1] = '\0'; if (data < 100) { /* POTENTIAL FLAW: data is interpreted as an...
void goodG2BSink(list<int> dataList) { int data = dataList.back(); { char source[100]; char dest[100] = ""; memset(source, 'A', 100-1); source[100-1] = '\0'; if (data < 100) { /* POTENTIAL FLAW: data is interpreted as an unsigned int - if its value is ...
cwe190_integer_overflow__char_max_postinc_14.c
CWE190
Integer Overflow
35
data++;
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE190_Integer_Overflow__char_max_postinc_14.c Label Definition File: CWE190_Integer_Overflow.label.xml Template File: sources-sinks-14.tmpl.c */ /* * @description * CWE: 190 Integer Overflow * BadSource: max Set data to the max value for char * GoodSource: Set data to ...
void CWE190_Integer_Overflow__char_max_postinc_14_bad() { char data; data = ' '; if(globalFive==5) { /* POTENTIAL FLAW: Use the maximum size of the data type */ data = CHAR_MAX; } if(globalFive==5) { { /* POTENTIAL FLAW: Incrementing data could cause an ov...
static void goodB2G1() { char data; data = ' '; if(globalFive==5) { /* POTENTIAL FLAW: Use the maximum size of the data type */ data = CHAR_MAX; } if(globalFive!=5) { /* INCIDENTAL: CWE 561 Dead Code, the code below will never run */ printLine("Benign, fixed s...
cwe762_mismatched_memory_management_routines__delete_array_int_realloc_62a.cpp
CWE762
Mismatched Memory Management Routines
36
delete [] data;
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE762_Mismatched_Memory_Management_Routines__delete_array_int_realloc_62a.cpp Label Definition File: CWE762_Mismatched_Memory_Management_Routines__delete_array.label.xml Template File: sources-sinks-62a.tmpl.cpp */ /* * @description * CWE: 762 Mismatched Memory Managemen...
void bad() { int * data; /* Initialize data*/ data = NULL; badSource(data); /* POTENTIAL FLAW: Deallocate memory using delete [] - the source memory allocation function may * require a call to free() to deallocate the memory */ delete [] data; }
static void goodG2B() { int * data; /* Initialize data*/ data = NULL; goodG2BSource(data); /* POTENTIAL FLAW: Deallocate memory using delete [] - the source memory allocation function may * require a call to free() to deallocate the memory */ delete [] data; } static void goodB2G() { i...
cwe122_heap_based_buffer_overflow__c_cwe129_connect_socket_63b.c
CWE122
Heap Based Buffer Overflow
60
buffer[data] = 1;
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE122_Heap_Based_Buffer_Overflow__c_CWE129_connect_socket_63b.c Label Definition File: CWE122_Heap_Based_Buffer_Overflow__c_CWE129.label.xml Template File: sources-sinks-63b.tmpl.c */ /* * @description * CWE: 122 Heap Based Buffer Overflow * BadSource: connect_socket Re...
void CWE122_Heap_Based_Buffer_Overflow__c_CWE129_connect_socket_63b_badSink(int * dataPtr) { int data = *dataPtr; { int i; int * buffer = (int *)malloc(10 * sizeof(int)); if (buffer == NULL) {exit(-1);} /* initialize buffer */ for (i = 0; i < 10; i++) { ...
void CWE122_Heap_Based_Buffer_Overflow__c_CWE129_connect_socket_63b_goodG2BSink(int * dataPtr) { int data = *dataPtr; { int i; int * buffer = (int *)malloc(10 * sizeof(int)); if (buffer == NULL) {exit(-1);} /* initialize buffer */ for (i = 0; i < 10; i++) { ...
cwe78_os_command_injection__wchar_t_file_w32_spawnv_73b.cpp
CWE78
OS Command Injection
54
_wspawnv(_P_WAIT, COMMAND_INT_PATH, args);
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE78_OS_Command_Injection__wchar_t_file_w32_spawnv_73b.cpp Label Definition File: CWE78_OS_Command_Injection.strings.label.xml Template File: sources-sink-73b.tmpl.cpp */ /* * @description * CWE: 78 OS Command Injection * BadSource: file Read input from a file * GoodSo...
void badSink(list<wchar_t *> dataList) { /* copy data out of dataList */ wchar_t * data = dataList.back(); { wchar_t *args[] = {COMMAND_INT_PATH, COMMAND_ARG1, COMMAND_ARG3, NULL}; /* wspawnv - specify the path where the command is located */ /* POTENTIAL FLAW: Execute command withou...
void goodG2BSink(list<wchar_t *> dataList) { wchar_t * data = dataList.back(); { wchar_t *args[] = {COMMAND_INT_PATH, COMMAND_ARG1, COMMAND_ARG3, NULL}; /* wspawnv - specify the path where the command is located */ /* POTENTIAL FLAW: Execute command without validating input possibly lead...
cwe369_divide_by_zero__int_rand_divide_66b.c
CWE369
Divide by Zero
27
printIntLine(100 / data);
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE369_Divide_by_Zero__int_rand_divide_66b.c Label Definition File: CWE369_Divide_by_Zero__int.label.xml Template File: sources-sinks-66b.tmpl.c */ /* * @description * CWE: 369 Divide by Zero * BadSource: rand Set data to result of rand(), which may be zero * GoodSource...
void CWE369_Divide_by_Zero__int_rand_divide_66b_badSink(int dataArray[]) { /* copy data out of dataArray */ int data = dataArray[2]; /* POTENTIAL FLAW: Possibly divide by zero */ printIntLine(100 / data); }
void CWE369_Divide_by_Zero__int_rand_divide_66b_goodG2BSink(int dataArray[]) { int data = dataArray[2]; /* POTENTIAL FLAW: Possibly divide by zero */ printIntLine(100 / data); } void CWE369_Divide_by_Zero__int_rand_divide_66b_goodB2GSink(int dataArray[]) { int data = dataArray[2]; /* FIX: test for ...
cwe121_stack_based_buffer_overflow__cwe806_char_declare_snprintf_68b.c
CWE121
Stack Based Buffer Overflow
40
SNPRINTF(dest, strlen(data), "%s", data);
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_snprintf_68b.c Label Definition File: CWE121_Stack_Based_Buffer_Overflow__CWE806.label.xml Template File: sources-sink-68b.tmpl.c */ /* * @description * CWE: 121 Stack Based Buffer Overflow * BadSource: Initialize ...
void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_snprintf_68b_badSink() { char * data = CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_snprintf_68_badData; { char dest[50] = ""; /* POTENTIAL FLAW: Possible buffer overflow if data is larger than dest */ SNPRINTF(dest,...
void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_snprintf_68b_goodG2BSink() { char * data = CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_snprintf_68_goodG2BData; { char dest[50] = ""; /* POTENTIAL FLAW: Possible buffer overflow if data is larger than dest */ SNPRIN...
cwe191_integer_underflow__unsigned_int_rand_predec_01.c
CWE191
Integer Underflow
30
--data;
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE191_Integer_Underflow__unsigned_int_rand_predec_01.c Label Definition File: CWE191_Integer_Underflow.label.xml Template File: sources-sinks-01.tmpl.c */ /* * @description * CWE: 191 Integer Underflow * BadSource: rand Set data to result of rand() * GoodSource: Set da...
void CWE191_Integer_Underflow__unsigned_int_rand_predec_01_bad() { unsigned int data; data = 0; /* POTENTIAL FLAW: Use a random value */ data = (unsigned int)RAND32(); { /* POTENTIAL FLAW: Decrementing data could cause an underflow */ --data; unsigned int result = data; ...
static void goodG2B() { unsigned int data; data = 0; /* FIX: Use a small, non-zero value that will not cause an underflow in the sinks */ data = -2; { /* POTENTIAL FLAW: Decrementing data could cause an underflow */ --data; unsigned int result = data; printUnsignedLin...
cwe590_free_memory_not_on_heap__delete_array_class_static_18.cpp
CWE590
Free Memory Not on Heap
47
delete [] data;
/* TEMPLATE GENERATED TESTCASE FILE Filename: CWE590_Free_Memory_Not_on_Heap__delete_array_class_static_18.cpp Label Definition File: CWE590_Free_Memory_Not_on_Heap__delete_array.label.xml Template File: sources-sink-18.tmpl.cpp */ /* * @description * CWE: 590 Free Memory Not on Heap * BadSource: static Data buffer ...
void bad() { TwoIntsClass * data; data = NULL; /* Initialize data */ goto source; source: { /* FLAW: data is allocated on the stack and deallocated in the BadSink */ static TwoIntsClass dataBuffer[100]; { size_t i; for (i = 0; i < 100; i++) { ...
static void goodG2B() { TwoIntsClass * data; data = NULL; /* Initialize data */ goto source; source: { /* FIX: data is allocated on the heap and deallocated in the BadSink */ TwoIntsClass * dataBuffer = new TwoIntsClass[100]; { size_t i; for (i = 0; i < 10...
End of preview. Expand in Data Studio
README.md exists but content is empty.
Downloads last month
34