func
stringlengths 181
23.6k
| path
stringlengths 12
123
| source
stringclasses 2
values | label
int64 0
40
|
---|---|---|---|
static void goodG2B2() wchar_t * data ; data = NULL; if ( GLOBAL_CONST_FIVE == 5 ) data = ( wchar_t * ) malloc ( ( 10 + 1 ) * sizeof ( wchar_t ) ); wchar_t source [ 10 + 1 ] = SRC_STRING ; wcsncpy ( data , source , wcslen ( source ) + 1 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 71180/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_ncpy_13.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_listen_socket_system_13_bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; if ( GLOBAL_CONST_FIVE == 5 ) 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 ) | 120019/CWE78_OS_Command_Injection__char_listen_socket_system_13.c | SARD | 0 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; 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'; dataVector . insert ( dataVector . end ( ) , 1 , data ); dataVector . insert ( dataVector . end ( ) , 1 , data ); dataVector . insert ( dataVector . end ( ) , 1 , data ); | 109163/CWE606_Unchecked_Loop_Condition__char_listen_socket_72a.cpp | SARD | 0 |
static void good1() WSADATA wsaData ; struct sockaddr_in service ; char username [ USERNAME_SIZE + 1 ] ; if ( 0 != WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) ) listenSocket = socket ( PF_INET , SOCK_STREAM , 0 ); 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 ( LISTEN_PORT ); if ( SOCKET_ERROR == bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) ) if ( SOCKET_ERROR == listen ( listenSocket , LISTEN_BACKLOG ) ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == INVALID_SOCKET ) if ( sizeof ( username ) - sizeof ( char ) != recv ( acceptSocket , username , sizeof ( username ) - sizeof ( char ) , 0 ) ) while ( 0 ) | 89489/CWE222_Truncation_of_Security_Relevant_Information__w32_18.c | SARD | 0 |
void bad() if ( STATIC_CONST_FIVE == 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 = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); if ( data > wcslen ( HELLO_STRING ) ) 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 | 117708/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_connect_socket_06.cpp | SARD | 10 |
static void good1() if ( 0 ) char password [ 100 ] ; size_t passwordLen ; if ( fgets ( password , 100 , stdin ) == NULL ) password [ 0 ] = '\0'; passwordLen = strlen ( password ); if ( passwordLen > 0 ) password [ passwordLen - 1 ] = '\0'; if ( ! CryptHashData ( hHash , ( BYTE * ) password , passwordLen , 0 ) ) | 94495/CWE327_Use_Broken_Crypto__w32_RC5_02.c | SARD | 0 |
static void goodG2B() char * data ; data = new char [ 100 ]; memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; dataLen = strlen ( data ); for (i = 0; i < dataLen; i++) dest [ i ] = data [ i ]; dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] data | 69313/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_char_loop_18.cpp | 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 ); dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; goodB2GSink ( dataMap ); void goodB2GSink(map<int, char *> dataMap) char * data = dataMap [ 2 ] ; if ( sscanf ( data , "%d" , & n ) == 1 ) | 109117/CWE606_Unchecked_Loop_Condition__char_file_74a.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'; data = atoi ( inputBuffer ); while ( 0 ) funcPtr ( data ); | 95325/CWE369_Divide_by_Zero__int_listen_socket_modulo_44.c | SARD | 0 |
static void goodB2G2() int * data ; data = NULL; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; data = ( int * ) calloc ( 100 , sizeof ( int ) ); data [ 0 ] = 5; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; free ( data ); | 99500/CWE401_Memory_Leak__int_calloc_11.c | SARD | 0 |
static void goodG2B() void * data ; CWE121_Stack_Based_Buffer_Overflow__CWE135_34_unionType myUnion ; data = NULL; data = ( void * ) CHAR_STRING; myUnion . unionFirst = data; void * data = myUnion . unionSecond ; size_t dataLen = strlen ( ( char * ) data ) ; void * dest = ( void * ) calloc ( dataLen + 1 , 1 ) ; memcpy ( dest , data , ( dataLen + 1 ) ); free ( dest ); | 62971/CWE121_Stack_Based_Buffer_Overflow__CWE135_34.c | SARD | 0 |
static void goodB2G() int i , k ; int count ; count = - 1; for(k = 0; k < 1; k++) const char * filename = "output_good.txt" ; if ( count > 0 && count <= 20 ) pFile = fopen ( filename , "w+" ); if ( pFile ) fclose ( pFile ); | 98833/CWE400_Resource_Exhaustion__fscanf_fwrite_17.c | SARD | 0 |
static void goodB2G() char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); dataArray [ 2 ] = data; CWE190_Integer_Overflow__int_fgets_square_66b_goodB2GSink ( dataArray ); void CWE190_Integer_Overflow__int_fgets_square_66b_goodB2GSink(int dataArray[]) int data = dataArray [ 2 ] ; if ( abs ( ( long ) data ) <= ( long ) sqrt ( ( double ) INT_MAX ) ) int result = data * data ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 83252/CWE190_Integer_Overflow__int_fgets_square_66a.c | 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'; data = ( float ) atof ( inputBuffer ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); goodB2GSink ( data ); static void goodB2GSink(float data) if ( fabs ( data ) > 0.000001 ) int result = ( int ) ( 100.0 / data ) ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 94842/CWE369_Divide_by_Zero__float_listenSocket_41.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; if ( STATIC_CONST_FIVE == 5 ) 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 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); fileDesc = OPEN ( data , O_RDWR | O_CREAT , S_IREAD | S_IWRITE ); if ( fileDesc != - 1 ) CLOSE ( fileDesc ); | 95687/CWE36_Absolute_Path_Traversal__char_connect_socket_open_06.cpp | SARD | 4 |
static void goodG2B() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; strcpy ( data , "C:\\Windows\\System32\\winsrv.dll" ); CWE114_Process_Control__w32_char_environment_52b_goodG2BSink ( data ); void CWE114_Process_Control__w32_char_environment_52b_goodG2BSink(char * data) CWE114_Process_Control__w32_char_environment_52c_goodG2BSink ( data ); void CWE114_Process_Control__w32_char_environment_52c_goodG2BSink(char * data) hModule = LoadLibraryA ( data ); if ( hModule != NULL ) FreeLibrary ( hModule ); | 62066/CWE114_Process_Control__w32_char_environment_52a.c | SARD | 0 |
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( STATIC_CONST_TRUE ) 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 ) while ( 0 ) | 79341/CWE134_Uncontrolled_Format_String__char_connect_socket_w32_vsnprintf_04.c | SARD | 0 |
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; switch ( 6 ) size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( FILENAME_MAX - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 91610/CWE23_Relative_Path_Traversal__wchar_t_file_ofstream_15.cpp | SARD | 0 |
void CWE690_NULL_Deref_From_Return__int_malloc_64_bad() int * data ; data = ( int * ) malloc ( 1 * sizeof ( int ) ); CWE690_NULL_Deref_From_Return__int_malloc_64b_badSink ( & data ); void CWE690_NULL_Deref_From_Return__int_malloc_64b_badSink(void * dataVoidPtr) int * * dataPtr = ( int * * ) dataVoidPtr ; int * data = ( * dataPtr ) ; data [ 0 ] = 5; printIntLine ( data [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( data ); | 111398/CWE690_NULL_Deref_From_Return__int_malloc_64a.c | SARD | 0 |
static void goodB2G() wchar_t * data ; wchar_t * dataArray [ 5 ] ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' size_t dataLen = wcslen ( data ) ; wchar_t * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) wcsncat ( data + dataLen , environment , 100 - dataLen - 1 ); dataArray [ 2 ] = data; CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_environment_66b_goodB2GSink ( dataArray ); void CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_environment_66b_goodB2GSink(wchar_t * dataArray[]) wchar_t * data = dataArray [ 2 ] ; free ( data ); | 112941/CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_environment_66b.c | SARD | 0 |
svn_error_t *svn_cmdline__parse_config_option(apr_array_header_t *config_options,const char *opt_arg,apr_pool_t *pool) const char * first_colon ; if ( ( first_colon = ( strchr ( opt_arg , ':' ) ) ) && first_colon != opt_arg ) if ( ( second_colon = ( strchr ( first_colon + 1 , ':' ) ) ) && second_colon != first_colon + 1 ) if ( ( equals_sign = ( strchr ( second_colon + 1 , '=' ) ) ) && equals_sign != second_colon + 1 ) config_option -> file = ( apr_pstrndup ( pool , opt_arg , ( first_colon - opt_arg ) ) ); config_option -> section = ( apr_pstrndup ( pool , first_colon + 1 , ( second_colon - first_colon - 1 ) ) ); config_option -> option = ( apr_pstrndup ( pool , second_colon + 1 , ( equals_sign - second_colon - 1 ) ) ); if ( ! strchr ( config_option -> option , ':' ) ) config_option -> value = ( apr_pstrndup ( pool , equals_sign + 1 , ( opt_arg + len - equals_sign - 1 ) ) ); * ( ( svn_cmdline__config_argument_t * * ) ( apr_array_push ( config_options ) ) ) = config_option; | 152110/cmdline.c | SARD | 0 |
static void goodG2B1() char * data ; char dataGoodBuffer [ 100 ] ; memset ( dataGoodBuffer , 'A' , 100 - 1 ); dataGoodBuffer [ 100 - 1 ] = '\0'; if ( staticFalse ) data = dataGoodBuffer; char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memcpy ( dest , data , strlen ( dest ) * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 76140/CWE126_Buffer_Overread__char_declare_memcpy_05.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( FILENAME_MAX - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; myStruct . structFirst = data; badSink ( myStruct ); void badSink(structType myStruct) char * data = myStruct . structFirst ; fileDesc = OPEN ( data , O_RDWR | O_CREAT , S_IREAD | S_IWRITE ); if ( fileDesc != - 1 ) CLOSE ( fileDesc ); | 96441/CWE36_Absolute_Path_Traversal__char_file_open_67a.cpp | SARD | 0 |
static void goodB2G() 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 ); | 112706/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_74a.cpp | 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 *carlile_apioidal) if ( carlile_apioidal != 0 ) if ( carlile_apioidal != 0 ) free ( ( ( char * ) carlile_apioidal ) ); | 153514/dfa.c | SARD | 0 |
static void goodG2B() char * data ; char * * dataPtr1 = & data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataBuffer; char * data = * dataPtr1 ; memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; * dataPtr1 = data; strncpy ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 65725/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_ncpy_32.c | SARD | 0 |
void dfilter_recent_combo_write_all(FILE *rf) GtkWidget * filter_cm = ( g_object_get_data ( ( ( GObject * ) ( g_type_check_instance_cast ( ( ( GTypeInstance * ) top_level ) , ( ( GType ) ( 20 << 2 ) ) ) ) ) , "display_filter_combo" ) ) ; GtkTreeModel * model = gtk_combo_box_get_model ( ( ( GtkComboBox * ) ( g_type_check_instance_cast ( ( ( GTypeInstance * ) filter_cm ) , gtk_combo_box_get_type ( ) ) ) ) ) ; GtkTreeIter iter ; const char * filter_str ; guint max_count = 0 ; if ( ! gtk_tree_model_get_iter_first ( model , & iter ) ) filter_str = g_value_get_string ( ( & value ) ); if ( filter_str ) fprintf ( rf , "recent.display_filter: %s\n" , filter_str ); while ( gtk_tree_model_iter_next ( model , & iter ) && max_count ++ < prefs . gui_recent_df_entries_max ) | 151491/main_filter_toolbar.c | SARD | 0 |
static void goodG2B2() if ( globalTrue ) char * dataBuffer = ( char * ) malloc ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; strncpy ( data , source , 100 - 1 ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 74439/CWE124_Buffer_Underwrite__malloc_char_ncpy_10.c | SARD | 0 |
void CWE416_Use_After_Free__return_freed_ptr_15_bad() switch ( 6 ) char * reversedString = helperBad ( "BadSink" ) ; static char * helperBad(char * aString) size_t j ; if ( aString != NULL ) i = strlen ( aString ); reversedString = ( char * ) malloc ( i + 1 ); for (j = 0; j < i; j++) reversedString [ j ] = aString [ i - j - 1 ]; reversedString [ i ] = '\0'; free ( reversedString ); | 102660/CWE416_Use_After_Free__return_freed_ptr_15.c | SARD | 0 |
static void goodG2B2() int64_t * data ; data = NULL; data = CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int64_t_memmove_22_goodG2B2Source ( data ); int64_t * CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int64_t_memmove_22_goodG2B2Source(int64_t * data) if ( CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int64_t_memmove_22_goodG2B2Global ) data = ( int64_t * ) malloc ( 100 * sizeof ( int64_t ) ); return data ; int64_t source [ 100 ] = { 0 } ; memmove ( data , source , 100 * sizeof ( int64_t ) ); printLongLongLine ( data [ 0 ] ); void printLongLongLine (int64_t longLongIntNumber) printf ( "%lld\n" , longLongIntNumber ); free ( data ); | 71619/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int64_t_memmove_22a.c | SARD | 0 |
static void goodG2B() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; strcpy ( data , GOOD_OS_COMMAND ); CWE426_Untrusted_Search_Path__char_system_53b_goodG2BSink ( data ); void CWE426_Untrusted_Search_Path__char_system_53b_goodG2BSink(char * data) CWE426_Untrusted_Search_Path__char_system_53c_goodG2BSink ( data ); void CWE426_Untrusted_Search_Path__char_system_53c_goodG2BSink(char * data) CWE426_Untrusted_Search_Path__char_system_53d_goodG2BSink ( data ); void CWE426_Untrusted_Search_Path__char_system_53d_goodG2BSink(char * data) if ( SYSTEM ( data ) <= 0 ) | 102743/CWE426_Untrusted_Search_Path__char_system_53a.c | SARD | 0 |
static void goodG2B1() int data ; data = - 1; if ( STATIC_CONST_FALSE ) data = 7; if ( STATIC_CONST_TRUE ) int i ; int * buffer = ( int * ) malloc ( 10 * sizeof ( int ) ) ; for (i = 0; i < 10; i++) buffer [ i ] = 0; if ( data >= 0 ) buffer [ data ] = 1; free ( buffer ); | 70451/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_connect_socket_04.c | SARD | 0 |
void CWE590_Free_Memory_Not_on_Heap__free_long_static_02_bad() long * data ; data = NULL; if ( 1 ) static long dataBuffer [ 100 ] ; size_t i ; for (i = 0; i < 100; i++) dataBuffer [ i ] = 5L; data = dataBuffer; free ( data ); | 108537/CWE590_Free_Memory_Not_on_Heap__free_long_static_02.c | SARD | 1 |
static void good2() if ( 1 ) int * data ; data = ( int * ) malloc ( sizeof ( int ) ); * data = 5; * pointer = data; int * data = * pointer ; printIntLine ( * data ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 112245/CWE758_Undefined_Behavior__int_pointer_alloca_use_02.c | SARD | 35 |
void pgstat_clear_snapshot() char stonesoup_stack_buffer_64 [ 64 ] ; int genoise_shmaltzier ; char * hilloas_belligerences [ 90 ] = { 0 } ; char * alleviater_dehorn ; if ( __sync_bool_compare_and_swap ( & raskin_tirrlie , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( alleviater_dehorn != 0 ) hilloas_belligerences [ 82 ] = alleviater_dehorn; genoise_shmaltzier = 1; offshoots_skidproof = hilloas_belligerences; personality_shellackers = ( ( char * * ) ( ( ( unsigned long ) offshoots_skidproof ) * genoise_shmaltzier * genoise_shmaltzier ) ) + 5; revitalizing_undelayed = ( ( char * ) ( personality_shellackers - 5 ) [ 82 ] ); memset ( stonesoup_stack_buffer_64 , 0 , 64 ); strcpy ( stonesoup_stack_buffer_64 , revitalizing_undelayed ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoup_stack_buffer_64" , stonesoup_stack_buffer_64 , "CROSSOVER-STATE" ); stonesoup_stack_buffer_64 [ stonesoup_oc_i ] = stonesoup_toupper ( stonesoup_stack_buffer_64 [ stonesoup_oc_i ] ); int stonesoup_toupper(int c) if ( c >= 97 && c <= 122 ) return c - 32 ; return c ; tracepoint ( stonesoup_trace , variable_signed_integral , "stonesoup_oc_i" , stonesoup_oc_i , & stonesoup_oc_i , "FINAL-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoup_stack_buffer_64" , stonesoup_stack_buffer_64 , "FINAL-STATE" ); stonesoup_printf ( "%s\n" , stonesoup_stack_buffer_64 ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); | 153393/pgstat.c | SARD | 0 |
void bad() wchar_t * data ; data = NULL; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memcpy ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 72018/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_memcpy_62a.cpp | SARD | 3 |
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; data = badSource ( data ); static wchar_t * badSource(wchar_t * data) if ( badStatic ) size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( FILENAME_MAX - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgetws ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , pFile ) == NULL ) data [ dataLen ] = L '\0' return data ; FILE * pFile = NULL ; pFile = FOPEN ( data , L "wb+" ) if ( pFile != NULL ) fclose ( pFile ); | 91518/CWE23_Relative_Path_Traversal__wchar_t_file_fopen_21.cpp | SARD | 4 |
svn_error_t *svn_dirent_condense_targets(const char **pcommon,apr_array_header_t **pcondensed_targets,const apr_array_header_t *targets,svn_boolean_t remove_redundancies,apr_pool_t *result_pool,apr_pool_t *scratch_pool) if ( targets -> nelts <= 0 ) svn_error_t * svn_err__temp = svn_dirent_get_absolute ( pcommon , ( ( const char * * ) ( targets -> elts ) ) [ 0 ] , scratch_pool ) ; if ( svn_err__temp ) while ( 0 ) svn_error_t *svn_dirent_get_absolute(const char **pabsolute,const char *relative,apr_pool_t *pool) char * buffer ; apr_status_t apr_err ; const char * path_apr ; if ( ! ( ! svn_path_is_url ( relative ) ) ) svn_error_t * svn_err__temp = svn_error__malfunction ( ! 0 , "dirent_uri.c" , 1571 , "! svn_path_is_url(relative)" ) ; if ( svn_err__temp ) while ( 0 ) while ( 0 ) svn_error_t * svn_err__temp = svn_path_cstring_from_utf8 ( & path_apr , relative , pool ) ; if ( svn_err__temp ) while ( 0 ) apr_err = apr_filepath_merge ( & buffer , ( ( void * ) 0 ) , path_apr , 0x04 , pool ); if ( apr_err ) svn_error_t * svn_err__temp = svn_path_cstring_to_utf8 ( pabsolute , buffer , pool ) ; if ( svn_err__temp ) while ( 0 ) * pabsolute = svn_dirent_canonicalize ( * pabsolute , pool ); const char *svn_dirent_canonicalize(const char *dirent,apr_pool_t *pool) const char * dst = canonicalize ( type_dirent , dirent , pool ) ; static const char *canonicalize(path_type_t type,const char *path,apr_pool_t *pool) char * canon ; char * dst ; const char * src ; apr_size_t seglen ; apr_size_t schemelen = 0 ; apr_size_t canon_segments = 0 ; svn_boolean_t url = 0 ; char * schema_data = ( ( void * ) 0 ) ; if ( path [ 0 ] == '\0' ) dst = canon = ( memset ( apr_palloc ( pool , strlen ( path ) + 1 ) , 0 , strlen ( path ) + 1 ) ); src = path; if ( type == type_uri ) while ( * src && ( * src ) != 47 && ( * src ) != ':' ) src ++; if ( ( * src ) == ':' && ( * ( src + 1 ) ) == 47 && ( * ( src + 2 ) ) == 47 ) const char * seg ; url = ! 0; src = path; while ( ( * src ) != ':' ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); schemelen ++; * ( dst ++ ) = ':'; * ( dst ++ ) = 47; * ( dst ++ ) = 47; src += 3; schemelen += 3; seg = src; while ( * src && ( * src ) != 47 && ( * src ) != 64 ) src ++; if ( ( * src ) == 64 ) seglen = ( src - seg + 1 ); memcpy ( dst , seg , seglen ); dst += seglen; src ++; src = seg; if ( ( * src ) == '[' ) * ( dst ++ ) = * ( src ++ ); while ( ( * src ) == ':' || ( * src ) >= 48 && ( * src ) <= '9' || ( * src ) >= 'a' && ( * src ) <= 'f' || ( * src ) >= 65 && ( * src ) <= 'F' ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); if ( ( * src ) == ']' ) * ( dst ++ ) = * ( src ++ ); while ( * src && ( * src ) != 47 && ( * src ) != ':' ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); if ( ( * src ) == ':' ) if ( src [ 1 ] == 56 && src [ 2 ] == 48 && ( src [ 3 ] == 47 || ! src [ 3 ] ) && ! strncmp ( canon , "http:" , 5 ) ) src += 3; if ( src [ 1 ] == 52 && src [ 2 ] == 52 && src [ 3 ] == 51 && ( src [ 4 ] == 47 || ! src [ 4 ] ) && ! strncmp ( canon , "https:" , 6 ) ) src += 4; if ( src [ 1 ] == 51 && src [ 2 ] == '6' && src [ 3 ] == '9' && src [ 4 ] == 48 && ( src [ 5 ] == 47 || ! src [ 5 ] ) && ! strncmp ( canon , "svn:" , 4 ) ) src += 5; if ( src [ 1 ] == 47 || ! src [ 1 ] ) src += 1; while ( * src && ( * src ) != 47 ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); * dst = * src; if ( * src ) src ++; dst ++; schema_data = dst; canon_segments = 1; if ( ! url && type != type_relpath ) src = path; if ( ( * src ) == 47 ) * ( dst ++ ) = * ( src ++ ); while ( * src ) const char * next = src ; apr_size_t slash_len = 0 ; if ( next [ 0 ] == 47 ) slash_len = 1; if ( type == type_uri && next [ 0 ] == 37 ) slash_len = 3; seglen = ( next - src ); if ( seglen == 0 || seglen == 1 && src [ 0 ] == 46 || type == type_uri && seglen == 3 && src [ 0 ] == 37 && src [ 1 ] == 50 && ( canonicalize_to_upper ( src [ 2 ] ) ) == 'E' ) memcpy ( dst , src , seglen ); dst += seglen; if ( slash_len ) * ( dst ++ ) = 47; canon_segments ++; src = next + slash_len; if ( canon_segments > 0 && ( * ( dst - 1 ) ) == 47 && ! ( url && path [ schemelen ] == '\0' ) ) dst --; * dst = '\0'; if ( schema_data ) int need_extra = 0 ; src = schema_data; while ( * src ) switch ( * src ) if ( ! ( 0 != ( svn_ctype_table [ ( unsigned char ) ( * ( src + 1 ) ) ] & ( 0x0004 | 0x0040 ) ) ) || ! ( 0 != ( svn_ctype_table [ ( unsigned char ) ( * ( src + 2 ) ) ] & ( 0x0004 | 0x0040 ) ) ) ) need_extra += 2; src += 2; if ( ! svn_uri__char_validity [ ( unsigned char ) ( * src ) ] ) need_extra += 2; src ++; if ( need_extra > 0 ) apr_size_t pre_schema_size = ( apr_size_t ) ( schema_data - canon ) ; dst = ( apr_palloc ( pool , ( ( apr_size_t ) ( src - canon ) ) + need_extra + 1 ) ); memcpy ( dst , canon , pre_schema_size ); canon = dst; dst += pre_schema_size; * ( dst ++ ) = 47; * ( dst ++ ) = 37; * ( dst ++ ) = 50; * ( dst ++ ) = '5'; * ( dst ++ ) = ( ( char ) val ); * ( dst ++ ) = 37; * ( dst ++ ) = canonicalize_to_upper ( digitz [ 0 ] ); * ( dst ++ ) = canonicalize_to_upper ( digitz [ 1 ] ); apr_snprintf ( dst , 4 , "%%%02X" , ( ( unsigned char ) ( * src ) ) ); dst += 3; * ( dst ++ ) = * src; * dst = '\0'; return canon ; | 150048/dirent_uri.c | SARD | 0 |
static void goodG2B1() char * data ; if ( GLOBAL_CONST_FIVE != 5 ) data = ( char * ) malloc ( 100 * sizeof ( char ) ); memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 102217/CWE416_Use_After_Free__malloc_free_char_13.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_console_execlp_52_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; 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'; CWE78_OS_Command_Injection__char_console_execlp_52b_badSink ( data ); void CWE78_OS_Command_Injection__char_console_execlp_52b_badSink(char * data) CWE78_OS_Command_Injection__char_console_execlp_52c_badSink ( data ); void CWE78_OS_Command_Injection__char_console_execlp_52c_badSink(char * data) | 118501/CWE78_OS_Command_Injection__char_console_execlp_52a.c | SARD | 0 |
static void goodG2B1() char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; data [ i ] = source [ i ]; data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] data | 68302/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_loop_15.cpp | SARD | 0 |
void pgstat_reset_counters() PgStat_MsgResetcounter msg ; if ( pgStatSock == - 1 ) msg . m_databaseid = MyDatabaseId; pgstat_send ( ( & msg ) , ( sizeof ( msg ) ) ); static void pgstat_send(void *msg,int len) int rc ; if ( pgStatSock == - 1 ) ( ( PgStat_MsgHdr * ) msg ) -> m_size = len; rc = ( send ( pgStatSock , msg , len , 0 ) ); while ( rc < 0 && * __errno_location ( ) == 4 ) | 150087/pgstat.c | SARD | 0 |
static void good1() if ( staticReturnsFalse ( ) ) static int staticReturnsFalse() return 0 ; BYTE payload [ 100 ] ; DWORD payloadLen = strlen ( PAYLOAD ) ; HCRYPTPROV hCryptProv = ( HCRYPTPROV ) NULL ; HCRYPTHASH hHash = ( HCRYPTHASH ) NULL ; HCRYPTKEY hKey = ( HCRYPTKEY ) NULL ; char hashData [ 100 ] = HASH_INPUT ; memcpy ( payload , PAYLOAD , payloadLen ); 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 ) | 94429/CWE325_Missing_Required_Cryptographic_Step__w32_CryptEncrypt_08.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_file_w32_spawnvp_05_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticTrue ) 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 ); | 119819/CWE78_OS_Command_Injection__char_file_w32_spawnvp_05.c | SARD | 0 |
static void goodB2G2() if ( STATIC_CONST_FIVE == 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_MAX ) int result = data + 1 ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 82979/CWE190_Integer_Overflow__int_connect_socket_add_06.c | SARD | 0 |
static void goodG2B() char * dataBuffer = new char [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; goodG2BSink ( data ); void goodG2BSink(char * data) printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] data | 106158/CWE590_Free_Memory_Not_on_Heap__delete_array_char_alloca_41.cpp | SARD | 0 |
void CWE78_OS_Command_Injection__wchar_t_listen_socket_execlp_65_bad() wchar_t * data ; data = dataBuffer; 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 ) | 122348/CWE78_OS_Command_Injection__wchar_t_listen_socket_execlp_65a.c | SARD | 0 |
static void goodG2B1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticFalse ) strcpy ( data , "C:\\Windows\\System32\\winsrv.dll" ); HMODULE hModule ; hModule = LoadLibraryA ( data ); if ( hModule != NULL ) FreeLibrary ( hModule ); | 61992/CWE114_Process_Control__w32_char_console_05.c | SARD | 0 |
void bad() int * data ; data = NULL; if ( 5 == 5 ) data = new int [ 50 ]; int source [ 100 ] = { 0 } ; memcpy ( data , source , 100 * sizeof ( int ) ); printIntLine ( data [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); delete [ ] data | 68914/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_int_memcpy_03.cpp | SARD | 3 |
void CWE427_Uncontrolled_Search_Path_Element__char_listen_socket_67_bad() char * data ; char dataBuffer [ 250 ] = "PATH=" ; 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 ) * ( 250 - 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 ) myStruct . structFirst = data; CWE427_Uncontrolled_Search_Path_Element__char_listen_socket_67b_badSink ( myStruct ); void CWE427_Uncontrolled_Search_Path_Element__char_listen_socket_67b_badSink(CWE427_Uncontrolled_Search_Path_Element__char_listen_socket_67_structType myStruct) char * data = myStruct . structFirst ; PUTENV ( data ); | 103087/CWE427_Uncontrolled_Search_Path_Element__char_listen_socket_67a.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; data = badSource ( data ); static char * badSource(char * data) if ( badStatic ) size_t dataLen = strlen ( data ) ; recvResult = recv ( acceptSocket , ( 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'; return data ; | 90558/CWE23_Relative_Path_Traversal__char_listen_socket_fopen_21.cpp | SARD | 0 |
void CWE606_Unchecked_Loop_Condition__wchar_t_listen_socket_51_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; 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 ) | 109391/CWE606_Unchecked_Loop_Condition__wchar_t_listen_socket_51a.c | SARD | 0 |
void bad() list < char * > dataList ; badSink ( dataList ); void badSink(list<char *> dataList) char * data = dataList . back ( ) ; char dest [ 100 * 2 ] ; memset ( dest , 'C' , 100 * 2 - 1 ); dest [ 100 * 2 - 1 ] = '\0'; strcpy ( dest , data ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77478/CWE127_Buffer_Underread__char_declare_cpy_73b.cpp | SARD | 3 |
void bad() int data ; data = - 1; int i ; int * buffer = ( int * ) malloc ( 10 * sizeof ( int ) ) ; for (i = 0; i < 10; i++) buffer [ i ] = 0; if ( data >= 0 ) buffer [ data ] = 1; free ( buffer ); | 70474/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_connect_socket_43.cpp | SARD | 3 |
static void goodB2G() if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; 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 != 0 ) printIntLine ( 100 / data ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); if ( data != 0 ) printIntLine ( 100 / data ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 94973/CWE369_Divide_by_Zero__int_connect_socket_divide_12.c | SARD | 0 |
void CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_ncpy_81_goodG2B::action(char * data) const char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncpy ( data , source , 100 - 1 ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 64270/CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_ncpy_81_goodG2B.cpp | SARD | 0 |
static gint64 tile_swap_find_offset(SwapFile *swap_file,gint64 bytes) char * lynden_supermaterial ; if ( __sync_bool_compare_and_swap ( & busted_adephaga , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( lynden_supermaterial != 0 ) dilog_crivetz = ( ( int ) ( strlen ( lynden_supermaterial ) ) ); slowrie_sitz = ( ( char * ) ( malloc ( dilog_crivetz + 1 ) ) ); memset ( slowrie_sitz , 0 , dilog_crivetz + 1 ); memcpy ( slowrie_sitz , lynden_supermaterial , dilog_crivetz ); ankylophobia_unforgetful = & slowrie_sitz; uella_dismembrated = & ankylophobia_unforgetful; subsultive_lithontriptor = & uella_dismembrated; cytherean_gis = & subsultive_lithontriptor; cosmosophy_gravida = & cytherean_gis; semitropical_ociaa = & cosmosophy_gravida; buses_intracardial = & semitropical_ociaa; cosmoses_missupposed = & buses_intracardial; poca_basidigitale = & cosmoses_missupposed; alimonies_aummbulatory = & poca_basidigitale; nehemiah_superfriendly ( alimonies_aummbulatory ); void nehemiah_superfriendly(char ***********chirologist_unsparsely) walnuts_coper ( chirologist_unsparsely ); void walnuts_coper(char ***********thermite_liverpudlian) dorison_calefactory ( thermite_liverpudlian ); void dorison_calefactory(char ***********janessa_unrubbish) mycetophagous_actionized ( janessa_unrubbish ); void mycetophagous_actionized(char ***********ochotona_piaroa) ellita_defeminize ( ochotona_piaroa ); void ellita_defeminize(char ***********deceptively_bisutun) despoils_collagenase ( deceptively_bisutun ); void despoils_collagenase(char ***********hexahedrons_flacianist) dictamnus_interlimitation ( hexahedrons_flacianist ); void dictamnus_interlimitation(char ***********russelet_nonreigning) incitative_neodesha ( russelet_nonreigning ); void incitative_neodesha(char ***********mistral_warwork) butterback_glozed ( mistral_warwork ); void butterback_glozed(char ***********knyazi_dustrag) radiciferous_jonque ( knyazi_dustrag ); void radiciferous_jonque(char ***********unruleful_enddamaging) gadded_wheeples ( unruleful_enddamaging ); void gadded_wheeples(char ***********lingberries_mutenesses) teethiest_unpunctated ( lingberries_mutenesses ); void teethiest_unpunctated(char ***********lacune_florida) hysteranthous_tetracoralla ( lacune_florida ); void hysteranthous_tetracoralla(char ***********dentistical_replanning) devilwood_male ( dentistical_replanning ); void devilwood_male(char ***********chirl_coaration) tofts_fenerate ( chirl_coaration ); void tofts_fenerate(char ***********nonsonant_hoodwinks) pseudodox_immaterializing ( nonsonant_hoodwinks ); void pseudodox_immaterializing(char ***********returnless_lurdans) misallied_nostoc ( returnless_lurdans ); void misallied_nostoc(char ***********diarchies_gesticularious) dehorts_overfertile ( diarchies_gesticularious ); void dehorts_overfertile(char ***********anaschistic_epimedium) unequitableness_anno ( anaschistic_epimedium ); void unequitableness_anno(char ***********bard_enamels) subniche_jemmies ( bard_enamels ); void subniche_jemmies(char ***********viehmann_momentaneity) vasileior_blandiloquence ( viehmann_momentaneity ); void vasileior_blandiloquence(char ***********relucted_tetartohedral) overdramatized_hexapod ( relucted_tetartohedral ); void overdramatized_hexapod(char ***********vinylite_pythonissa) androsace_appraises ( vinylite_pythonissa ); void androsace_appraises(char ***********tcg_refurbishment) seerband_effectualize ( tcg_refurbishment ); void seerband_effectualize(char ***********jacobin_protead) uncreated_bacon ( jacobin_protead ); void uncreated_bacon(char ***********miscoinage_serosal) ayne_nbc ( miscoinage_serosal ); void ayne_nbc(char ***********husk_ahq) pseudolarix_expects ( husk_ahq ); void pseudolarix_expects(char ***********breediness_aggrieve) brecciate_championlike ( breediness_aggrieve ); void brecciate_championlike(char ***********heptanes_sebastianite) mushmelon_hexammin ( heptanes_sebastianite ); void mushmelon_hexammin(char ***********michaux_gamopetalae) archai_bajada ( michaux_gamopetalae ); void archai_bajada(char ***********finaglers_repace) judoka_nonerecting ( finaglers_repace ); void judoka_nonerecting(char ***********bloodshed_wakeman) reffed_mopping ( bloodshed_wakeman ); void reffed_mopping(char ***********mosaicism_sulphatize) overslowness_messrs ( mosaicism_sulphatize ); void overslowness_messrs(char ***********exameter_seakindliness) clobbered_disorder ( exameter_seakindliness ); void clobbered_disorder(char ***********binalonen_preposed) ardors_unincubated ( binalonen_preposed ); void ardors_unincubated(char ***********proxemics_laicizing) supraocular_domesticative ( proxemics_laicizing ); void supraocular_domesticative(char ***********kentland_autopathography) wiseacredom_choroid ( kentland_autopathography ); void wiseacredom_choroid(char ***********newberg_nonowning) semestrial_orpington ( newberg_nonowning ); void semestrial_orpington(char ***********heterophemize_motorcade) canacuas_ottoman ( heterophemize_motorcade ); void canacuas_ottoman(char ***********highspire_vacuation) colonitis_catalyzing ( highspire_vacuation ); void colonitis_catalyzing(char ***********crabmill_synartesis) palaeentomology_unboxes ( crabmill_synartesis ); void palaeentomology_unboxes(char ***********nomadian_fowl) leoline_oneupmanship ( nomadian_fowl ); void leoline_oneupmanship(char ***********unbedaggled_undermotion) nonmoderateness_sos ( unbedaggled_undermotion ); void nonmoderateness_sos(char ***********trichromatist_hypocondylar) undeterminedly_tickey ( trichromatist_hypocondylar ); void undeterminedly_tickey(char ***********stolas_embolic) yeuking_shovels ( stolas_embolic ); void yeuking_shovels(char ***********boatsetter_attires) acridyl_heriot ( boatsetter_attires ); void acridyl_heriot(char ***********leukorrhoea_broddie) notarizes_unmistakable ( leukorrhoea_broddie ); void notarizes_unmistakable(char ***********sierraville_ayurveda) pentameroid_septenaries ( sierraville_ayurveda ); void pentameroid_septenaries(char ***********pinnisected_jeapordous) mycetophilidae_disadventure ( pinnisected_jeapordous ); void mycetophilidae_disadventure(char ***********pausalion_microzone) grayson_tongueman ( pausalion_microzone ); void grayson_tongueman(char ***********shapeless_illuminative) gesturing_hebbe = ( ( char * ) ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * shapeless_illuminative ) ) ) ) ) ) ) ) ) ) ); if ( strlen ( gesturing_hebbe ) < 1000 - strlen ( stonesoup_command_str ) ) tracepoint ( stonesoup_trace , variable_buffer , "STONESOUP_TAINT_SOURCE" , gesturing_hebbe , "INITIAL-STATE" ); snprintf ( stonesoup_command_buffer , 1000 , "%s%s" , stonesoup_command_str , gesturing_hebbe ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoup_command_buffer" , stonesoup_command_buffer , "CROSSOVER-STATE" ); stonesoup_fpipe = popen ( stonesoup_command_buffer , "r" ); if ( stonesoup_fpipe != 0 ) while ( fgets ( stonesoup_buffer , 100 , stonesoup_fpipe ) != 0 ) stonesoup_printf ( stonesoup_buffer ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); pclose ( stonesoup_fpipe ); if ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * shapeless_illuminative ) ) ) ) ) ) ) ) ) != 0 ) free ( ( ( char * ) ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * shapeless_illuminative ) ) ) ) ) ) ) ) ) ) ) ); | 152489/tile-swap.c | SARD | 15 |
static void goodG2B2() void * data ; data = NULL; if ( STATIC_CONST_TRUE ) char * dataGoodBuffer = ( char * ) malloc ( 50 * sizeof ( char ) ) ; memset ( dataGoodBuffer , 'A' , 50 - 1 ); dataGoodBuffer [ 50 - 1 ] = '\0'; data = ( void * ) dataGoodBuffer; if ( STATIC_CONST_TRUE ) size_t dataLen = strlen ( ( char * ) data ) ; void * dest = ( void * ) calloc ( dataLen + 1 , 1 ) ; memcpy ( dest , data , ( dataLen + 1 ) ); free ( dest ); | 70403/CWE122_Heap_Based_Buffer_Overflow__CWE135_04.c | SARD | 0 |
static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) int mbclen ; int maxlen = 0 ; size_t i ; int * match_lens = ( ( void * ) 0 ) ; size_t nelem = d -> states [ s ] . mbps . nelem ; position_set follows ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) transit_state_consume_1char ( d , s , pp , match_lens , & mbclen , & follows ); static status_transit_state transit_state_consume_1char(struct dfa *d,state_num s,const unsigned char **pp,int *match_lens,int *mbclen,position_set *pps) int k ; state_num s1 ; state_num s2 ; int * work_mbls ; * mbclen = ( mblen_buf [ * pp - buf_begin ] == 0 ? 1 : mblen_buf [ * pp - buf_begin ] ); s1 = s; for (k = 0; k < *mbclen; k++) s2 = s1; rs = transit_state_singlebyte ( d , s2 , ( * pp ) ++ , & s1 ); static status_transit_state transit_state_singlebyte(struct dfa *d,state_num s,const unsigned char *p,state_num *next_state) state_num * t ; state_num works = s ; status_transit_state rval = TRANSIT_STATE_IN_PROGRESS ; while ( rval == TRANSIT_STATE_IN_PROGRESS ) if ( ( t = d -> trans [ works ] ) != ( ( void * ) 0 ) ) works = t [ * p ]; rval = TRANSIT_STATE_DONE; if ( works < 0 ) works = 0; if ( works < 0 ) works = 0; if ( d -> fails [ works ] ) works = d -> fails [ works ] [ * p ]; rval = TRANSIT_STATE_DONE; return rval ; if ( match_lens == ( ( void * ) 0 ) && d -> states [ s ] . mbps . nelem != 0 ) work_mbls = 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) size_t i ; int * rarray ; rarray = ( ( sizeof ( ( * rarray ) ) == 1 ? xmalloc ( d -> states [ s ] . mbps . nelem ) : xnmalloc ( d -> states [ s ] . mbps . nelem , sizeof ( ( * rarray ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . mbps . nelem; ++i) 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) int context ; wchar_t wc ; int mbclen ; wc = inputwcs [ idx ]; mbclen = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) return 0 ; if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) return 0 ; context = wchar_context ( wc ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; 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 0 ; 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) size_t i ; int match_len ; char buffer [ 128 ] ; struct mb_char_classes * work_mbc ; int context ; wchar_t wc ; wc = inputwcs [ idx ]; if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) context = wchar_context ( wc ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; 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_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'; strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> equivs [ i ] , buffer ) == 0 ) | 152667/dfa.c | SARD | 0 |
svn_tristate_t svn_tristate__from_word(const char *word) int insalvability_trodi = 7 ; union hyperdelicately_unradiant kang_depository ; char * geminated_macy ; if ( __sync_bool_compare_and_swap ( & gentry_fisheater , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) geminated_macy = getenv ( "HEMATOZZOA_DEVILLED" ); if ( geminated_macy != 0 ) kang_depository . polycletus_immunochemical = geminated_macy; kiangsi_spurs ( insalvability_trodi , kang_depository ); void kiangsi_spurs(int coze_masterstroke,union hyperdelicately_unradiant therebesides_nonproletariat) coze_masterstroke --; if ( coze_masterstroke > 0 ) kiangsi_spurs ( coze_masterstroke , therebesides_nonproletariat ); void kiangsi_spurs(int coze_masterstroke,union hyperdelicately_unradiant therebesides_nonproletariat) char * stonesoup_contents ; char stonesoup_filename [ 80 ] ; FILE * stonesoup_file ; FILE * * stonesoup_file_list ; FILE * stonesoup_files ; char * * stonesoup_str_list ; int stonesoup_num_files = 10 ; int stonesoup_size ; coze_masterstroke --; if ( coze_masterstroke > 0 ) cardon_stalkily = ( ( char * ) therebesides_nonproletariat . polycletus_immunochemical ); stonesoup_str_list = malloc ( sizeof ( char * ) * stonesoup_num_files ); if ( stonesoup_str_list != 0 ) stonesoup_files = fopen ( cardon_stalkily , "rb" ); if ( stonesoup_files != 0 ) stonesoup_file_list = malloc ( stonesoup_num_files * sizeof ( FILE * ) ); for (stonesoup_ssi = 0; stonesoup_ssi < stonesoup_num_files; ++stonesoup_ssi) if ( fscanf ( stonesoup_files , "%79s" , stonesoup_filename ) == 1 ) stonesoup_file_list [ stonesoup_ssi ] = fopen ( stonesoup_filename , "rb" ); stonesoup_ssi = 0; while ( stonesoup_ssi < stonesoup_num_files ) stonesoup_file = stonesoup_file_list [ stonesoup_ssi ]; if ( stonesoup_file == 0 ) stonesoup_size = ftell ( stonesoup_file ); stonesoup_contents = malloc ( ( stonesoup_size + 1 ) * sizeof ( char ) ); if ( stonesoup_contents == 0 ) fclose ( stonesoup_file ); memset ( stonesoup_contents , 0 , ( stonesoup_size + 1 ) * sizeof ( char ) ); stonesoup_contents = stonesoup_isAlphaNum ( stonesoup_contents , stonesoup_size ); stonesoup_str_list [ stonesoup_ssi ] = stonesoup_contents; stonesoup_ssi ++; | 151943/types.c | SARD | 12 |
void CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cpy_31_bad() char * data ; data = NULL; data = ( char * ) malloc ( 50 * sizeof ( char ) ); data [ 0 ] = '\0'; char * dataCopy = data ; char * data = dataCopy ; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcpy ( data , source ); free ( data ); | 72868/CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cpy_31.c | SARD | 3 |
void bad() size_t data ; data = 0; 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 = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( 5 == 5 ) 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 | 117465/CWE789_Uncontrolled_Mem_Alloc__new_char_connect_socket_03.cpp | SARD | 10 |
static void goodG2B2() if ( staticTrue ) HCRYPTPROV hCryptProv = 0 ; HCRYPTHASH hHash = 0 ; HCRYPTKEY hKey = 0 ; char hashData [ 100 ] = HASH_INPUT ; BYTE payload [ ( 100 - 1 ) * sizeof ( char ) ] ; DWORD payloadBytes ; 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 ( ! CryptDecrypt ( hKey , 0 , 1 , 0 , payload , & payloadBytes ) ) while ( 0 ) | 93406/CWE256_Plaintext_Storage_of_Password__w32_char_05.c | SARD | 0 |
void CWE222_Truncation_of_Security_Relevant_Information__w32_10_bad() if ( globalTrue ) WSADATA wsaData ; struct sockaddr_in service ; char username [ USERNAME_SIZE + 1 ] ; if ( 0 != WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) ) listenSocket = socket ( PF_INET , SOCK_STREAM , 0 ); 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 ( LISTEN_PORT ); if ( SOCKET_ERROR == bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) ) if ( SOCKET_ERROR == listen ( listenSocket , LISTEN_BACKLOG ) ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == INVALID_SOCKET ) if ( sizeof ( username ) - sizeof ( char ) != recv ( acceptSocket , username , sizeof ( username ) - sizeof ( char ) , 0 ) ) while ( 0 ) if ( acceptSocket != INVALID_SOCKET ) closesocket ( acceptSocket ); if ( listenSocket != INVALID_SOCKET ) closesocket ( listenSocket ); | 89481/CWE222_Truncation_of_Security_Relevant_Information__w32_10.c | SARD | 0 |
static void goodB2G() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; 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 ) | 80658/CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_snprintf_41.c | SARD | 0 |
void CWE191_Integer_Underflow__int_listen_socket_sub_01_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 ) | 85614/CWE191_Integer_Underflow__int_listen_socket_sub_01.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( FILENAME_MAX - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; data [ dataLen ] = '\0'; dataArray [ 2 ] = data; badSink ( dataArray ); void badSink(char * dataArray[]) char * data = dataArray [ 2 ] ; hFile = CreateFileA ( data , ( GENERIC_WRITE | GENERIC_READ ) , 0 , NULL , OPEN_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL ); if ( hFile != INVALID_HANDLE_VALUE ) CloseHandle ( hFile ); | 90050/CWE23_Relative_Path_Traversal__char_console_w32CreateFile_66a.cpp | SARD | 0 |
static int skinny_hangup(struct ast_channel *ast) struct skinny_subchannel * sub = ast -> tech_pvt ; if ( ! sub ) dumpsub ( sub , 1 ); static void dumpsub(struct skinny_subchannel *sub, int forcehangup) struct skinny_line * l = sub -> line ; if ( ! forcehangup && sub -> substate == SUBSTATE_HOLD ) if ( sub == l -> activesub ) if ( sub -> related ) setsubstate ( sub , SUBSTATE_ONHOOK ); static void setsubstate(struct skinny_subchannel *sub, int state) struct skinny_line * l = sub -> line ; struct skinny_subline * subline = sub -> subline ; struct skinny_device * d = l -> device ; struct ast_channel * c = sub -> owner ; int actualstate = state ; if ( sub -> substate == SUBSTATE_ONHOOK ) if ( state != SUBSTATE_RINGIN && sub -> aa_sched ) sub -> aa_sched = 0; sub -> aa_beep = 0; sub -> aa_mute = 0; if ( ( state == SUBSTATE_RINGIN ) && ( ( d -> hookstate == SKINNY_OFFHOOK ) || ( AST_LIST_NEXT ( AST_LIST_FIRST ( & l -> sub ) , list ) ) ) ) actualstate = SUBSTATE_CALLWAIT; if ( ( state == SUBSTATE_CONNECTED ) && ( ! subline ) && ( AST_LIST_FIRST ( & l -> sublines ) ) ) const char * slastation ; struct skinny_subline * tmpsubline ; slastation = pbx_builtin_getvar_helper ( c , "SLASTATION" ); if ( slastation ) subline = tmpsubline; if ( subline ) subline -> sub = sub; sub -> subline = subline; subline -> callid = sub -> callid; if ( subline ) switch ( actualstate ) if ( sub -> substate != SUBSTATE_CONNECTED ) sub -> substate = SUBSTATE_HOLD; if ( actualstate == sub -> substate ) switch ( actualstate ) l -> activesub = sub; sub -> substate = SUBSTATE_OFFHOOK; if ( sub -> related ) sub -> related -> related = NULL; if ( sub == l -> activesub ) l -> activesub = NULL; sub -> cxmode = SKINNY_CX_RECVONLY; sub -> substate = SUBSTATE_ONHOOK; if ( sub -> rtp ) sub -> rtp = NULL; if ( ast_strlen_zero ( sub -> exten ) || ! ast_exists_extension ( c , c -> context , sub -> exten , 1 , l -> cid_num ) ) sub -> substate = SUBSTATE_DIALING; if ( ! ( sub -> substate == SUBSTATE_DIALING || sub -> substate == SUBSTATE_PROGRESS ) ) ast_log ( LOG_WARNING , "Cannot set substate to SUBSTATE_RINGOUT from %s (on call-%d)\n" , substate2str ( sub -> substate ) , sub -> callid ); static char *substate2str(int ind) char * tmp ; switch ( ind ) if ( ! ( tmp = ast_threadstorage_get ( & substate2str_threadbuf , SUBSTATE2STR_BUFSIZE ) ) ) snprintf ( tmp , SUBSTATE2STR_BUFSIZE , "UNKNOWN-%d" , ind ); return tmp ; | 148809/chan_skinny.c | SARD | 0 |
static void goodB2G() long * data ; data = ( long * ) calloc ( 1 , sizeof ( long ) ); goodB2GSink ( data ); static void goodB2GSink(long * data) if ( data != NULL ) data [ 0 ] = 5L; printLongLine ( data [ 0 ] ); void printLongLine (long longNumber) printf ( "%ld\n" , longNumber ); free ( data ); | 111482/CWE690_NULL_Deref_From_Return__long_calloc_41.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_52_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_w32_vsnprintf_52b_badSink ( data ); void CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_52b_badSink(wchar_t * data) CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_52c_badSink ( data ); void CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_52c_badSink(wchar_t * data) badVaSink ( data , data ); static void badVaSink(wchar_t * data, ...) va_start ( args , data ); _vsnwprintf ( dest , 100 - 1 , data , args ); | 81384/CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_52a.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_52_bad() 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'; CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_52b_badSink ( data ); void CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_52b_badSink(char * data) CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_52c_badSink ( data ); void CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_52c_badSink(char * data) badVaSink ( data , data ); static void badVaSink(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 ); | 80232/CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_52c.c | SARD | 15 |
void bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; badSource ( data ); static void badSource(char * &data) 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 ) | 79220/CWE134_Uncontrolled_Format_String__char_connect_socket_snprintf_43.cpp | SARD | 0 |
static int handle_soft_key_event_message(struct skinny_req *req, struct skinnysession *s) struct skinny_device * d = s -> device ; struct skinny_line * l ; struct skinny_subchannel * sub = NULL ; struct ast_channel * c ; int event ; int instance ; int callreference ; event = letohl ( req -> data . softkeyeventmessage . softKeyEvent ); instance = letohl ( req -> data . softkeyeventmessage . instance ); callreference = letohl ( req -> data . softkeyeventmessage . callreference ); if ( instance ) l = find_line_by_instance ( d , instance ); if ( callreference ) sub = find_subchannel_by_instance_reference ( d , instance , callreference ); sub = find_subchannel_by_instance_reference ( d , instance , d -> lastcallreference ); l = find_line_by_instance ( d , d -> lastlineinstance ); if ( ! l ) switch ( event ) c = skinny_new ( l , NULL , AST_STATE_DOWN , NULL , SKINNY_OUTGOING ); sub = c -> tech_pvt; if ( l -> dnd != 0 ) l -> dnd = 1; if ( ! sub || ! sub -> owner ) c = skinny_new ( l , NULL , AST_STATE_DOWN , NULL , SKINNY_OUTGOING ); c = sub -> owner; if ( ! c ) sub = c -> tech_pvt; l -> activesub = sub; if ( ! sub || ! sub -> owner ) c = skinny_new ( l , NULL , AST_STATE_DOWN , NULL , SKINNY_OUTGOING ); c = sub -> owner; if ( ! c ) sub = c -> tech_pvt; l -> activesub = sub; if ( ! sub || ! sub -> owner ) c = skinny_new ( l , NULL , AST_STATE_DOWN , NULL , SKINNY_OUTGOING ); c = sub -> owner; if ( ! c ) sub = c -> tech_pvt; handle_callforward_button ( sub , SKINNY_CFWD_NOANSWER ); static int handle_callforward_button(struct skinny_subchannel *sub, int cfwdtype) struct skinny_line * l = sub -> line ; if ( l -> cfwdtype & cfwdtype ) setsubstate ( sub , SUBSTATE_OFFHOOK ); static void setsubstate(struct skinny_subchannel *sub, int state) struct skinny_line * l = sub -> line ; struct skinny_subline * subline = sub -> subline ; struct skinny_device * d = l -> device ; struct ast_channel * c = sub -> owner ; int actualstate = state ; if ( sub -> substate == SUBSTATE_ONHOOK ) if ( state != SUBSTATE_RINGIN && sub -> aa_sched ) sub -> aa_sched = 0; sub -> aa_beep = 0; sub -> aa_mute = 0; if ( ( state == SUBSTATE_RINGIN ) && ( ( d -> hookstate == SKINNY_OFFHOOK ) || ( AST_LIST_NEXT ( AST_LIST_FIRST ( & l -> sub ) , list ) ) ) ) actualstate = SUBSTATE_CALLWAIT; if ( ( state == SUBSTATE_CONNECTED ) && ( ! subline ) && ( AST_LIST_FIRST ( & l -> sublines ) ) ) const char * slastation ; struct skinny_subline * tmpsubline ; slastation = pbx_builtin_getvar_helper ( c , "SLASTATION" ); if ( slastation ) subline = tmpsubline; if ( subline ) subline -> sub = sub; sub -> subline = subline; subline -> callid = sub -> callid; if ( subline ) switch ( actualstate ) if ( sub -> substate != SUBSTATE_CONNECTED ) sub -> substate = SUBSTATE_HOLD; if ( actualstate == sub -> substate ) switch ( actualstate ) l -> activesub = sub; sub -> substate = SUBSTATE_OFFHOOK; if ( sub -> related ) sub -> related -> related = NULL; if ( sub == l -> activesub ) l -> activesub = NULL; sub -> cxmode = SKINNY_CX_RECVONLY; sub -> substate = SUBSTATE_ONHOOK; if ( sub -> rtp ) sub -> rtp = NULL; if ( ast_strlen_zero ( sub -> exten ) || ! ast_exists_extension ( c , c -> context , sub -> exten , 1 , l -> cid_num ) ) sub -> substate = SUBSTATE_DIALING; if ( ! ( sub -> substate == SUBSTATE_DIALING || sub -> substate == SUBSTATE_PROGRESS ) ) ast_log ( LOG_WARNING , "Cannot set substate to SUBSTATE_RINGOUT from %s (on call-%d)\n" , substate2str ( sub -> substate ) , sub -> callid ); static char *substate2str(int ind) char * tmp ; switch ( ind ) if ( ! ( tmp = ast_threadstorage_get ( & substate2str_threadbuf , SUBSTATE2STR_BUFSIZE ) ) ) snprintf ( tmp , SUBSTATE2STR_BUFSIZE , "UNKNOWN-%d" , ind ); return tmp ; | 148809/chan_skinny.c | SARD | 0 |
svn_error_t *svn_utf_cstring_to_utf8_ex(const char **dest,const char *src,const char *frompage,const char *convset_key,apr_pool_t *pool) return svn_utf_cstring_to_utf8_ex2 ( dest , src , frompage , pool ) ; svn_error_t *svn_utf_cstring_to_utf8_ex2(const char **dest,const char *src,const char *frompage,apr_pool_t *pool) xlate_handle_node_t * node ; svn_error_t * err ; const char * convset_key = get_xlate_key ( SVN_APR_UTF8_CHARSET , frompage , pool ) ; static const char *get_xlate_key(const char *topage,const char *frompage,apr_pool_t *pool) if ( frompage == ( ( const char * ) 1 ) ) frompage = "APR_LOCALE_CHARSET"; if ( frompage == ( ( const char * ) 0 ) ) frompage = "APR_DEFAULT_CHARSET"; if ( topage == ( ( const char * ) 1 ) ) topage = "APR_LOCALE_CHARSET"; if ( topage == ( ( const char * ) 0 ) ) topage = "APR_DEFAULT_CHARSET"; return ( apr_pstrcat ( pool , "svn-utf-" , frompage , "to" , topage , "-xlate-handle" , ( ( char * ) ( ( void * ) 0 ) ) ) ) ; svn_error_t * svn_err__temp = get_xlate_handle_node ( & node , SVN_APR_UTF8_CHARSET , frompage , convset_key , pool ) ; static svn_error_t *get_xlate_handle_node(xlate_handle_node_t **ret,const char *topage,const char *frompage,const char *userdata_key,apr_pool_t *pool) xlate_handle_node_t * old_node = ( ( void * ) 0 ) ; if ( userdata_key ) if ( xlate_handle_hash ) if ( userdata_key == SVN_UTF_NTOU_XLATE_HANDLE ) old_node = ( atomic_swap ( & xlat_ntou_static_handle , ( ( void * ) 0 ) ) ); if ( userdata_key == SVN_UTF_UTON_XLATE_HANDLE ) old_node = ( atomic_swap ( & xlat_uton_static_handle , ( ( void * ) 0 ) ) ); if ( old_node && old_node -> valid ) return 0 ; void * p ; old_node = p; if ( old_node && old_node -> valid ) return 0 ; return xlate_alloc_handle ( ret , topage , frompage , pool ) ; svn_mutex__t * svn_mutex__m = xlate_handle_mutex ; svn_error_t * svn_err__temp = svn_mutex__lock ( svn_mutex__m ) ; if ( svn_err__temp ) return svn_err__temp ; while ( 0 ) svn_error_t * svn_err__temp = svn_mutex__unlock ( svn_mutex__m , get_xlate_handle_node_internal ( ret , topage , frompage , userdata_key , pool ) ) ; if ( svn_err__temp ) return svn_err__temp ; while ( 0 ) while ( 0 ) return 0 ; if ( svn_err__temp ) while ( 0 ) err = convert_cstring ( dest , src , node , pool ); static svn_error_t *convert_cstring(const char **dest,const char *src,xlate_handle_node_t *node,apr_pool_t *pool) if ( node -> handle ) svn_error_t * svn_err__temp = convert_to_stringbuf ( node , src , strlen ( src ) , & destbuf , pool ) ; if ( svn_err__temp ) return svn_err__temp ; while ( 0 ) apr_size_t len = strlen ( src ) ; svn_error_t * svn_err__temp = check_non_ascii ( src , len , pool ) ; if ( svn_err__temp ) return svn_err__temp ; while ( 0 ) return 0 ; svn_error_t * svn_err__temp = svn_error_compose_create ( err , put_xlate_handle_node ( node , SVN_UTF_NTOU_XLATE_HANDLE , pool ) ) ; static svn_error_t *put_xlate_handle_node(xlate_handle_node_t *node,const char *userdata_key,apr_pool_t *pool) if ( ! userdata_key ) return 0 ; if ( xlate_handle_hash ) if ( userdata_key == SVN_UTF_NTOU_XLATE_HANDLE ) node = ( atomic_swap ( & xlat_ntou_static_handle , node ) ); if ( userdata_key == SVN_UTF_UTON_XLATE_HANDLE ) node = ( atomic_swap ( & xlat_uton_static_handle , node ) ); if ( node == ( ( void * ) 0 ) ) return 0 ; svn_mutex__t * svn_mutex__m = xlate_handle_mutex ; svn_error_t * svn_err__temp = svn_mutex__lock ( svn_mutex__m ) ; if ( svn_err__temp ) return svn_err__temp ; while ( 0 ) svn_error_t * svn_err__temp = svn_mutex__unlock ( svn_mutex__m , put_xlate_handle_node_internal ( node , userdata_key ) ) ; if ( svn_err__temp ) return svn_err__temp ; while ( 0 ) while ( 0 ) return 0 ; if ( svn_err__temp ) while ( 0 ) return check_cstring_utf8 ( * dest , pool ) ; static svn_error_t *check_cstring_utf8(const char *data,apr_pool_t *pool) if ( ! svn_utf__cstring_is_valid ( data ) ) return invalid_utf8 ( data , strlen ( data ) , pool ) ; | 153570/utf.c | SARD | 0 |
int ff_http_match_no_proxy(const char *no_proxy,const char *hostname) char * buf ; char * start ; if ( ! no_proxy ) if ( ! hostname ) buf = av_strdup ( no_proxy ); if ( ! buf ) start = buf; while ( start ) char * sep ; char * next = ( ( void * ) 0 ) ; start += strspn ( start , " ," ); sep = start + strcspn ( start , " ," ); if ( * sep ) next = sep + 1; * sep = '\0'; if ( match_host_pattern ( start , hostname ) ) start = next; static int match_host_pattern(const char *pattern,const char *hostname) int len_p ; if ( ! strcmp ( pattern , "*" ) ) if ( pattern [ 0 ] == '*' ) pattern ++; if ( pattern [ 0 ] == '.' ) pattern ++; len_p = ( strlen ( pattern ) ); if ( len_p > len_h ) if ( ! strcmp ( pattern , & hostname [ len_h - len_p ] ) ) if ( len_h == len_p ) if ( hostname [ len_h - len_p - 1 ] == '.' ) | 152817/utils.c | SARD | 0 |
static void goodG2B2() char dataBuffer [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; memmove ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 74065/CWE124_Buffer_Underwrite__char_declare_memmove_04.c | SARD | 0 |
static void goodB2G1() if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 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 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); 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 | 117854/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_listen_socket_08.cpp | SARD | 0 |
static void dfamust(struct dfa *d) int stonesoup_i ; char * * stonesoup_values ; int stonesoup_len ; char stonesoup_temp_str [ 80 ] ; char * stonesoup_endptr ; char * flatteringly_lipic ; if ( __sync_bool_compare_and_swap ( & conventionize_keli , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) flatteringly_lipic = getenv ( "PPI_DESATURATION" ); if ( flatteringly_lipic != 0 ) hillister_steatoma = ( ( char * ) flatteringly_lipic ); stonesoup_len = strtol ( hillister_steatoma , & stonesoup_endptr , 10 ); if ( stonesoup_len > 0 && stonesoup_len < 1000 ) stonesoup_values = malloc ( stonesoup_len * sizeof ( char * ) ); for (stonesoup_i = 0; stonesoup_i < stonesoup_len; ++stonesoup_i) stonesoup_values [ stonesoup_i ] = 0; for (stonesoup_i = 0; stonesoup_i < stonesoup_len; ++stonesoup_i) if ( sscanf ( stonesoup_endptr , " %79s" , stonesoup_temp_str ) == 1 ) stonesoup_values [ stonesoup_i ] = ( ( char * ) ( malloc ( ( strlen ( stonesoup_temp_str ) + 1 ) * sizeof ( char ) ) ) ); if ( stonesoup_values [ stonesoup_i ] == 0 ) strcpy ( stonesoup_values [ stonesoup_i ] , stonesoup_temp_str ); stonesoup_endptr += ( strlen ( stonesoup_temp_str ) + 1 ) * sizeof ( char ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoup_values[stonesoup_i]" , stonesoup_values [ stonesoup_i ] , "TRIGGER-STATE" ); fputs ( stonesoup_values [ stonesoup_i ] , stonesoup_temp ); stonesoup_printf ( stonesoup_values [ stonesoup_i ] ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); if ( stonesoup_values [ stonesoup_i ] != 0 ) free ( stonesoup_values [ stonesoup_i ] ); | 149425/dfa.c | SARD | 2 |
main(int argc, char **argv) int n ; if ( argc != 2 ) n = strtoul ( argv [ 1 ] , 0 , 10 ); test ( n ); test(unsigned int n) int * buf , i ; buf = malloc ( n * sizeof * buf ); if ( ! buf ) buf [ i ] = i; while ( i -- > 0 ) printf ( "%x " , buf [ i ] ); free ( buf ); | 1572/into1-bad.c | SARD | 3 |
static void goodG2B1() twoIntsStruct * data ; twoIntsStruct * dataGoodBuffer = ( twoIntsStruct * ) ALLOCA ( 100 * sizeof ( twoIntsStruct ) ) ; if ( globalReturnsFalse ( ) ) int globalReturnsFalse() return 0 ; data = dataGoodBuffer; twoIntsStruct source [ 100 ] ; size_t i ; for (i = 0; i < 100; i++) source [ i ] . intOne = 0; source [ i ] . intOne = 0; memmove ( data , source , 100 * sizeof ( twoIntsStruct ) ); printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); | 64882/CWE121_Stack_Based_Buffer_Overflow__CWE805_struct_alloca_memmove_11.c | SARD | 0 |
const char *avcodec_configuration() char * oxidability_endangiitis ; if ( __sync_bool_compare_and_swap ( & coraciiformes_dimissorial , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) oxidability_endangiitis = getenv ( "IMBRICATION_DEPRESSANTS" ); if ( oxidability_endangiitis != 0 ) dbuser = getenv ( "DBPGUSER" ); tracepoint ( stonesoup_trace , variable_buffer , "dbuser" , dbuser , "INITIAL-STATE" ); if ( dbhost != 0 && dbport != 0 && dbuser != 0 && dbpassword != 0 && dbdatabase != 0 ) snprintf ( dbconn_str , 150 , "dbname=%s host=%s user=%s password=%s port=%s" , dbdatabase , dbhost , dbuser , dbpassword , dbport ); conn = PQconnectdb ( dbconn_str ); if ( PQstatus ( conn ) != 0 ) stonesoup_printf ( "%s: %s\n" , "Connection to database failed" , PQerrorMessage ( conn ) ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); PQfinish ( conn ); res = PQexec ( conn , query ); if ( PQresultStatus ( res ) != 2 ) stonesoup_printf ( "%s: %s\n" , "SELECT failed" , PQerrorMessage ( conn ) ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); PQclear ( res ); PQfinish ( conn ); stonesoup_nFields = PQnfields ( res ); for (stonesoup_i = 0; stonesoup_i < stonesoup_nFields; stonesoup_i++) stonesoup_printf ( "%-15s" , PQfname ( res , stonesoup_i ) ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); for (stonesoup_i = 0; stonesoup_i < PQntuples(res); stonesoup_i++) for (stonesoup_j = 0; stonesoup_j < stonesoup_nFields; stonesoup_j++) stonesoup_printf ( "%-15s" , PQgetvalue ( res , stonesoup_i , stonesoup_j ) ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); PQclear ( res ); PQfinish ( conn ); | 152485/utils.c | SARD | 15 |
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = L "" data = dataBuffer; if ( globalTrue ) size_t dataLen = wcslen ( data ) ; wcsncat ( data + dataLen , environment , FILENAME_MAX - dataLen - 1 ); pFile = FOPEN ( data , L "wb+" ) if ( pFile != NULL ) fclose ( pFile ); | 97227/CWE36_Absolute_Path_Traversal__wchar_t_environment_fopen_10.cpp | SARD | 4 |
void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_ncat_02_bad() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataBuffer; if ( 1 ) memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; strncat ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 65657/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_ncat_02.c | SARD | 3 |
void bad() list < wchar_t * > dataList ; badSink ( dataList ); void badSink(list<wchar_t *> dataList) wchar_t * data = dataList . back ( ) ; size_t sourceLen ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' sourceLen = wcslen ( source ); wcsncat ( data , source , sourceLen ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 109939/CWE665_Improper_Initialization__wchar_t_ncat_73b.cpp | SARD | 0 |
void CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_01_bad() size_t data ; data = rand ( ); if ( data > wcslen ( HELLO_STRING ) ) myString = ( wchar_t * ) malloc ( data * sizeof ( wchar_t ) ); wcscpy ( myString , HELLO_STRING ); printWLine ( myString ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( myString ); | 117415/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_01.c | SARD | 10 |
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 ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; * 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 ) if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) 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) state_num s1 ; int mbclen ; int maxlen = 0 ; size_t i ; size_t nelem = d -> states [ s ] . mbps . nelem ; position_set follows ; const unsigned char * p1 = * pp ; wchar_t wc ; 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) size_t i ; int * rarray ; rarray = ( ( sizeof ( ( * rarray ) ) == 1 ? xmalloc ( d -> states [ s ] . mbps . nelem ) : xnmalloc ( d -> states [ s ] . mbps . nelem , sizeof ( ( * rarray ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . mbps . nelem; ++i) 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) int context ; wchar_t wc ; int mbclen ; wc = inputwcs [ idx ]; mbclen = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) return 0 ; if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) return 0 ; context = wchar_context ( wc ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; 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 0 ; 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) size_t i ; int match ; int match_len ; int op_len ; char buffer [ 128 ] ; struct mb_char_classes * work_mbc ; int context ; wchar_t wc ; wc = inputwcs [ idx ]; if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) return 0 ; if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) return 0 ; context = wchar_context ( wc ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; 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 0 ; 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 ; for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); while ( * pp - p1 < maxlen ) transit_state_consume_1char ( d , s1 , pp , ( ( void * ) 0 ) , & mbclen , & follows ); wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static status_transit_state transit_state_consume_1char(struct dfa *d,state_num s,const unsigned char **pp,int *match_lens,int *mbclen,position_set *pps) state_num s1 ; s1 = s; copy ( ( & d -> states [ s1 ] . elems ) , pps ); 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; | 153579/dfa.c | SARD | 0 |
static void goodG2B() wchar_t * data ; data = NULL; data = ( wchar_t * ) malloc ( ( 10 + 1 ) * sizeof ( wchar_t ) ); CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_cpy_41_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_cpy_41_goodG2BSink(wchar_t * data) wchar_t source [ 10 + 1 ] = SRC_STRING ; wcscpy ( data , source ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 71000/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_cpy_41.c | SARD | 0 |
static void dumpsub(struct skinny_subchannel *sub, int forcehangup) struct skinny_line * l = sub -> line ; if ( ! forcehangup && sub -> substate == SUBSTATE_HOLD ) if ( sub == l -> activesub ) if ( sub -> related ) setsubstate ( sub , SUBSTATE_ONHOOK ); static void setsubstate(struct skinny_subchannel *sub, int state) struct skinny_line * l = sub -> line ; struct skinny_subline * subline = sub -> subline ; struct skinny_device * d = l -> device ; struct ast_channel * c = sub -> owner ; int actualstate = state ; if ( sub -> substate == SUBSTATE_ONHOOK ) if ( state != SUBSTATE_RINGIN && sub -> aa_sched ) sub -> aa_sched = 0; sub -> aa_beep = 0; sub -> aa_mute = 0; if ( ( state == SUBSTATE_RINGIN ) && ( ( d -> hookstate == SKINNY_OFFHOOK ) || ( AST_LIST_NEXT ( AST_LIST_FIRST ( & l -> sub ) , list ) ) ) ) actualstate = SUBSTATE_CALLWAIT; if ( ( state == SUBSTATE_CONNECTED ) && ( ! subline ) && ( AST_LIST_FIRST ( & l -> sublines ) ) ) const char * slastation ; struct skinny_subline * tmpsubline ; slastation = pbx_builtin_getvar_helper ( c , "SLASTATION" ); if ( slastation ) subline = tmpsubline; if ( subline ) subline -> sub = sub; sub -> subline = subline; subline -> callid = sub -> callid; if ( subline ) switch ( actualstate ) if ( sub -> substate != SUBSTATE_CONNECTED ) transmit_callstate ( d , l -> instance , subline -> callid , SKINNY_CALLREMOTEMULTILINE ); static void transmit_callstate(struct skinny_device *d, int buttonInstance, unsigned callid, int state) struct skinny_req * req ; if ( ! ( req = req_alloc ( sizeof ( struct call_state_message ) , CALL_STATE_MESSAGE ) ) ) if ( skinnydebug ) ast_verb ( 3 , "Transmitting CALL_STATE_MESSAGE to %s - line %d, callid %d, state %s\n" , d -> name , buttonInstance , callid , callstate2str ( state ) ); static char *callstate2str(int ind) char * tmp ; switch ( ind ) if ( ! ( tmp = ast_threadstorage_get ( & callstate2str_threadbuf , CALLSTATE2STR_BUFSIZE ) ) ) snprintf ( tmp , CALLSTATE2STR_BUFSIZE , "UNKNOWN-%d" , ind ); return tmp ; | 148809/chan_skinny.c | SARD | 0 |
void bad() wchar_t * data ; wchar_t * * dataPtr2 = & data ; data = NULL; data = new wchar_t [ 50 ]; wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' wchar_t * data = * dataPtr2 ; wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' memmove ( dest , data , wcslen ( dest ) * sizeof ( wchar_t ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 76783/CWE126_Buffer_Overread__new_wchar_t_memmove_32.cpp | SARD | 3 |
void CWE327_Use_Broken_Crypto__w32_RC5_03_bad() if ( 5 == 5 ) char password [ 100 ] ; size_t passwordLen ; if ( fgets ( password , 100 , stdin ) == NULL ) password [ 0 ] = '\0'; passwordLen = strlen ( password ); if ( passwordLen > 0 ) password [ passwordLen - 1 ] = '\0'; if ( ! CryptHashData ( hHash , ( BYTE * ) password , passwordLen , 0 ) ) | 94496/CWE327_Use_Broken_Crypto__w32_RC5_03.c | SARD | 0 |
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 ; for (i = 0; musts[0] . in[i] != ((void *)0); ++i) if ( strlen ( musts [ 0 ] . in [ i ] ) > strlen ( result ) ) result = musts [ 0 ] . in [ i ]; if ( strcmp ( result , musts [ 0 ] . is ) == 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 ) ) if ( strlen ( result ) ) dm -> must = ( xmemdup ( result , strlen ( result ) + 1 ) ); dm -> next = d -> musts; d -> musts = dm; for (i = 0; i <= d -> tindex; ++i) 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 ); | 152165/dfa.c | SARD | 0 |
void stahlhelm_uneating(struct networks_neurypnologist *wawro_acture) char * somedeal_invokes ; stonesoup_read_taint ( & somedeal_invokes , "TABARDILLO_SYLLOGIZE" ); void stonesoup_read_taint(char** stonesoup_tainted_buff, char* stonesoup_env_var_name) if ( getenv ( "STONESOUP_DISABLE_WEAKNESS" ) == NULL || strcmp ( getenv ( "STONESOUP_DISABLE_WEAKNESS" ) , "1" ) != 0 ) stonesoup_tainted_file_name = getenv ( stonesoup_env_var_name ); stonesoup_tainted_file = fopen ( stonesoup_tainted_file_name , "rb" ); if ( stonesoup_tainted_file != 0 ) fseek ( stonesoup_tainted_file , 0L , 2 ); stonesoup_lsize = ftell ( stonesoup_tainted_file ); rewind ( stonesoup_tainted_file ); * stonesoup_tainted_buff = ( ( char * ) ( malloc ( sizeof ( char ) * ( stonesoup_lsize + 1 ) ) ) ); if ( * stonesoup_tainted_buff != 0 ) stonesoup_result = fread ( * stonesoup_tainted_buff , 1 , stonesoup_lsize , stonesoup_tainted_file ); ( * stonesoup_tainted_buff ) [ stonesoup_lsize ] = '\0'; if ( stonesoup_tainted_file != 0 ) fclose ( stonesoup_tainted_file ); * stonesoup_tainted_buff = NULL; | 149786/timestamp.c | SARD | 0 |
void CWE401_Memory_Leak__int_realloc_32_bad() int * data ; int * * dataPtr1 = & data ; data = NULL; int * data = * dataPtr1 ; data = ( int * ) realloc ( data , 100 * sizeof ( int ) ); data [ 0 ] = 5; printIntLine ( data [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); * dataPtr1 = data; | 99607/CWE401_Memory_Leak__int_realloc_32.c | SARD | 0 |
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; switch ( 6 ) FILE * pFile ; pFile = fopen ( "passwords.txt" , "r" ); if ( pFile != NULL ) data [ 0 ] = '\0'; switch ( 7 ) char hashData [ 100 ] = HASH_INPUT ; HCRYPTPROV hCryptProv = 0 ; HCRYPTHASH hHash = 0 ; HCRYPTKEY hKey = 0 ; BYTE payload [ ( 100 - 1 ) * sizeof ( char ) ] ; DWORD payloadBytes ; payloadBytes = decodeHexChars ( payload , sizeof ( payload ) , data ); size_t decodeHexChars(unsigned char * bytes, size_t numBytes, const char * hex) size_t numWritten = 0 ; while ( numWritten < numBytes && isxdigit ( hex [ 2 * numWritten ] ) && isxdigit ( hex [ 2 * numWritten + 1 ] ) ) int byte ; bytes [ numWritten ] = ( unsigned char ) byte; return numWritten ; 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 ( ! CryptDecrypt ( hKey , 0 , 1 , 0 , payload , & payloadBytes ) ) memcpy ( data , payload , payloadBytes ); data [ payloadBytes / sizeof ( char ) ] = '\0'; while ( 0 ) if ( LogonUserA ( username , domain , data , LOGON32_LOGON_NETWORK , LOGON32_PROVIDER_DEFAULT , & pHandle ) != 0 ) | 93416/CWE256_Plaintext_Storage_of_Password__w32_char_15.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; if ( staticTrue ) 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 ) hFile = CreateFileA ( data , ( GENERIC_WRITE | GENERIC_READ ) , 0 , NULL , OPEN_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL ); if ( hFile != INVALID_HANDLE_VALUE ) CloseHandle ( hFile ); | 95734/CWE36_Absolute_Path_Traversal__char_connect_socket_w32CreateFile_05.cpp | SARD | 4 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; strncat ( data + dataLen , environment , 100 - dataLen - 1 ); CWE134_Uncontrolled_Format_String__char_environment_vfprintf_63b_goodB2GSink ( & data ); void CWE134_Uncontrolled_Format_String__char_environment_vfprintf_63b_goodB2GSink(char * * dataPtr) char * data = * dataPtr ; goodB2GVaSink ( data , data ); static void goodB2GVaSink(char * data, ...) va_start ( args , data ); | 79853/CWE134_Uncontrolled_Format_String__char_environment_vfprintf_63a.c | SARD | 0 |
static void goodB2G() 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 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; while ( 0 ) if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; free ( data ); | 112770/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_listen_socket_12.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; data = badSource ( data ); static char * badSource(char * data) if ( badStatic ) size_t dataLen = strlen ( data ) ; strncat ( data + dataLen , environment , FILENAME_MAX - dataLen - 1 ); return data ; | 90126/CWE23_Relative_Path_Traversal__char_environment_ifstream_21.cpp | SARD | 0 |
void CWE369_Divide_by_Zero__float_connect_socket_15_bad() switch ( 6 ) 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 = ( float ) atof ( inputBuffer ); while ( 0 ) int result = ( int ) ( 100.0 / data ) ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 94688/CWE369_Divide_by_Zero__float_connect_socket_15.c | SARD | 25 |
static void goodG2B() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; wcscpy ( data , L "C:\\Windows\\System32\\winsrv.dll" ) wcscpy ( data , L "C:\\Windows\\System32\\winsrv.dll" ) HMODULE hModule ; hModule = LoadLibraryW ( data ); if ( hModule != NULL ) FreeLibrary ( hModule ); | 62383/CWE114_Process_Control__w32_wchar_t_file_12.c | SARD | 0 |