func
stringlengths 181
23.6k
| path
stringlengths 12
123
| source
stringclasses 2
values | label
int64 0
40
|
---|---|---|---|
void av_pkt_dump2(FILE *f,AVPacket *pkt,int dump_payload,AVStream *st) pkt_dump_internal ( ( ( void * ) 0 ) , f , 0 , pkt , dump_payload , st -> time_base ); static void pkt_dump_internal(void *avcl,FILE *f,int level,AVPacket *pkt,int dump_payload,AVRational time_base) if ( pkt -> pts == ( ( int64_t ) 0x8000000000000000UL ) ) if ( ! f ) fprintf ( f , "%0.3f" , ( pkt -> pts ) * av_q2d ( time_base ) ); while ( 0 ) if ( ! f ) fprintf ( f , "\n" ); if ( ! f ) fprintf ( f , " size=%d\n" , pkt -> size ); av_hex_dump ( f , ( pkt -> data ) , pkt -> size ); | 152151/utils.c | SARD | 0 |
static void goodG2BSink() wchar_t * data = goodG2BData ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcsncat ( data , source , 100 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) delete [ ] data | 69180/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_wchar_t_ncat_45.cpp | SARD | 0 |
static void goodB2G() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; count = atoi ( inputBuffer ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); countList . push_back ( count ); countList . push_back ( count ); countList . push_back ( count ); | 99051/CWE400_Resource_Exhaustion__listen_socket_sleep_73a.cpp | SARD | 0 |
void ERR_load_BIO_strings() long periesophageal_sickless [ 10 ] ; nashville_uncounselled rhodanic_wadmaker [ 10 ] = { 0 } ; char * duotriode_unreprovedly ; if ( __sync_bool_compare_and_swap ( & framings_laboratories , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( duotriode_unreprovedly != 0 ) semiexternally_lymphomatous = duotriode_unreprovedly; rhodanic_wadmaker [ 5 ] = semiexternally_lymphomatous; periesophageal_sickless [ 1 ] = 5; nonideal_tediosity = * ( rhodanic_wadmaker + periesophageal_sickless [ 1 ] ); arne_woodman ( nonideal_tediosity ); void arne_woodman(nashville_uncounselled agglomerative_pursuers) detailist_clyman ( agglomerative_pursuers ); void detailist_clyman(nashville_uncounselled necessariness_stamboul) grx_amphiploid = ( ( char * ) necessariness_stamboul ); stonesoup_input_len = strlen ( grx_amphiploid ); if ( stonesoup_input_len < 2 ) stonesoup_function_ptr = malloc ( sizeof ( void * ) ); if ( stonesoup_function_ptr == 0 ) stonesoup_get_function ( stonesoup_input_len , stonesoup_function_ptr ); void stonesoup_get_function(int len, fptr * modulus_function) if ( len > 10 ) * modulus_function = stonesoup_modulus_function1; if ( len < 10 ) * modulus_function = stonesoup_modulus_function2; stonesoup_result = ( * stonesoup_function_ptr ) ( grx_amphiploid ); if ( stonesoup_result == 0 ) if ( stonesoup_function_ptr != 0 ) free ( stonesoup_function_ptr ); | 152995/bio_err.c | SARD | 3 |
static void goodB2G1() size_t data ; data = 0; if ( GLOBAL_CONST_TRUE ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( GLOBAL_CONST_FALSE ) if ( data > strlen ( HELLO_STRING ) && data < 100 ) | 116991/CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_09.c | SARD | 0 |
static pvscsi_reset(DeviceState *dev) PCIDevice * d = PCI_DEVICE ( dev ) ; PVSCSIState * s = PVSCSI ( d ) ; pvscsi_reset_adapter ( s ); static pvscsi_reset_adapter(PVSCSIState *s) s -> resetting ++; s -> resetting --; pvscsi_reset_state ( s ); static pvscsi_reset_state(PVSCSIState *s) s -> curr_cmd = PVSCSI_CMD_FIRST; s -> curr_cmd_data_cntr = 0; s -> reg_command_status = PVSCSI_COMMAND_PROCESSING_SUCCEEDED; s -> reg_interrupt_status = 0; pvscsi_ring_cleanup ( & s -> rings ); static pvscsi_ring_cleanup(PVSCSIRingInfo *mgr) mgr -> rs_pa = 0; mgr -> txr_len_mask = 0; mgr -> rxr_len_mask = 0; mgr -> msg_len_mask = 0; mgr -> consumed_ptr = 0; mgr -> filled_cmp_ptr = 0; mgr -> filled_msg_ptr = 0; memset ( mgr -> req_ring_pages_pa , 0 , sizeof ( mgr -> req_ring_pages_pa ) ); memset ( mgr -> cmp_ring_pages_pa , 0 , sizeof ( mgr -> cmp_ring_pages_pa ) ); memset ( mgr -> msg_ring_pages_pa , 0 , sizeof ( mgr -> msg_ring_pages_pa ) ); | CVE-2016-4952/qemu_2.3.0_CVE-2016-4952_vmw_pvscsi.c | NVD | 0 |
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; size_t dataLen = wcslen ( data ) ; wcsncat ( data + dataLen , environment , FILENAME_MAX - dataLen - 1 ); fileDesc = OPEN ( data , O_RDWR | O_CREAT , S_IREAD | S_IWRITE ); if ( fileDesc != - 1 ) CLOSE ( fileDesc ); | 91414/CWE23_Relative_Path_Traversal__wchar_t_environment_open_11.cpp | SARD | 4 |
void CWE134_Uncontrolled_Format_String__char_listen_socket_w32_vsnprintf_16_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; while ( 1 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 80505/CWE134_Uncontrolled_Format_String__char_listen_socket_w32_vsnprintf_16.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_file_vprintf_12_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 80165/CWE134_Uncontrolled_Format_String__char_file_vprintf_12.c | SARD | 0 |
void sig_handler (int sig) if ( stonesoupData != NULL ) delNonAlpha ( stonesoupData ); void delNonAlpha (void *data) struct stonesoup_data * stonesoupData = ( struct stonesoup_data * ) data ; int i = 0 ; int j = 0 ; char * temp = malloc ( sizeof ( char ) * ( stonesoupData -> data_size + 1 ) ) ; while ( stonesoupData -> data [ i ] != '\0' ) if ( ( stonesoupData -> data [ i ] >= 'A' && stonesoupData -> data [ i ] <= 'Z' ) || ( stonesoupData -> data [ i ] >= 'a' && stonesoupData -> data [ i ] <= 'z' ) ) temp [ j ++ ] = stonesoupData -> data [ i ]; i ++; temp [ j ++ ] = '\0'; stonesoupData -> data_size = j; stonesoupData -> data = temp; waitForSig ( stonesoupData -> file1 ); void waitForSig(char* sleepFile) int fd ; char outStr [ 25 ] = { 0 } ; char filename [ 500 ] = { 0 } ; sprintf ( outStr , "%d.pid" , getpid ( ) ); strcat ( filename , "/opt/stonesoup/workspace/testData/" ); strcat ( filename , outStr ); if ( ( fd = open ( filename , O_CREAT | O_WRONLY , 0666 ) ) == - 1 ) stonesoup_readFile ( sleepFile ); void stonesoup_readFile(char *filename) FILE * fifo ; char ch ; fifo = fopen ( filename , "r" ); if ( fifo != NULL ) while ( ( ch = fgetc ( fifo ) ) != EOF ) stonesoup_printf ( "%c" , ch ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); mg_vprintf_data ( ( struct mg_connection * ) stonesoup_printf_context , format , argptr ); | 150149/dfa.c | SARD | 0 |
void CWE194_Unexpected_Sign_Extension__fgets_memcpy_13_bad() if ( GLOBAL_CONST_FIVE == 5 ) char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = ( short ) atoi ( inputBuffer ); if ( data < 100 ) memcpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 86538/CWE194_Unexpected_Sign_Extension__fgets_memcpy_13.c | SARD | 20 |
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( 5 == 5 ) size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; | 79484/CWE134_Uncontrolled_Format_String__char_console_snprintf_03.c | SARD | 0 |
static void goodG2B2() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( staticFive == 5 ) wcscpy ( data , L "C:\\Windows\\System32\\winsrv.dll" ) HMODULE hModule ; hModule = LoadLibraryW ( data ); if ( hModule != NULL ) FreeLibrary ( hModule ); | 62330/CWE114_Process_Control__w32_wchar_t_environment_07.c | SARD | 0 |
static void good1() if ( 0 ) char * data = ( char * ) malloc ( 100 * sizeof ( char ) ) ; strcpy ( data , "A String" ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); tmpData = ( char * ) realloc ( data , ( 130000 ) * sizeof ( char ) ); if ( tmpData != NULL ) data = tmpData; strcpy ( data , "New String" ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 99635/CWE401_Memory_Leak__malloc_realloc_char_02.c | SARD | 0 |
void tolerableness_bilsted(int usecc_vociferative,struct gyratory_fritillaria junkerish_blastomycotic) gynarchies_koralie ( usecc_vociferative , junkerish_blastomycotic ); void gynarchies_koralie(int vinylate_misaligned,struct gyratory_fritillaria kolozsv_amentiferae) vinylate_misaligned --; if ( vinylate_misaligned > 0 ) tolerableness_bilsted ( vinylate_misaligned , kolozsv_amentiferae ); void tolerableness_bilsted(int usecc_vociferative,struct gyratory_fritillaria junkerish_blastomycotic) gynarchies_koralie ( usecc_vociferative , junkerish_blastomycotic ); void gynarchies_koralie(int vinylate_misaligned,struct gyratory_fritillaria kolozsv_amentiferae) vinylate_misaligned --; if ( vinylate_misaligned > 0 ) swaddle_bedad = ( ( char * ) kolozsv_amentiferae . leodicid_beausire ); if ( strlen ( swaddle_bedad ) >= 1 && swaddle_bedad [ 0 ] != '-' ) | 151424/eng_table.c | SARD | 0 |
void bad() char * data ; data = new char [ 100 ]; data = badSource ( data ); static char * badSource(char * data) if ( badStatic ) memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; return data ; size_t i , dataLen ; dataLen = strlen ( data ); for (i = 0; i < dataLen; i++) | 69314/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_char_loop_21.cpp | SARD | 0 |
static void goodB2G() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; data [ dataLen ] = '\0'; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; size_t i ; for (i=0; i < strlen(data); i++) if ( data [ i ] == SEARCH_CHAR ) | 112578/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_console_12.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_53_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; size_t dataLen = wcslen ( data ) ; wcsncat ( data + dataLen , environment , 100 - dataLen - 1 ); CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_53b_badSink ( data ); void CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_53b_badSink(wchar_t * data) CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_53c_badSink ( data ); void CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_53c_badSink(wchar_t * data) CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_53d_badSink ( data ); void CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_53d_badSink(wchar_t * data) badVaSink ( data , data ); static void badVaSink(wchar_t * data, ...) va_start ( args , data ); _vsnwprintf ( dest , 100 - 1 , data , args ); | 81385/CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_53a.c | SARD | 0 |
static void goodG2B2() wchar_t * data ; wchar_t * dataBuffer = ( wchar_t * ) ALLOCA ( 100 * sizeof ( wchar_t ) ) ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' if ( GLOBAL_CONST_TRUE ) data = dataBuffer; wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' wcsncpy ( dest , data , wcslen ( dest ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 78866/CWE127_Buffer_Underread__wchar_t_alloca_ncpy_09.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__wchar_t_environment_snprintf_63_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; size_t dataLen = wcslen ( data ) ; wchar_t * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) wcsncat ( data + dataLen , environment , 100 - dataLen - 1 ); CWE134_Uncontrolled_Format_String__wchar_t_environment_snprintf_63b_badSink ( & data ); void CWE134_Uncontrolled_Format_String__wchar_t_environment_snprintf_63b_badSink(wchar_t * * dataPtr) wchar_t * data = * dataPtr ; SNPRINTF ( dest , 100 - 1 , data ); | 81245/CWE134_Uncontrolled_Format_String__wchar_t_environment_snprintf_63a.c | SARD | 0 |
static void goodG2B1() char * data ; data = new char [ 100 ]; if ( staticFive != 5 ) memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; memcpy ( dest , data , strlen ( data ) * sizeof ( char ) ); dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] data | 69350/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_char_memcpy_07.cpp | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int_memmove_13_bad() int * data ; data = NULL; if ( GLOBAL_CONST_FIVE == 5 ) data = ( int * ) malloc ( 50 * sizeof ( int ) ); int source [ 100 ] = { 0 } ; memmove ( data , source , 100 * sizeof ( int ) ); printIntLine ( data [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( data ); | 71756/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int_memmove_13.c | SARD | 3 |
static void goodG2B2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; switch ( 6 ) strcpy ( data , "fixedstringtest" ); switch ( 7 ) goodG2B2VaSinkB ( data , data ); static void goodG2B2VaSinkB(char * data, ...) char dest [ 100 ] = "" ; va_list args ; vsnprintf ( dest , 100 - 1 , data , args ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 80504/CWE134_Uncontrolled_Format_String__char_listen_socket_w32_vsnprintf_15.c | SARD | 0 |
static void goodB2G2() if ( globalFive == 5 ) char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); if ( data > 0 ) if ( data < ( INT_MAX / 2 ) ) int result = data * 2 ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 83179/CWE190_Integer_Overflow__int_fgets_multiply_14.c | SARD | 0 |
void CWE114_Process_Control__w32_char_listen_socket_15_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; switch ( 6 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 62146/CWE114_Process_Control__w32_char_listen_socket_15.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_memmove_03_bad() wchar_t * data ; data = NULL; if ( 5 == 5 ) data = ( wchar_t * ) malloc ( 10 * sizeof ( wchar_t ) ); wchar_t source [ 10 + 1 ] = SRC_STRING ; memmove ( data , source , ( wcslen ( source ) + 1 ) * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 71122/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_memmove_03.c | SARD | 3 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_memmove_02_bad() char * data ; data = NULL; if ( 1 ) data = ( char * ) malloc ( 10 * sizeof ( char ) ); char source [ 10 + 1 ] = SRC_STRING ; memmove ( data , source , ( strlen ( source ) + 1 ) * sizeof ( char ) ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 70881/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_memmove_02.c | SARD | 3 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfamust ( d ); static void dfamust(struct dfa *d) must * musts ; must * mp ; size_t ri ; size_t i ; token t ; static must must0 ; musts = ( ( sizeof ( ( * musts ) ) == 1 ? xmalloc ( d -> tindex + 1 ) : xnmalloc ( d -> tindex + 1 , sizeof ( ( * musts ) ) ) ) ); while ( 0 ) mp = musts; for (i = 0; i <= d -> tindex; ++i) mp [ i ] = must0; for (i = 0; i <= d -> tindex; ++i) mp [ i ] . in = ( xmalloc ( sizeof ( ( * mp [ i ] . in ) ) ) ); mp [ i ] . left = ( xmalloc ( 2 ) ); mp [ i ] . right = ( xmalloc ( 2 ) ); mp [ i ] . is = ( xmalloc ( 2 ) ); mp [ i ] . left [ 0 ] = mp [ i ] . right [ 0 ] = mp [ i ] . is [ 0 ] = '\0'; mp [ i ] . in [ 0 ] = ( ( void * ) 0 ); for (ri = 0; ri < d -> tindex; ++ri) switch ( t = d -> tokens [ ri ] ) must * lmp ; must * rmp ; if ( ! ( strcmp ( ( lmp -> is ) , ( rmp -> is ) ) == 0 ) ) lmp -> is [ 0 ] = '\0'; while ( lmp -> left [ i ] != '\0' && lmp -> left [ i ] == rmp -> left [ i ] ) lmp -> left [ i ] = '\0'; ln = strlen ( ( lmp -> right ) ); n = ln; if ( n > rn ) for (i = 0; i < n; ++i) if ( lmp -> right [ ln - i - 1 ] != rmp -> right [ rn - i - 1 ] ) for (j = 0; j < i; ++j) lmp -> right [ j ] = lmp -> right [ ln - i + j ]; lmp -> right [ j ] = '\0'; new = inboth ( lmp -> in , rmp -> in if ( new == ( ( void * ) 0 ) ) static char **inboth(char **left,char **right) char * * both ; char * * temp ; size_t lnum ; size_t rnum ; if ( left == ( ( void * ) 0 ) || right == ( ( void * ) 0 ) ) return ( ( void * ) 0 ) ; both = ( malloc ( sizeof ( ( * both ) ) ) ); if ( both == ( ( void * ) 0 ) ) return ( ( void * ) 0 ) ; both [ 0 ] = ( ( void * ) 0 ); for (lnum = 0; left[lnum] != ((void *)0); ++lnum) for (rnum = 0; right[rnum] != ((void *)0); ++rnum) temp = comsubs ( left [ lnum ] , right [ rnum ] ); static char **comsubs(char *left,const char *right) char * * cpp ; char * lcp ; char * rcp ; size_t i ; size_t len ; if ( left == ( ( void * ) 0 ) || right == ( ( void * ) 0 ) ) return ( ( void * ) 0 ) ; cpp = ( malloc ( sizeof ( ( * cpp ) ) ) ); if ( cpp == ( ( void * ) 0 ) ) return ( ( void * ) 0 ) ; cpp [ 0 ] = ( ( void * ) 0 ); for (lcp = left; ( *lcp) != '\0'; ++lcp) len = 0; rcp = strchr ( right , ( * lcp ) ); while ( rcp != ( ( void * ) 0 ) ) if ( i > len ) len = i; rcp = strchr ( ( rcp + 1 ) , ( * lcp ) ); if ( len == 0 ) char * * p = enlist ( cpp , lcp , len ) ; if ( p == ( ( void * ) 0 ) ) cpp = ( ( void * ) 0 ); cpp = p; return cpp ; if ( temp == ( ( void * ) 0 ) ) return ( ( void * ) 0 ) ; both = addlists ( both , temp ); if ( both == ( ( void * ) 0 ) ) return ( ( void * ) 0 ) ; return both ; mp -> is [ 0 ] = '\0'; must * lmp ; must * rmp ; rmp = -- mp; lmp = -- mp; lmp -> in = addlists ( lmp -> in , rmp -> in ); if ( lmp -> in == ( ( void * ) 0 ) ) if ( lmp -> right [ 0 ] != '\0' && rmp -> left [ 0 ] != '\0' ) char * tp ; tp = icpyalloc ( ( lmp -> right ) ); static char *icpyalloc(const char *string) return icatalloc ( ( ( void * ) 0 ) , string ) ; tp = icatalloc ( tp , ( rmp -> left ) ); lmp -> in = enlist ( lmp -> in , tp , strlen ( tp ) ); free ( tp ); if ( lmp -> in == ( ( void * ) 0 ) ) if ( lmp -> is [ 0 ] != '\0' ) lmp -> left = icatalloc ( lmp -> left , ( rmp -> left ) ); if ( lmp -> left == ( ( void * ) 0 ) ) if ( rmp -> is [ 0 ] == '\0' ) lmp -> right [ 0 ] = '\0'; lmp -> right = icatalloc ( lmp -> right , ( rmp -> right ) ); if ( lmp -> right == ( ( void * ) 0 ) ) if ( lmp -> is [ 0 ] != '\0' && rmp -> is [ 0 ] != '\0' ) lmp -> is = icatalloc ( lmp -> is , ( rmp -> is ) ); if ( lmp -> is == ( ( void * ) 0 ) ) lmp -> is [ 0 ] = '\0'; if ( t < END ) if ( t == '\0' ) if ( t >= CSET || ! 1 || t == ANYCHAR || t == MBCSET ) mp -> is [ 0 ] = mp -> left [ 0 ] = mp -> right [ 0 ] = t; mp -> is [ 1 ] = mp -> left [ 1 ] = mp -> right [ 1 ] = '\0'; mp -> in = enlist ( mp -> in , mp -> is , ( ( size_t ) 1 ) ); if ( mp -> in == ( ( void * ) 0 ) ) freelist ( mp [ i ] . in ); static void freelist(char **cpp) if ( cpp == ( ( void * ) 0 ) ) for (i = 0; cpp[i] != ((void *)0); ++i) free ( cpp [ i ] ); cpp [ i ] = ( ( void * ) 0 ); free ( mp [ i ] . in ); free ( mp [ i ] . left ); free ( mp [ i ] . right ); free ( mp [ i ] . is ); | 153172/dfa.c | SARD | 0 |
void CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_declare_ncat_41_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] ; data = dataBuffer; wmemset ( data , L 'A' , 100 - 1 data [ 100 - 1 ] = L '\0' CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_declare_ncat_41_badSink ( data ); void CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_declare_ncat_41_badSink(wchar_t * data) wchar_t dest [ 50 ] = L "" wcsncat ( dest , data , wcslen ( data ) ); | 66544/CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_declare_ncat_41.c | SARD | 3 |
static void goodB2G2() char * data ; data = NULL; data = ( char * ) calloc ( 20 , sizeof ( char ) ); if ( globalFive == 5 ) if ( data != NULL ) strcpy ( data , "Initialize" ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 110991/CWE690_NULL_Deref_From_Return__char_calloc_14.c | SARD | 0 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfaanalyze ( d , searchflag ); void dfaanalyze(struct dfa *d,int searchflag) int * nullable ; size_t * nfirstpos ; position * firstpos ; size_t * nlastpos ; position * lastpos ; position_set merged ; position * o_firstpos ; position * o_lastpos ; size_t i ; size_t j ; position * pos ; d -> searchflag = searchflag; nullable = ( ( sizeof ( ( * nullable ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nullable ) ) ) ) ); while ( 0 ) nfirstpos = ( ( sizeof ( ( * nfirstpos ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nfirstpos ) ) ) ) ); while ( 0 ) firstpos = ( ( sizeof ( ( * firstpos ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * firstpos ) ) ) ) ); while ( 0 ) o_firstpos = firstpos , firstpos += d -> nleaves; nlastpos = ( ( sizeof ( ( * nlastpos ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nlastpos ) ) ) ) ); while ( 0 ) lastpos = ( ( sizeof ( ( * lastpos ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * lastpos ) ) ) ) ); while ( 0 ) o_lastpos = lastpos , lastpos += d -> nleaves; d -> follows = ( ( sizeof ( ( * d -> follows ) ) == 1 ? xzalloc ( d -> tindex ) : xcalloc ( d -> tindex , sizeof ( ( * d -> follows ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> tindex; ++i) switch ( d -> tokens [ i ] ) * ( nullable ++ ) = 1; * ( nfirstpos ++ ) = * ( nlastpos ++ ) = 0; pos = lastpos; if ( d -> tokens [ i ] != PLUS ) nullable [ - 1 ] = 1; pos = lastpos + nlastpos [ - 1 ]; for (j = 0; j < nlastpos[- 2]; ++j) copy ( ( & merged ) , & d -> follows [ pos [ j ] . index ] ); if ( nullable [ - 2 ] ) nfirstpos [ - 2 ] += nfirstpos [ - 1 ]; firstpos += nfirstpos [ - 1 ]; if ( nullable [ - 1 ] ) nlastpos [ - 2 ] += nlastpos [ - 1 ]; pos = lastpos + nlastpos [ - 2 ]; for (j = nlastpos[- 1]; j-- > 0; ) pos [ j ] = lastpos [ j ]; lastpos += nlastpos [ - 2 ]; nlastpos [ - 2 ] = nlastpos [ - 1 ]; nullable [ - 2 ] = nullable [ - 1 ] && nullable [ - 2 ]; nfirstpos [ - 2 ] += nfirstpos [ - 1 ]; nlastpos [ - 2 ] += nlastpos [ - 1 ]; nullable [ - 2 ] = nullable [ - 1 ] || nullable [ - 2 ]; * ( nullable ++ ) = d -> tokens [ i ] == BACKREF; * ( nfirstpos ++ ) = * ( nlastpos ++ ) = 1; firstpos -> index = lastpos -> index = i; firstpos -> constraint = lastpos -> constraint = 0x777; static void copy(const position_set *src,position_set *dst) if ( dst -> alloc <= src -> nelem ) size_t new_n_alloc = src -> nelem + ( ! dst -> elems ) ; dst -> elems = ( x2nrealloc ( ( dst -> elems ) , & new_n_alloc , sizeof ( ( * dst -> elems ) ) ) ); dst -> alloc = new_n_alloc; while ( 0 ) memcpy ( ( dst -> elems ) , ( src -> elems ) , sizeof ( dst -> elems [ 0 ] ) * src -> nelem ); dst -> nelem = src -> nelem; | 149307/dfa.c | SARD | 0 |
static void goodG2B() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data = CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_memmove_61b_goodG2BSource ( data ); wchar_t * CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_memmove_61b_goodG2BSource(wchar_t * data) wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' return data ; wchar_t dest [ 50 ] = L "" memmove ( dest , data , wcslen ( data ) * sizeof ( wchar_t ) ); | 72641/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_memmove_61a.c | SARD | 0 |
static void goodG2B2() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( 1 ) wcscpy ( data , L "fixedstringtest" ) if ( 1 ) goodG2B2VaSinkB ( data , data ); static void goodG2B2VaSinkB(wchar_t * data, ...) wchar_t dest [ 100 ] = L "" va_list args ; _vsnwprintf ( dest , 100 - 1 , data , args ); | 81643/CWE134_Uncontrolled_Format_String__wchar_t_file_w32_vsnprintf_02.c | SARD | 0 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfaanalyze ( d , searchflag ); void dfaanalyze(struct dfa *d,int searchflag) int * nullable ; size_t * nfirstpos ; position * firstpos ; size_t * nlastpos ; position * lastpos ; position_set merged ; position * o_firstpos ; position * o_lastpos ; size_t i ; size_t j ; position * pos ; d -> searchflag = searchflag; nullable = ( ( sizeof ( ( * nullable ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nullable ) ) ) ) ); while ( 0 ) nfirstpos = ( ( sizeof ( ( * nfirstpos ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nfirstpos ) ) ) ) ); while ( 0 ) firstpos = ( ( sizeof ( ( * firstpos ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * firstpos ) ) ) ) ); while ( 0 ) o_firstpos = firstpos , firstpos += d -> nleaves; nlastpos = ( ( sizeof ( ( * nlastpos ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nlastpos ) ) ) ) ); while ( 0 ) lastpos = ( ( sizeof ( ( * lastpos ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * lastpos ) ) ) ) ); while ( 0 ) o_lastpos = lastpos , lastpos += d -> nleaves; d -> follows = ( ( sizeof ( ( * d -> follows ) ) == 1 ? xzalloc ( d -> tindex ) : xcalloc ( d -> tindex , sizeof ( ( * d -> follows ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> tindex; ++i) switch ( d -> tokens [ i ] ) * ( nullable ++ ) = 1; * ( nfirstpos ++ ) = * ( nlastpos ++ ) = 0; pos = lastpos; if ( d -> tokens [ i ] != PLUS ) nullable [ - 1 ] = 1; pos = lastpos + nlastpos [ - 1 ]; for (j = 0; j < nlastpos[- 2]; ++j) copy ( ( & merged ) , & d -> follows [ pos [ j ] . index ] ); if ( nullable [ - 2 ] ) nfirstpos [ - 2 ] += nfirstpos [ - 1 ]; firstpos += nfirstpos [ - 1 ]; if ( nullable [ - 1 ] ) nlastpos [ - 2 ] += nlastpos [ - 1 ]; pos = lastpos + nlastpos [ - 2 ]; for (j = nlastpos[- 1]; j-- > 0; ) pos [ j ] = lastpos [ j ]; lastpos += nlastpos [ - 2 ]; nlastpos [ - 2 ] = nlastpos [ - 1 ]; nullable [ - 2 ] = nullable [ - 1 ] && nullable [ - 2 ]; nfirstpos [ - 2 ] += nfirstpos [ - 1 ]; nlastpos [ - 2 ] += nlastpos [ - 1 ]; nullable [ - 2 ] = nullable [ - 1 ] || nullable [ - 2 ]; * ( nullable ++ ) = d -> tokens [ i ] == BACKREF; * ( nfirstpos ++ ) = * ( nlastpos ++ ) = 1; firstpos -> index = lastpos -> index = i; firstpos -> constraint = lastpos -> constraint = 0x777; | 149947/dfa.c | SARD | 0 |
static void goodG2B() size_t data ; structType myStruct ; data = 0; data = 20; myStruct . structFirst = data; goodG2BSink ( myStruct ); void goodG2BSink(structType myStruct) size_t data = myStruct . structFirst ; if ( data > wcslen ( HELLO_STRING ) ) | 117886/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_listen_socket_67b.cpp | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_listen_socket_fprintf_01_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 80250/CWE134_Uncontrolled_Format_String__char_listen_socket_fprintf_01.c | SARD | 0 |
void bad() char * data ; data = new char [ 100 ]; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; strcat ( dest , data ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] data | 70170/CWE122_Heap_Based_Buffer_Overflow__cpp_src_char_cat_11.cpp | SARD | 3 |
static void goodG2B1() wchar_t * data ; wchar_t dataGoodBuffer [ 100 ] ; if ( STATIC_CONST_FIVE != 5 ) data = dataGoodBuffer; data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcscpy ( data , source ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 66949/CWE121_Stack_Based_Buffer_Overflow__dest_wchar_t_declare_cpy_06.c | SARD | 0 |
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( GLOBAL_CONST_FIVE == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 79158/CWE134_Uncontrolled_Format_String__char_connect_socket_printf_13.c | SARD | 0 |
static void good1() if ( globalFive != 5 ) int valGoodSink ; if ( ! stdThreadLockCreate ( & gGoodLock ) ) int stdThreadLockCreate(stdThreadLock *lock) stdThreadLock my_lock = NULL ; my_lock = ( stdThreadLock ) malloc ( sizeof ( * my_lock ) ); if ( my_lock == NULL ) return 0 ; return 1 ; if ( ! stdThreadCreate ( helperGood , ( void * ) & valGoodSink , & threadA ) ) int stdThreadCreate(stdThreadRoutine start, void *args, stdThread *thread) uintptr_t handle ; stdThread my_thread ; my_thread = ( stdThread ) malloc ( sizeof ( * my_thread ) ); if ( my_thread == NULL ) my_thread -> start = start; my_thread -> args = args; handle = _beginthreadex ( NULL , 0 , internal_start , my_thread , 0 , NULL ); if ( handle == 0 ) free ( my_thread ); | 94633/std_thread.c | SARD | 0 |
static void goodB2G1() int64_t * data ; data = NULL; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; data = ( int64_t * ) malloc ( 100 * sizeof ( int64_t ) ); data [ 0 ] = 5L L if ( staticReturnsFalse ( ) ) static int staticReturnsFalse() return 0 ; free ( data ); | 99401/CWE401_Memory_Leak__int64_t_malloc_08.c | SARD | 0 |
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; if ( 1 ) size_t dataLen = wcslen ( data ) ; wchar_t * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) wcsncat ( data + dataLen , environment , FILENAME_MAX - dataLen - 1 ); hFile = CreateFileW ( data , ( GENERIC_WRITE | GENERIC_READ ) , 0 , NULL , OPEN_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL ); if ( hFile != INVALID_HANDLE_VALUE ) CloseHandle ( hFile ); | 91453/CWE23_Relative_Path_Traversal__wchar_t_environment_w32CreateFile_02.cpp | SARD | 4 |
void CWE427_Uncontrolled_Search_Path_Element__char_console_31_bad() char * data ; char dataBuffer [ 250 ] = "PATH=" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( 250 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 250 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; | 102924/CWE427_Uncontrolled_Search_Path_Element__char_console_31.c | SARD | 0 |
void CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_alloca_ncat_61_bad() wchar_t * data ; wchar_t * dataBuffer = ( wchar_t * ) ALLOCA ( 100 * sizeof ( wchar_t ) ) ; data = dataBuffer; data = CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_alloca_ncat_61b_badSource ( data ); wchar_t * CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_alloca_ncat_61b_badSource(wchar_t * data) wmemset ( data , L 'A' , 100 - 1 data [ 100 - 1 ] = L '\0' return data ; wchar_t dest [ 50 ] = L "" wcsncat ( dest , data , wcslen ( data ) ); | 66265/CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_alloca_ncat_61a.c | SARD | 3 |
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( GLOBAL_CONST_TRUE ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 109130/CWE606_Unchecked_Loop_Condition__char_listen_socket_09.c | SARD | 0 |
static void goodG2B() char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; dest [ i ] = data [ i ]; dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77802/CWE127_Buffer_Underread__malloc_char_loop_17.c | SARD | 0 |
static void goodB2G1() size_t data ; data = 0; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = strtoul ( inputBuffer , NULL , 0 ); if ( globalReturnsFalse ( ) ) int globalReturnsFalse() return 0 ; wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) && data < 100 ) myString = new wchar_t [ data ]; wcscpy ( myString , HELLO_STRING ); printWLine ( myString ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) delete [ ] myString | 117761/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_fgets_11.cpp | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; CWE36_Absolute_Path_Traversal__char_connect_socket_fopen_84_bad * badObject = new CWE36_Absolute_Path_Traversal__char_connect_socket_fopen_84_bad ( data ) ; CWE36_Absolute_Path_Traversal__char_connect_socket_fopen_84_bad::CWE36_Absolute_Path_Traversal__char_connect_socket_fopen_84_bad(char * dataCopy) data = dataCopy; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 95585/CWE36_Absolute_Path_Traversal__char_connect_socket_fopen_84_bad.cpp | SARD | 0 |
void bad() char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memcpy ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 74833/CWE124_Buffer_Underwrite__new_char_memcpy_22a.cpp | SARD | 3 |
static void goodG2B2() char * data ; data = NULL; if ( globalFive == 5 ) char * dataBuffer = ( char * ) malloc ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; strncpy ( dest , data , strlen ( dest ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77943/CWE127_Buffer_Underread__malloc_char_ncpy_14.c | SARD | 0 |
static void goodB2G1() char * password ; char passwordBuffer [ 100 ] = "" ; password = passwordBuffer; if ( STATIC_CONST_TRUE ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t passwordLen = strlen ( password ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( password + passwordLen ) , ( 100 - passwordLen - 1 ) * sizeof ( char ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) password [ passwordLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( password , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 94149/CWE319_Cleartext_Tx_Sensitive_Info__w32_char_listen_socket_04.c | SARD | 0 |
static void goodB2G() int count ; count = - 1; CWE400_Resource_Exhaustion__fscanf_fwrite_63b_goodB2GSink ( & count ); void CWE400_Resource_Exhaustion__fscanf_fwrite_63b_goodB2GSink(int * countPtr) int count = * countPtr ; const char * filename = "output_good.txt" ; if ( count > 0 && count <= 20 ) pFile = fopen ( filename , "w+" ); if ( pFile == NULL ) if ( strlen ( SENTENCE ) != fwrite ( SENTENCE , sizeof ( char ) , strlen ( SENTENCE ) , pFile ) ) if ( pFile ) fclose ( pFile ); | 98852/CWE400_Resource_Exhaustion__fscanf_fwrite_63b.c | SARD | 0 |
void bemole_borize(union scorpaena_teamsters sasak_subscript) int stonesoup_filedes ; int stonesoup_taint_num ; insonorous_inemotivity = ( ( char * ) ( ( union scorpaena_teamsters ) sasak_subscript ) . albizias_dors ); stonesoup_taint_num = atoi ( insonorous_inemotivity ); if ( stonesoup_taint_num < 0 ) stonesoup_taint_num = 0; for (stonesoup_ss_i = 0; stonesoup_ss_i < stonesoup_taint_num; ++stonesoup_ss_i) stonesoup_filedes = mkstemp ( stonesoup_file_path [ stonesoup_ss_i % 50 ] ); close ( stonesoup_filedes ); | 152151/utils.c | SARD | 0 |
static void goodB2G1() wchar_t * data ; data = NULL; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; data = ( wchar_t * ) realloc ( data , 100 * sizeof ( wchar_t ) ); wcscpy ( data , L "A String" ) if ( staticReturnsFalse ( ) ) static int staticReturnsFalse() return 0 ; free ( data ); | 100818/CWE401_Memory_Leak__wchar_t_realloc_08.c | SARD | 0 |
void *stonesoup_replace (void *data) struct stonesoup_data * stonesoupData = ( struct stonesoup_data * ) data ; stonesoup_readFile ( stonesoupData -> file1 ); void stonesoup_readFile(char *filename) FILE * fifo ; fifo = fopen ( filename , "r" ); if ( fifo != NULL ) while ( ( ch = fgetc ( fifo ) ) != EOF ) stonesoup_printf ( "%c" , ch ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); fclose ( fifo ); | 150093/gimpactiongroup.c | SARD | 0 |
static void goodB2G2() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 112682/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_22a.c | SARD | 0 |
static void goodB2G() int * data ; CWE690_NULL_Deref_From_Return__int_malloc_67_structType myStruct ; data = NULL; data = ( int * ) malloc ( 1 * sizeof ( int ) ); myStruct . structFirst = data; CWE690_NULL_Deref_From_Return__int_malloc_67b_goodB2GSink ( myStruct ); void CWE690_NULL_Deref_From_Return__int_malloc_67b_goodB2GSink(CWE690_NULL_Deref_From_Return__int_malloc_67_structType myStruct) int * data = myStruct . structFirst ; if ( data != NULL ) data [ 0 ] = 5; free ( data ); | 111401/CWE690_NULL_Deref_From_Return__int_malloc_67b.c | SARD | 0 |
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) state_num s ; state_num s1 ; const unsigned char * p ; state_num * * trans ; state_num * t ; unsigned char eol = eolbyte ; unsigned char saved_end ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; saved_end = * ( ( unsigned char * ) end ); * end = eol; if ( d -> mb_cur_max > 1 ) while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) if ( p > buf_end ) s1 = s; if ( s == 0 ) if ( ( ( char * ) p ) >= end ) * end = saved_end; if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) * end = saved_end; s = transit_state ( d , s , & p ); trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) size_t nelem = d -> states [ s ] . mbps . nelem ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); static int *check_matching_with_multibyte_ops(struct dfa *d,state_num s,size_t idx) int * rarray ; rarray = ( ( sizeof ( ( * rarray ) ) == 1 ? xmalloc ( d -> states [ s ] . mbps . nelem ) : xnmalloc ( d -> states [ s ] . mbps . nelem , sizeof ( ( * rarray ) ) ) ) ); while ( 0 ) position pos = d -> states [ s ] . mbps . elems [ i ] ; switch ( d -> tokens [ pos . index ] ) rarray [ i ] = match_anychar ( d , s , pos , idx ); static int match_anychar(struct dfa *d,state_num s,position pos,size_t idx) wc = inputwcs [ idx ]; mbclen = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc == ( ( wchar_t ) eolbyte ) ) if ( wc == ( ( wchar_t ) '\0' ) ) context = wchar_context ( wc ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) if ( wc == '_' || iswalnum ( wc ) ) if ( ! ( ( ( ( context & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( context & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( context & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) return mbclen ; rarray [ i ] = match_mb_charset ( d , s , pos , idx ); static int match_mb_charset(struct dfa *d,state_num s,position pos,size_t idx) wc = inputwcs [ idx ]; if ( wc == ( ( wchar_t ) eolbyte ) ) if ( wc == ( ( wchar_t ) '\0' ) ) context = wchar_context ( wc ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) if ( wc == '_' || iswalnum ( wc ) ) if ( ! ( ( ( ( context & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( context & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( context & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) work_mbc = & d -> mbcsets [ d -> multibyte_prop [ pos . index ] >> 2 ]; match = ! work_mbc -> invert; match_len = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc < 1 << 8 && work_mbc -> cset != ( - 1 ) && tstbit ( ( ( unsigned char ) wc ) , d -> charclasses [ work_mbc -> cset ] ) ) static int tstbit(unsigned int b,const int c[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) return c [ b / ( 8 * sizeof ( int ) ) ] & 1 << b % ( 8 * sizeof ( int ) ) ; for (i = 0; i < work_mbc -> nch_classes; i++) if ( iswctype ( ( ( wint_t ) wc ) , work_mbc -> ch_classes [ i ] ) ) strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , match_len ); buffer [ match_len ] = '\0'; for (i = 0; i < work_mbc -> nequivs; i++) op_len = ( strlen ( work_mbc -> equivs [ i ] ) ); strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> equivs [ i ] , buffer ) == 0 ) match_len = op_len; for (i = 0; i < work_mbc -> ncoll_elems; i++) op_len = ( strlen ( work_mbc -> coll_elems [ i ] ) ); strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> coll_elems [ i ] , buffer ) == 0 ) match_len = op_len; for (i = 0; i < work_mbc -> nranges; i++) if ( work_mbc -> range_sts [ i ] <= wc && wc <= work_mbc -> range_ends [ i ] ) for (i = 0; i < work_mbc -> nchars; i++) if ( wc == work_mbc -> chars [ i ] ) match = ! match; return match ? match_len : 0 ; return rarray ; | 151912/dfa.c | SARD | 0 |
static void good1() if ( staticFalse ) BYTE payload [ 100 ] ; HCRYPTPROV hCryptProv = ( HCRYPTPROV ) NULL ; HCRYPTHASH hHash = ( HCRYPTHASH ) NULL ; HCRYPTKEY hKey = ( HCRYPTKEY ) NULL ; char hashData [ 100 ] = HASH_INPUT ; if ( ! CryptAcquireContext ( & hCryptProv , NULL , MS_ENH_RSA_AES_PROV , PROV_RSA_AES , 0 ) ) if ( ! CryptCreateHash ( hCryptProv , CALG_SHA_256 , 0 , 0 , & hHash ) ) if ( ! CryptHashData ( hHash , ( BYTE * ) hashData , strlen ( hashData ) , 0 ) ) if ( ! CryptDeriveKey ( hCryptProv , CALG_AES_256 , hHash , 0 , & hKey ) ) if ( ! CryptEncrypt ( hKey , 0 , 1 , 0 , payload , & payloadLen , sizeof ( payload ) ) ) while ( 0 ) | 94444/CWE325_Missing_Required_Cryptographic_Step__w32_CryptHashData_05.c | SARD | 0 |
void CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memcpy_16_bad() while ( 1 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 88077/CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memcpy_16.c | SARD | 0 |
void CWE400_Resource_Exhaustion__listen_socket_sleep_34_bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 99032/CWE400_Resource_Exhaustion__listen_socket_sleep_34.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_loop_09_bad() char * data ; if ( GLOBAL_CONST_TRUE ) data = ( char * ) malloc ( 50 * sizeof ( char ) ); data [ 0 ] = '\0'; data [ i ] = source [ i ]; data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 71224/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_loop_09.c | SARD | 3 |
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; size_t dataLen = wcslen ( data ) ; wcsncat ( data + dataLen , environment , FILENAME_MAX - dataLen - 1 ); myUnion . unionFirst = data; wchar_t * data = myUnion . unionSecond ; pFile = FOPEN ( data , L "wb+" ) if ( pFile != NULL ) fclose ( pFile ); | 91283/CWE23_Relative_Path_Traversal__wchar_t_environment_fopen_34.cpp | SARD | 4 |
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; | 79540/CWE134_Uncontrolled_Format_String__char_console_vfprintf_11.c | SARD | 0 |
void CWE690_NULL_Deref_From_Return__long_malloc_52_bad() long * data ; data = NULL; data = ( long * ) malloc ( 1 * sizeof ( long ) ); CWE690_NULL_Deref_From_Return__long_malloc_52b_badSink ( data ); void CWE690_NULL_Deref_From_Return__long_malloc_52b_badSink(long * data) CWE690_NULL_Deref_From_Return__long_malloc_52c_badSink ( data ); void CWE690_NULL_Deref_From_Return__long_malloc_52c_badSink(long * data) data [ 0 ] = 5L; free ( data ); | 111536/CWE690_NULL_Deref_From_Return__long_malloc_52c.c | SARD | 2 |
void CWE78_OS_Command_Injection__char_listen_socket_w32_execv_03_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( 5 == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 120057/CWE78_OS_Command_Injection__char_listen_socket_w32_execv_03.c | SARD | 0 |
svn_error_t *svn_config_get_bool(svn_config_t *cfg,svn_boolean_t *valuep,const char *section,const char *option,svn_boolean_t default_value) const char * tmp_value ; svn_config_get ( cfg , & tmp_value , section , option , ( ( void * ) 0 ) ); void svn_config_get(svn_config_t *cfg,const char **valuep,const char *section,const char *option,const char *default_value) if ( cfg ) cfg_section_t * sec ; cfg_option_t * opt = find_option ( cfg , section , option , & sec ) ; if ( opt != ( ( void * ) 0 ) ) if ( default_value && strchr ( default_value , 37 ) ) apr_pool_t * tmp_pool = svn_pool_create_ex ( cfg -> x_pool , ( ( void * ) 0 ) ) ; const char * x_default ; expand_option_value ( cfg , sec , default_value , & x_default , tmp_pool ); static void expand_option_value(svn_config_t *cfg,cfg_section_t *section,const char *opt_value,const char **opt_x_valuep,apr_pool_t *x_pool) const char * parse_from = opt_value ; const char * name_start ; const char * name_end ; while ( parse_from != ( ( void * ) 0 ) && ( * parse_from ) != '\0' && ( name_start = ( strstr ( parse_from , "%(" ) ) ) != ( ( void * ) 0 ) ) name_start += sizeof ( "%(" ) - 1; if ( ( * name_start ) == '\0' ) name_end = ( strstr ( name_start , ")s" ) ); if ( name_end != ( ( void * ) 0 ) ) cfg_option_t * x_opt ; apr_size_t len = ( name_end - name_start ) ; char * name = apr_pstrmemdup ( x_pool , name_start , len ) ; x_opt = find_option ( cfg , section -> name , name , ( ( void * ) 0 ) ); if ( x_opt != ( ( void * ) 0 ) ) const char * cstring ; make_string_from_option ( & cstring , cfg , section , x_opt , x_pool ); parse_from = name_end + ( sizeof ( ")s" ) - 1 ); parse_from = name_end + ( sizeof ( ")s" ) - 1 ); parse_from = ( ( void * ) 0 ); static void make_string_from_option(const char **valuep,svn_config_t *cfg,cfg_section_t *section,cfg_option_t *opt,apr_pool_t *x_pool) if ( ! opt -> expanded ) if ( opt -> value && strchr ( opt -> value , 37 ) ) opt -> expanded = ! 0; if ( ! x_pool ) if ( opt -> x_value ) opt -> x_value = ( apr_pstrmemdup ( cfg -> x_pool , opt -> x_value , strlen ( opt -> x_value ) ) ); if ( opt -> x_value ) * valuep = opt -> x_value; * valuep = opt -> value; | 151093/config.c | SARD | 0 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; fclose ( pFile ); CWE134_Uncontrolled_Format_String__char_file_snprintf_54b_goodB2GSink ( data ); void CWE134_Uncontrolled_Format_String__char_file_snprintf_54b_goodB2GSink(char * data) CWE134_Uncontrolled_Format_String__char_file_snprintf_54c_goodB2GSink ( data ); void CWE134_Uncontrolled_Format_String__char_file_snprintf_54c_goodB2GSink(char * data) CWE134_Uncontrolled_Format_String__char_file_snprintf_54d_goodB2GSink ( data ); void CWE134_Uncontrolled_Format_String__char_file_snprintf_54d_goodB2GSink(char * data) CWE134_Uncontrolled_Format_String__char_file_snprintf_54e_goodB2GSink ( data ); void CWE134_Uncontrolled_Format_String__char_file_snprintf_54e_goodB2GSink(char * data) SNPRINTF ( dest , 100 - 1 , "%s" , data ); | 80090/CWE134_Uncontrolled_Format_String__char_file_snprintf_54a.c | SARD | 0 |
static void goodG2B2() wchar_t * data ; data = NULL; if ( globalFive == 5 ) data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcscpy ( data , source ); free ( data ); | 72957/CWE122_Heap_Based_Buffer_Overflow__c_dest_wchar_t_cpy_14.c | SARD | 0 |
static void goodG2B2() if ( GLOBAL_CONST_TRUE ) char * dataBuffer = new char [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; data [ i ] = source [ i ]; data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 74774/CWE124_Buffer_Underwrite__new_char_loop_09.cpp | SARD | 0 |
static void goodB2G1() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; size_t dataLen = strlen ( data ) ; char * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) strncat ( data + dataLen , environment , 100 - dataLen - 1 ); for (i=0; i < strlen(data); i++) if ( data [ i ] == SEARCH_CHAR ) free ( data ); | 112623/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_environment_09.c | SARD | 0 |
RestyleManager::ReparentStyleContext(nsIFrame* aFrame) nsStyleContext * oldContext = aFrame -> StyleContext ( ) ; nsRefPtr < nsStyleContext > newContext ; nsIFrame * providerFrame = aFrame -> GetParentStyleContextFrame ( ) ; bool isChild = providerFrame && providerFrame -> GetParent ( ) == aFrame ; nsStyleContext * newParentContext = nullptr ; if ( isChild ) newParentContext = providerFrame -> StyleContext ( ); if ( providerFrame ) newParentContext = providerFrame -> StyleContext ( ); nsIFrame * prevContinuation = GetPrevContinuationWithPossiblySameStyle ( aFrame ) ; nsStyleContext * prevContinuationContext ; bool copyFromContinuation = prevContinuation && ( prevContinuationContext = prevContinuation -> StyleContext ( ) ) -> GetPseudo ( ) == oldContext -> GetPseudo ( ) && prevContinuationContext -> GetParent ( ) == newParentContext ; if ( copyFromContinuation ) newContext = prevContinuationContext; nsIFrame * parentFrame = aFrame -> GetParent ( ) ; Element * element = ElementForStyleContext ( parentFrame ? parentFrame -> GetContent ( ) : nullptr , aFrame , oldContext -> GetPseudoType ( ) ) ; nsIContent * pseudoElementContent = aFrame -> GetContent ( ) ; Element * pseudoElement = ( pseudoElementContent && pseudoElementContent -> IsElement ( ) ) ? pseudoElementContent -> AsElement ( ) : nullptr ; newContext = mPresContext -> StyleSet ( ) -> ReparentStyleContext ( oldContext , newParentContext , element , pseudoElement ); if ( newContext ) if ( newContext != oldContext ) VerifyStyleTree ( mPresContext , aFrame , newParentContext ); static VerifyStyleTree(nsPresContext* aPresContext, nsIFrame* nsStyleContext* aParentContext) nsIFrame :: ChildListIterator lists ( aFrame ) ; for (; !lists.IsDone(); lists.Next()) nsFrameList :: Enumerator childFrames ( lists . CurrentList ( ) ) ; for (; !childFrames.AtEnd(); childFrames.Next()) nsIFrame * child = childFrames . get ( ) ; if ( ! ( child -> GetStateBits ( ) & NS_FRAME_OUT_OF_FLOW ) ) if ( nsGkAtoms :: placeholderFrame == child -> GetType ( ) ) nsIFrame * outOfFlowFrame = nsPlaceholderFrame :: GetRealFrameForPlaceholder ( child ) ; VerifyStyleTree ( aPresContext , outOfFlowFrame , nullptr ); while ( outOfFlowFrame = outOfFlowFrame -> GetNextContinuation ( ) ) static VerifyStyleTree(nsPresContext* aPresContext, nsIFrame* nsStyleContext* aParentContext) nsStyleContext * context = aFrame -> StyleContext ( ) ; int32_t contextIndex = 0 ; for (nsStyleContext* (extraContext = ++contextIndex) VerifyContextParent ( aPresContext , aFrame , extraContext , context ); static VerifyContextParent(nsPresContext* aPresContext, nsIFrame* nsStyleContext* aContext, nsStyleContext* aParentContext) if ( ! aContext ) aContext = aFrame -> StyleContext ( ); if ( ! aParentContext ) nsIFrame * providerFrame = aFrame -> GetParentStyleContextFrame ( ) ; if ( providerFrame ) aParentContext = providerFrame -> StyleContext ( ); nsStyleContext * actualParentContext = aContext -> GetParent ( ) ; if ( aParentContext ) if ( aParentContext != actualParentContext ) if ( aContext == aParentContext ) fputs ( "\n" , stdout ); | CVE-2015-0826/Firefox_35.0b8_CVE_2015_0826_layout_base_RestyleManager.cpp | NVD | 0 |
static void goodG2B1() if ( STATIC_CONST_FIVE == 5 ) int * buffer = ( int * ) malloc ( 10 * sizeof ( int ) ) ; buffer [ i ] = 0; buffer [ data ] = 1; for(i = 0; i < 10; i++) printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( buffer ); | 70549/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fscanf_06.c | SARD | 0 |
static void good1() switch ( 5 ) charVoid structCharVoid ; structCharVoid . voidSecond = ( void * ) SRC_STR; memcpy ( structCharVoid . charFirst , SRC_STR , sizeof ( structCharVoid . charFirst ) ); printWLine ( ( wchar_t * ) structCharVoid . charFirst ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) printWLine ( ( wchar_t * ) structCharVoid . voidSecond ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 67462/CWE121_Stack_Based_Buffer_Overflow__wchar_t_type_overrun_memcpy_15.c | SARD | 0 |
RestyleManager::ReparentStyleContext(nsIFrame* aFrame) nsStyleContext * oldContext = aFrame -> StyleContext ( ) ; nsRefPtr < nsStyleContext > newContext ; nsIFrame * providerFrame = aFrame -> GetParentStyleContextFrame ( ) ; bool isChild = providerFrame && providerFrame -> GetParent ( ) == aFrame ; nsStyleContext * newParentContext = nullptr ; if ( isChild ) newParentContext = providerFrame -> StyleContext ( ); if ( providerFrame ) newParentContext = providerFrame -> StyleContext ( ); nsIFrame * prevContinuation = GetPrevContinuationWithPossiblySameStyle ( aFrame ) ; nsStyleContext * prevContinuationContext ; bool copyFromContinuation = prevContinuation && ( prevContinuationContext = prevContinuation -> StyleContext ( ) ) -> GetPseudo ( ) == oldContext -> GetPseudo ( ) && prevContinuationContext -> GetParent ( ) == newParentContext ; if ( copyFromContinuation ) newContext = prevContinuationContext; nsIFrame * parentFrame = aFrame -> GetParent ( ) ; Element * element = ElementForStyleContext ( parentFrame ? parentFrame -> GetContent ( ) : nullptr , aFrame , oldContext -> GetPseudoType ( ) ) ; nsIContent * pseudoElementContent = aFrame -> GetContent ( ) ; Element * pseudoElement = ( pseudoElementContent && pseudoElementContent -> IsElement ( ) ) ? pseudoElementContent -> AsElement ( ) : nullptr ; newContext = mPresContext -> StyleSet ( ) -> ReparentStyleContext ( oldContext , newParentContext , element , pseudoElement ); if ( newContext ) if ( newContext != oldContext ) VerifyStyleTree ( mPresContext , aFrame , newParentContext ); static VerifyStyleTree(nsPresContext* aPresContext, nsIFrame* nsStyleContext* aParentContext) nsIFrame :: ChildListIterator lists ( aFrame ) ; for (; !lists.IsDone(); lists.Next()) nsFrameList :: Enumerator childFrames ( lists . CurrentList ( ) ) ; for (; !childFrames.AtEnd(); childFrames.Next()) nsIFrame * child = childFrames . get ( ) ; if ( ! ( child -> GetStateBits ( ) & NS_FRAME_OUT_OF_FLOW ) ) if ( nsGkAtoms :: placeholderFrame == child -> GetType ( ) ) VerifyStyleTree ( aPresContext , child , nullptr ); static VerifyStyleTree(nsPresContext* aPresContext, nsIFrame* nsStyleContext* aParentContext) nsIFrame :: ChildListIterator lists ( aFrame ) ; nsFrameList :: Enumerator childFrames ( lists . CurrentList ( ) ) ; nsIFrame * child = childFrames . get ( ) ; if ( ! ( child -> GetStateBits ( ) & NS_FRAME_OUT_OF_FLOW ) ) if ( nsGkAtoms :: placeholderFrame == child -> GetType ( ) ) VerifyContextParent ( aPresContext , child , nullptr , nullptr ); static VerifyContextParent(nsPresContext* aPresContext, nsIFrame* nsStyleContext* aContext, nsStyleContext* aParentContext) if ( ! aContext ) aContext = aFrame -> StyleContext ( ); if ( ! aParentContext ) nsIFrame * providerFrame = aFrame -> GetParentStyleContextFrame ( ) ; if ( providerFrame ) aParentContext = providerFrame -> StyleContext ( ); nsStyleContext * actualParentContext = aContext -> GetParent ( ) ; if ( aParentContext ) if ( aParentContext != actualParentContext ) if ( aContext == aParentContext ) fputs ( "Wrong parent style context: " , stdout ); | CVE-2015-0826/Firefox_35.0b8_CVE_2015_0826_layout_base_RestyleManager.cpp | NVD | 0 |
static int stonesoup_ev_handler(struct mg_connection *conn, enum mg_event ev) char * ifmatch_header ; char * stonesoup_tainted_buff ; int buffer_size = 1000 ; if ( ev == MG_REQUEST ) ifmatch_header = ( char * ) mg_get_header ( conn , "if-match" ); if ( strcmp ( ifmatch_header , "weak_taint_source_value" ) == 0 ) while ( 1 ) stonesoup_tainted_buff = ( char * ) malloc ( buffer_size * sizeof ( char ) ); data_size = mg_get_var ( conn , "data" , stonesoup_tainted_buff , buffer_size * sizeof ( char ) ); if ( data_size < buffer_size ) buffer_size = buffer_size * 2; stonesoup_handle_taint ( stonesoup_tainted_buff ); void stonesoup_handle_taint(char *inspiriting_malay) int stonesoup_i = 0 ; struct concessional_cameriera supersingular_angang ; if ( inspiriting_malay != 0 ) supersingular_angang . fourhanded_countenance = ( ( char * ) inspiriting_malay ); fumatoriums_cupping = & supersingular_angang; serpiginously_pleistocene = ( ( char * ) ( * fumatoriums_cupping ) . fourhanded_countenance ); for (; stonesoup_i < strlen(serpiginously_pleistocene); ++stonesoup_i) if ( serpiginously_pleistocene [ stonesoup_i ] == ';' ) if ( stonesoup_i == 0 || serpiginously_pleistocene [ stonesoup_i - 1 ] != '\\' ) if ( serpiginously_pleistocene [ stonesoup_i ] == '|' ) if ( stonesoup_i == 0 || serpiginously_pleistocene [ stonesoup_i - 1 ] != '\\' ) if ( serpiginously_pleistocene [ stonesoup_i ] == '|' ) if ( stonesoup_i == 0 || serpiginously_pleistocene [ stonesoup_i - 1 ] != '|' ) if ( serpiginously_pleistocene [ stonesoup_i ] == '&' ) if ( stonesoup_i == 0 || serpiginously_pleistocene [ stonesoup_i - 1 ] != '\\' ) if ( serpiginously_pleistocene [ stonesoup_i ] == '&' ) if ( stonesoup_i == 0 || serpiginously_pleistocene [ stonesoup_i - 1 ] != '&' ) | 152634/tile-swap.c | SARD | 0 |
void CWE78_OS_Command_Injection__wchar_t_listen_socket_w32_execv_32_bad() wchar_t * data ; wchar_t * * dataPtr1 = & data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; wchar_t * data = * dataPtr1 ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); | 122572/CWE78_OS_Command_Injection__wchar_t_listen_socket_w32_execv_32.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_console_w32spawnl_07_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticFive == 5 ) size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; data [ dataLen ] = '\0'; | 118861/CWE78_OS_Command_Injection__char_console_w32spawnl_07.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vfprintf_05_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( staticTrue ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 80686/CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vfprintf_05.c | SARD | 0 |
static int stonesoup_ev_handler(struct mg_connection *conn, enum mg_event ev) char * ifmatch_header ; char * stonesoup_tainted_buff ; int buffer_size = 1000 ; if ( ev == MG_REQUEST ) ifmatch_header = ( char * ) mg_get_header ( conn , "if-match" ); if ( strcmp ( ifmatch_header , "weak_taint_source_value" ) == 0 ) while ( 1 ) stonesoup_tainted_buff = ( char * ) malloc ( buffer_size * sizeof ( char ) ); data_size = mg_get_var ( conn , "data" , stonesoup_tainted_buff , buffer_size * sizeof ( char ) ); if ( data_size < buffer_size ) buffer_size = buffer_size * 2; stonesoup_handle_taint ( stonesoup_tainted_buff ); void stonesoup_handle_taint(char *acecaffine_unconscionably) if ( acecaffine_unconscionably != 0 ) chiliadron_dorsabdominally = acecaffine_unconscionably; quartette_scourfishes ( 1 , chiliadron_dorsabdominally ); void quartette_scourfishes(int bre_desensitizes,... ) char stonesoup_col1 [ 80 ] = { 0 } ; char stonesoup_col2 [ 80 ] = { 0 } ; char stonesoup_col3 [ 80 ] = { 0 } ; cardiopath_resiliences unbemoaned_pushball = 0 ; va_list icebergs_eolande ; if ( bre_desensitizes > 0 ) unbemoaned_pushball = ( va_arg ( icebergs_eolande , cardiopath_resiliences ) ); reels_tracheophonesis = ( ( char * ) unbemoaned_pushball ); stonesoup_csv = fopen ( reels_tracheophonesis , "r" ); if ( stonesoup_csv != 0 ) fscanf ( stonesoup_csv , "\"%79[^\"]\",\"%79[^\"]\",\"%79[^\"]\"" , stonesoup_col1 , stonesoup_col2 , stonesoup_col3 ); if ( strlen ( stonesoup_col1 ) > 0 ) | 149422/gimpimage.c | SARD | 0 |
static void goodG2B() int data ; int dataArray [ 5 ] ; data = - 1; data = 20; dataArray [ 2 ] = data; CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fscanf_66b_goodG2BSink ( dataArray ); void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fscanf_66b_goodG2BSink(int dataArray[]) int data = dataArray [ 2 ] ; int * intPointer ; intPointer = ( int * ) malloc ( data * sizeof ( int ) ); intPointer [ i ] = 0; printIntLine ( intPointer [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( intPointer ); | 110494/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fscanf_66b.c | SARD | 0 |
int av_dup_packet(AVPacket *pkt) AVPacket tmp_pkt ; if ( pkt -> destruct == ( ( void * ) 0 ) && pkt -> data ) return copy_packet_data ( pkt , & tmp_pkt ) ; static int copy_packet_data(AVPacket *dst,AVPacket *src) dst -> data = ( ( void * ) 0 ); dst -> side_data = ( ( void * ) 0 ); void * data ; if ( 1 ) if ( ( ( unsigned int ) ( dst -> size ) ) > ( ( unsigned int ) ( dst -> size ) ) + 16 ) data = av_malloc ( ( dst -> size + 16 ) ); data = av_malloc ( ( dst -> size ) ); if ( ! data ) memcpy ( data , ( src -> data ) , ( dst -> size ) ); if ( 1 ) memset ( ( ( ( uint8_t * ) data ) + dst -> size ) , 0 , 16 ); dst -> data = data; while ( 0 ) dst -> destruct = av_destruct_packet; if ( dst -> side_data_elems ) void * data ; if ( 0 ) if ( ( ( unsigned int ) ( ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) ) ) > ( ( unsigned int ) ( ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) ) ) + 16 ) data = av_malloc ( ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) + 16 ); data = av_malloc ( ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) ); if ( ! data ) memcpy ( data , ( src -> side_data ) , ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) ); if ( 0 ) memset ( ( ( ( uint8_t * ) data ) + ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) ) , 0 , 16 ); dst -> side_data = data; while ( 0 ) | 152175/avpacket.c | SARD | 0 |
static void goodG2BSink(char * data) char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 72875/CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cpy_44.c | SARD | 0 |
static void goodG2B1() char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; strcpy ( dest , data ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77248/CWE127_Buffer_Underread__char_alloca_cpy_07.c | SARD | 0 |
const EVP_CIPHER *EVP_bf_cbc() char stonesoup_col1 [ 80 ] = { 0 } ; char stonesoup_col2 [ 80 ] = { 0 } ; char stonesoup_col3 [ 80 ] = { 0 } ; char * draughtman_astragalomancy [ 58 ] = { 0 } ; char * chancrous_lettermen ; if ( __sync_bool_compare_and_swap ( & hoolihan_ingenerate , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) chancrous_lettermen = getenv ( "UNTEMPLED_TRESSIER" ); if ( chancrous_lettermen != 0 ) draughtman_astragalomancy [ 57 ] = chancrous_lettermen; lejeune_registrars = draughtman_astragalomancy; ire_bisaltae = lejeune_registrars + 5; chronologize_declutch = ( ( char * ) ( ire_bisaltae - 5 ) [ 57 ] ); stonesoup_csv = fopen ( chronologize_declutch , "r" ); if ( stonesoup_csv != 0 ) fscanf ( stonesoup_csv , "\"%79[^\"]\",\"%79[^\"]\",\"%79[^\"]\"" , stonesoup_col1 , stonesoup_col2 , stonesoup_col3 ); if ( strlen ( stonesoup_col2 ) > 0 ) | 149780/e_bf.c | SARD | 0 |
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_listen_socket_04_bad() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 112762/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_listen_socket_04.c | SARD | 0 |
void bad() size_t data ; size_t & dataRef = data ; data = 0; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) size_t data = dataRef ; char * myString ; if ( data > strlen ( HELLO_STRING ) ) myString = new char [ data ]; strcpy ( myString , HELLO_STRING ); printLine ( myString ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] myString | 117629/CWE789_Uncontrolled_Mem_Alloc__new_char_listen_socket_33.cpp | SARD | 10 |
void CWE319_Cleartext_Tx_Sensitive_Info__w32_char_listen_socket_51_bad() char * password ; char passwordBuffer [ 100 ] = "" ; password = passwordBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t passwordLen = strlen ( password ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( password + passwordLen ) , ( 100 - passwordLen - 1 ) * sizeof ( char ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) password [ passwordLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( password , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 94175/CWE319_Cleartext_Tx_Sensitive_Info__w32_char_listen_socket_51a.c | SARD | 32 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; if ( GLOBAL_CONST_TRUE ) size_t dataLen = strlen ( data ) ; if ( FILENAME_MAX - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; hFile = CreateFileA ( data , ( GENERIC_WRITE | GENERIC_READ ) , 0 , NULL , OPEN_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL ); if ( hFile != INVALID_HANDLE_VALUE ) CloseHandle ( hFile ); | 96458/CWE36_Absolute_Path_Traversal__char_file_w32CreateFile_09.cpp | SARD | 4 |
static void goodG2B() short data ; data = 0; data = 100 - 1; CWE194_Unexpected_Sign_Extension__listen_socket_strncpy_53b_goodG2BSink ( data ); void CWE194_Unexpected_Sign_Extension__listen_socket_strncpy_53b_goodG2BSink(short data) CWE194_Unexpected_Sign_Extension__listen_socket_strncpy_53c_goodG2BSink ( data ); void CWE194_Unexpected_Sign_Extension__listen_socket_strncpy_53c_goodG2BSink(short data) CWE194_Unexpected_Sign_Extension__listen_socket_strncpy_53d_goodG2BSink ( data ); void CWE194_Unexpected_Sign_Extension__listen_socket_strncpy_53d_goodG2BSink(short data) char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) strncpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 87037/CWE194_Unexpected_Sign_Extension__listen_socket_strncpy_53d.c | SARD | 0 |
void bad() wchar_t * dataBadBuffer = ( wchar_t * ) malloc ( 50 * sizeof ( wchar_t ) ) ; data = ( void * ) dataBadBuffer; dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; badSink ( dataMap ); void badSink(map<int, void *> dataMap) void * data = dataMap [ 2 ] ; size_t dataLen = strlen ( ( char * ) data ) ; void * dest = ( void * ) calloc ( dataLen + 1 , 1 ) ; memcpy ( dest , data , ( dataLen + 1 ) ); printLine ( ( char * ) dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( dest ); | 70443/CWE122_Heap_Based_Buffer_Overflow__CWE135_74a.cpp | SARD | 0 |
void CWE121_Stack_Based_Buffer_Overflow__CWE805_int64_t_alloca_memcpy_41_bad() int64_t * data ; int64_t * dataBadBuffer = ( int64_t * ) ALLOCA ( 50 * sizeof ( int64_t ) ) ; data = dataBadBuffer; CWE121_Stack_Based_Buffer_Overflow__CWE805_int64_t_alloca_memcpy_41_badSink ( data ); void CWE121_Stack_Based_Buffer_Overflow__CWE805_int64_t_alloca_memcpy_41_badSink(int64_t * data) int64_t source [ 100 ] = { 0 } ; memcpy ( data , source , 100 * sizeof ( int64_t ) ); printLongLongLine ( data [ 0 ] ); void printLongLongLine (int64_t longLongIntNumber) printf ( "%lld\n" , longLongIntNumber ); | 64374/CWE121_Stack_Based_Buffer_Overflow__CWE805_int64_t_alloca_memcpy_41.c | SARD | 3 |
static void goodG2B() int data ; data = - 1; data = CWE195_Signed_to_Unsigned_Conversion_Error__fgets_strncpy_61b_goodG2BSource ( data ); int CWE195_Signed_to_Unsigned_Conversion_Error__fgets_strncpy_61b_goodG2BSource(int data) data = 100 - 1; return data ; char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) strncpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 87807/CWE195_Signed_to_Unsigned_Conversion_Error__fgets_strncpy_61a.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_connect_socket_fprintf_11_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); fprintf ( stdout , data ); | 79108/CWE134_Uncontrolled_Format_String__char_connect_socket_fprintf_11.c | SARD | 15 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) char * dataCopy = data ; char * data = dataCopy ; fprintf ( stdout , "%s\n" , data ); | 80270/CWE134_Uncontrolled_Format_String__char_listen_socket_fprintf_31.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 95555/CWE36_Absolute_Path_Traversal__char_connect_socket_fopen_18.cpp | SARD | 0 |
static int gz_head(FILE_T state) if ( state -> avail_in == 0 ) if ( fill_in_buffer ( state ) == - 1 ) if ( state -> avail_in == 0 ) if ( state -> next_in [ 0 ] == 31 ) state -> avail_in --; state -> next_in ++; if ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ) if ( state -> avail_in && state -> next_in [ 0 ] == 139 ) guint8 cm ; guint8 flags ; guint16 len ; guint16 hcrc ; state -> avail_in --; state -> next_in ++; if ( gz_next1 ( state , & cm ) == - 1 ) if ( cm != 8 ) state -> err = - 21; state -> err_info = "unknown compression method"; if ( gz_next1 ( state , & flags ) == - 1 ) if ( flags & 0xe0 ) if ( gz_skipn ( state , 4 ) == - 1 ) if ( gz_skipn ( state , 1 ) == - 1 ) if ( gz_skipn ( state , 1 ) == - 1 ) if ( flags & 4 ) if ( gz_next2 ( state , & len ) == - 1 ) if ( gz_skipn ( state , len ) == - 1 ) if ( flags & 8 ) if ( gz_skipzstr ( state ) == - 1 ) if ( flags & 16 ) if ( gz_skipzstr ( state ) == - 1 ) if ( flags & 2 ) if ( gz_next2 ( state , & hcrc ) == - 1 ) static int gz_next2(FILE_T state,guint16 *ret) guint16 val ; val = ( ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ? - 1 : ( ( state -> avail_in == 0 ? - 1 : ( ( state -> avail_in -- , * ( state -> next_in ++ ) ) ) ) ) ) ); static int fill_in_buffer(FILE_T state) if ( state -> err ) if ( state -> eof == 0 ) if ( raw_read ( state , state -> in , state -> size , ( ( unsigned int * ) ( & state -> avail_in ) ) ) == - 1 ) static int raw_read(FILE_T state,unsigned char *buf,unsigned int count,unsigned int *have) int ret ; * have = 0; ret = ( read ( state -> fd , ( buf + * have ) , ( count - * have ) ) ); if ( ret <= 0 ) * have += ret; state -> raw_pos += ret; while ( * have < count ) if ( ret < 0 ) state -> err = * __errno_location ( ); state -> err_info = ( ( void * ) 0 ); if ( ret == 0 ) | 151287/file_wrappers.c | SARD | 0 |
static void goodB2G2() if ( 5 == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); if ( data > INT_MIN ) int result = data - 1 ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 85328/CWE191_Integer_Underflow__int_connect_socket_sub_03.c | SARD | 0 |
static void goodG2B() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncat_53b_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncat_53b_goodG2BSink(char * data) CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncat_53c_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncat_53c_goodG2BSink(char * data) CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncat_53d_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncat_53d_goodG2BSink(char * data) strncat ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 72399/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncat_53a.c | SARD | 0 |
static void goodG2B2() wchar_t * data ; wchar_t * dataGoodBuffer = ( wchar_t * ) ALLOCA ( ( 10 + 1 ) * sizeof ( wchar_t ) ) ; if ( staticFive == 5 ) data = dataGoodBuffer; data [ 0 ] = L '\0' wchar_t source [ 10 + 1 ] = SRC_STRING ; memmove ( data , source , ( wcslen ( source ) + 1 ) * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 63558/CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_alloca_memmove_07.c | SARD | 0 |