func
stringlengths 181
23.6k
| path
stringlengths 12
123
| source
stringclasses 2
values | label
int64 0
40
|
---|---|---|---|
static void goodB2G() size_t data ; data = 0; data = goodB2GSource ( data ); static size_t goodB2GSource(size_t data) 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 ) return data ; if ( data > wcslen ( HELLO_STRING ) && data < 100 ) | 117728/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_connect_socket_42.cpp | SARD | 0 |
void bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; CWE134_Uncontrolled_Format_String__char_connect_socket_w32_vsnprintf_84_bad * badObject = new CWE134_Uncontrolled_Format_String__char_connect_socket_w32_vsnprintf_84_bad ( data ) ; CWE134_Uncontrolled_Format_String__char_connect_socket_w32_vsnprintf_84_bad::CWE134_Uncontrolled_Format_String__char_connect_socket_w32_vsnprintf_84_bad(char * dataCopy) data = dataCopy; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 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 ) | 79385/CWE134_Uncontrolled_Format_String__char_connect_socket_w32_vsnprintf_84_bad.cpp | SARD | 0 |
void CWE127_Buffer_Underread__CWE839_fgets_31_bad() char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); int dataCopy = data ; int data = dataCopy ; if ( data < 10 ) printIntLine ( buffer [ data ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 77118/CWE127_Buffer_Underread__CWE839_fgets_31.c | SARD | 3 |
void CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_61_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; data = CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_61b_badSource ( data ); wchar_t * CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_61b_badSource(wchar_t * data) size_t dataLen = wcslen ( data ) ; wchar_t * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) wcsncat ( data + dataLen , environment , 100 - dataLen - 1 ); return data ; | 81387/CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_61b.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncat_81_goodG2B::action(wchar_t * data) const wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcsncat ( data , source , 100 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 72124/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncat_81_goodG2B.cpp | SARD | 0 |
void CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_fgets_18_bad() size_t data ; data = 0; char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = strtoul ( inputBuffer , NULL , 0 ); wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) ) myString = ( wchar_t * ) malloc ( data * sizeof ( wchar_t ) ); wcscpy ( myString , HELLO_STRING ); free ( myString ); | 117288/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_fgets_18.c | SARD | 10 |
static void goodB2G1() if ( GLOBAL_CONST_TRUE ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( data >= 0 && data < ( 10 ) ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); delete [ ] buffer | 67528/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE129_connect_socket_09.cpp | SARD | 0 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( sscanf ( data , "%d" , & n ) == 1 ) if ( sscanf ( data , "%d" , & n ) == 1 ) | 109133/CWE606_Unchecked_Loop_Condition__char_listen_socket_12.c | SARD | 0 |
void CWE427_Uncontrolled_Search_Path_Element__char_file_09_bad() char * data ; char dataBuffer [ 250 ] = "PATH=" ; data = dataBuffer; if ( GLOBAL_CONST_TRUE ) size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 250 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 250 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; fclose ( pFile ); PUTENV ( data ); | 103008/CWE427_Uncontrolled_Search_Path_Element__char_file_09.c | SARD | 9 |
static void goodG2B() char dataBuffer [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; CWE127_Buffer_Underread__char_declare_ncpy_41_goodG2BSink ( data ); void CWE127_Buffer_Underread__char_declare_ncpy_41_goodG2BSink(char * data) strncpy ( dest , data , strlen ( dest ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77624/CWE127_Buffer_Underread__char_declare_ncpy_41.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__wchar_t_file_vfprintf_68_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) fclose ( pFile ); | 81586/CWE134_Uncontrolled_Format_String__wchar_t_file_vfprintf_68a.c | SARD | 0 |
void CWE416_Use_After_Free__return_freed_ptr_16_bad() while ( 1 ) char * reversedString = helperBad ( "BadSink" ) ; static char * helperBad(char * aString) 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 ); return reversedString ; | 102661/CWE416_Use_After_Free__return_freed_ptr_16.c | SARD | 3 |
int svn_cmdline_init(const char *progname,FILE *error_stream) struct stat st ; if ( fstat ( 0 , & st ) == - 1 && open ( "/dev/null" , 0 ) == - 1 || fstat ( 1 , & st ) == - 1 && open ( "/dev/null" , 01 ) == - 1 || fstat ( 2 , & st ) == - 1 && open ( "/dev/null" , 01 ) == - 1 ) if ( ! setlocale ( __LC_ALL , "" ) && ! setlocale ( __LC_CTYPE , "" ) ) if ( error_stream ) const char * env_vars [ ] = { "LC_ALL" , "LC_CTYPE" , "LANG" , ( ( ( void * ) 0 ) ) } ; const char * * env_var = & env_vars [ 0 ] ; while ( * env_var ) env_val = ( getenv ( * env_var ) ); if ( env_val && env_val [ 0 ] ) fprintf ( error_stream , "%s: warning: cannot set LC_CTYPE locale\n%s: warning: environment variable %s is %s\n%s: warning: please check that your locale name is correct\n" , progname , progname , * env_var , env_val , progname ); if ( error_stream ) fprintf ( error_stream , "%s: error: cannot initialize APR: %s\n" , progname , buf ); | 150418/cmdline.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; 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 ) * ( 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 ) | 96557/CWE36_Absolute_Path_Traversal__char_listen_socket_ifstream_12.cpp | SARD | 0 |
int CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_strncpy_22_badSource(int data) if ( CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_strncpy_22_badGlobal ) 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 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); return data ; | 88177/CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_strncpy_22b.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_cpy_54b_goodG2BSink(char * data) CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_cpy_54c_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_cpy_54c_goodG2BSink(char * data) CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_cpy_54d_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_cpy_54d_goodG2BSink(char * data) CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_cpy_54e_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_cpy_54e_goodG2BSink(char * data) char source [ 10 + 1 ] = SRC_STRING ; strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 70768/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_cpy_54e.c | SARD | 0 |
static void goodG2B() char dataGoodBuffer [ 100 ] ; memset ( dataGoodBuffer , 'A' , 100 - 1 ); dataGoodBuffer [ 100 - 1 ] = '\0'; data = dataGoodBuffer; 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 ); | 76153/CWE126_Buffer_Overread__char_declare_memcpy_18.c | SARD | 0 |
void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_18_bad() 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 ) while ( 0 ) | 110329/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_18.c | SARD | 0 |
void CWE427_Uncontrolled_Search_Path_Element__wchar_t_listen_socket_05_bad() wchar_t * data ; wchar_t dataBuffer [ 250 ] = L "PATH=" data = dataBuffer; if ( staticTrue ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 ) * ( 250 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 103292/CWE427_Uncontrolled_Search_Path_Element__wchar_t_listen_socket_05.c | SARD | 0 |
void *stonesoup_calc_data (void *data) struct stonesoup_queue * ssQ ; ssQ = get_instance ( NULL ); struct stonesoup_queue *get_instance (char* file2) static struct stonesoup_queue * ssQ = NULL ; if ( ssQ == NULL ) if ( file2 != NULL ) stonesoup_readFile ( file2 ); void stonesoup_readFile(char *filename) FILE * fifo ; fifo = fopen ( filename , "r" ); if ( fifo != NULL ) while ( ( ch = fgetc ( fifo ) ) != EOF ) stonesoup_printf ( "%c" , ch ); fclose ( fifo ); | 149946/mux.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 = atoi ( inputBuffer ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); CWE191_Integer_Underflow__int_listen_socket_sub_64b_goodB2GSink ( & data ); void CWE191_Integer_Underflow__int_listen_socket_sub_64b_goodB2GSink(void * dataVoidPtr) int * dataPtr = ( int * ) dataVoidPtr ; int data = ( * dataPtr ) ; if ( data > INT_MIN ) int result = data - 1 ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 85650/CWE191_Integer_Underflow__int_listen_socket_sub_64a.c | SARD | 0 |
void bad() char * cryptoKey ; char cryptoKeyBuffer [ 100 ] = "" ; cryptoKey = cryptoKeyBuffer; CWE321_Hard_Coded_Cryptographic_Key__w32_char_84_bad * badObject = new CWE321_Hard_Coded_Cryptographic_Key__w32_char_84_bad ( cryptoKey ) ; CWE321_Hard_Coded_Cryptographic_Key__w32_char_84_bad::CWE321_Hard_Coded_Cryptographic_Key__w32_char_84_bad(char * cryptoKeyCopy) cryptoKey = cryptoKeyCopy; strcpy ( cryptoKey , CRYPTO_KEY ); delete badObject CWE321_Hard_Coded_Cryptographic_Key__w32_char_84_bad::~CWE321_Hard_Coded_Cryptographic_Key__w32_char_84_bad() char toBeEncrypted [ ] = "String to be encrypted" ; DWORD encryptedLen = strlen ( toBeEncrypted ) * sizeof ( char ) ; BYTE encrypted [ 200 ] ; memcpy ( encrypted , toBeEncrypted , encryptedLen ); if ( ! CryptEncrypt ( hKey , ( HCRYPTHASH ) NULL , 1 , 0 , encrypted , & encryptedLen , sizeof ( encrypted ) ) ) printBytesLine ( encrypted , encryptedLen ); void printBytesLine(const unsigned char * bytes, size_t numBytes) for (i = 0; i < numBytes; ++i) printf ( "%02x" , bytes [ i ] ); | 94337/CWE321_Hard_Coded_Cryptographic_Key__w32_char_84_bad.cpp | SARD | 31 |
static void goodB2G2() if ( staticFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; count = atoi ( inputBuffer ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); if ( count > 0 && count <= 20 ) for (i = 0; i < (size_t)count; i++) | 98919/CWE400_Resource_Exhaustion__listen_socket_for_loop_07.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_dest_wchar_t_cpy_51_bad() wchar_t * data ; data = ( wchar_t * ) malloc ( 50 * sizeof ( wchar_t ) ); CWE122_Heap_Based_Buffer_Overflow__c_dest_wchar_t_cpy_51b_badSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_dest_wchar_t_cpy_51b_badSink(wchar_t * data) wcscpy ( data , source ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 72973/CWE122_Heap_Based_Buffer_Overflow__c_dest_wchar_t_cpy_51a.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; 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 ) * ( 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 ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); badData = data; | 96526/CWE36_Absolute_Path_Traversal__char_listen_socket_fopen_45.cpp | SARD | 0 |
void CWE401_Memory_Leak__char_calloc_15_bad() char * data ; data = NULL; switch ( 6 ) data = ( char * ) calloc ( 100 , sizeof ( char ) ); strcpy ( data , "A String" ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 99215/CWE401_Memory_Leak__char_calloc_15.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; badSource ( data ); 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 ) 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 ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 96676/CWE36_Absolute_Path_Traversal__char_listen_socket_open_62b.cpp | SARD | 0 |
void CWE244_Heap_Inspection__w32_char_free_12_bad() if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; char * password = ( char * ) malloc ( 100 * sizeof ( char ) ) ; password [ 0 ] = '\0'; if ( fgets ( password , 100 , stdin ) == NULL ) password [ 0 ] = '\0'; passwordLen = strlen ( password ); if ( passwordLen > 0 ) password [ passwordLen - 1 ] = '\0'; char * password = ( char * ) malloc ( 100 * sizeof ( char ) ) ; password [ 0 ] = '\0'; if ( fgets ( password , 100 , stdin ) == NULL ) password [ 0 ] = '\0'; passwordLen = strlen ( password ); if ( passwordLen > 0 ) password [ passwordLen - 1 ] = '\0'; free ( password ); | 92009/CWE244_Heap_Inspection__w32_char_free_12.c | SARD | 0 |
static void goodB2G() size_t data ; data = 0; CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_84_goodB2G * goodB2GObject = new CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_84_goodB2G ( data ) ; CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_84_goodB2G::CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_84_goodB2G(size_t dataCopy) data = dataCopy; data = rand ( ); delete goodB2GObject CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_84_goodB2G::~CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_84_goodB2G() wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) && data < 100 ) myString = ( wchar_t * ) malloc ( data * sizeof ( wchar_t ) ); wcscpy ( myString , HELLO_STRING ); free ( myString ); | 117462/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_84_goodB2G.cpp | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; data = badSource ( data ); static char * badSource(char * data) if ( badStatic ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 89742/CWE23_Relative_Path_Traversal__char_connect_socket_open_21.cpp | SARD | 0 |
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = BASEPATH ; 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 ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); | 90946/CWE23_Relative_Path_Traversal__wchar_t_connect_socket_open_33.cpp | SARD | 0 |
static void goodG2B1() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataBuffer; data = goodG2B1Source ( data ); static char * goodG2B1Source(char * data) if ( goodG2B1Static ) memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; return data ; | 67082/CWE121_Stack_Based_Buffer_Overflow__src_char_alloca_cat_21.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; 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'; badSink ( & data ); void badSink(void * dataVoidPtr) char * * dataPtr = ( char * * ) dataVoidPtr ; char * data = ( * dataPtr ) ; hFile = CreateFileA ( data , ( GENERIC_WRITE | GENERIC_READ ) , 0 , NULL , OPEN_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL ); if ( hFile != INVALID_HANDLE_VALUE ) CloseHandle ( hFile ); | 96006/CWE36_Absolute_Path_Traversal__char_console_w32CreateFile_64a.cpp | SARD | 0 |
s32 brcmf_vif_clear_mgmt_ies(struct brcmf_cfg80211_vif *vif) s32 pktflags [ ] = { BRCMF_VNDR_IE_PRBREQ_FLAG , BRCMF_VNDR_IE_PRBRSP_FLAG , BRCMF_VNDR_IE_BEACON_FLAG } ; int i ; for (i = 0; i < ARRAY_SIZE(pktflags); i++) brcmf_vif_set_mgmt_ie ( vif , pktflags [ i ] , NULL , 0 ); s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 const u8 *vndr_ie_buf, u32 vndr_ie_len) struct vif_saved_ie * saved_ie ; u8 * iovar_ie_buf ; u8 * curr_ie_buf ; int mgmt_ie_buf_len ; u32 * mgmt_ie_len ; u32 parsed_ie_buf_len = 0 ; struct parsed_vndr_ies old_vndr_ies ; struct parsed_vndr_ies new_vndr_ies ; struct parsed_vndr_ie_info * vndrie_info ; s32 i ; int remained_buf_len ; if ( ! vif ) saved_ie = & vif -> saved_ie; iovar_ie_buf = kzalloc ( WL_EXTRA_BUF_MAX , GFP_KERNEL ); if ( ! iovar_ie_buf ) curr_ie_buf = iovar_ie_buf; switch ( pktflag ) mgmt_ie_buf = saved_ie -> probe_req_ie; mgmt_ie_len = & saved_ie -> probe_req_ie_len; mgmt_ie_buf_len = sizeof ( saved_ie -> probe_req_ie ); mgmt_ie_buf = saved_ie -> probe_res_ie; mgmt_ie_len = & saved_ie -> probe_res_ie_len; mgmt_ie_buf_len = sizeof ( saved_ie -> probe_res_ie ); mgmt_ie_buf = saved_ie -> beacon_ie; mgmt_ie_len = & saved_ie -> beacon_ie_len; mgmt_ie_buf_len = sizeof ( saved_ie -> beacon_ie ); mgmt_ie_buf = saved_ie -> assoc_req_ie; mgmt_ie_len = & saved_ie -> assoc_req_ie_len; mgmt_ie_buf_len = sizeof ( saved_ie -> assoc_req_ie ); if ( vndr_ie_len > mgmt_ie_buf_len ) if ( vndr_ie_buf && vndr_ie_len && curr_ie_buf ) for (i = 0; i < new_vndr_ies.count; i++) vndrie_info = & new_vndr_ies . ie_info [ i ]; parsed_ie_buf_len += vndrie_info -> ie_len; if ( mgmt_ie_buf && * mgmt_ie_len ) if ( parsed_ie_buf_len && ( parsed_ie_buf_len == * mgmt_ie_len ) && ( memcmp ( mgmt_ie_buf , curr_ie_buf , parsed_ie_buf_len ) == 0 ) ) for (i = 0; i < old_vndr_ies.count; i++) vndrie_info = & old_vndr_ies . ie_info [ i ]; del_add_ie_buf_len = brcmf_vndr_ie ( curr_ie_buf , pktflag , vndrie_info -> ie_ptr , vndrie_info -> ie_len , "del" ); curr_ie_buf += del_add_ie_buf_len; if ( mgmt_ie_buf && parsed_ie_buf_len ) remained_buf_len = mgmt_ie_buf_len; for (i = 0; i < new_vndr_ies.count; i++) vndrie_info = & new_vndr_ies . ie_info [ i ]; if ( remained_buf_len < ( vndrie_info -> vndrie . len + VNDR_IE_VSIE_OFFSET ) ) remained_buf_len -= ( vndrie_info -> ie_len + VNDR_IE_VSIE_OFFSET ); del_add_ie_buf_len = brcmf_vndr_ie ( curr_ie_buf , pktflag , vndrie_info -> ie_ptr , vndrie_info -> ie_len , "add" ); curr_ie_buf += del_add_ie_buf_len; static brcmf_vndr_ie(u8 *iebuf, s32 pktflag, u8 *ie_ptr, u32 ie_len, s8 *add_del_cmd) strncpy ( iebuf , add_del_cmd , VNDR_IE_CMD_LEN - 1 ); iebuf [ VNDR_IE_CMD_LEN - 1 ] = '\0'; put_unaligned_le32 ( 1 , & iebuf [ VNDR_IE_COUNT_OFFSET ] ); put_unaligned_le32 ( pktflag , & iebuf [ VNDR_IE_PKTFLAG_OFFSET ] ); memcpy ( & iebuf [ VNDR_IE_VSIE_OFFSET ] , ie_ptr , ie_len ); | CVE-2016-8658/linux_kernel_4.7.4_CVE_2016_8658_drivers_net_wireless_broadcom_brcm80211_brcmfmac_cfg80211.c | NVD | 0 |
static void goodB2G1() char * password ; char passwordBuffer [ 100 ] = "" ; password = passwordBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t passwordLen = strlen ( password ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 * ) ( password + passwordLen ) , ( 100 - passwordLen - 1 ) * sizeof ( char ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) password [ passwordLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( password , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 94116/CWE319_Cleartext_Tx_Sensitive_Info__w32_char_connect_socket_21.c | SARD | 0 |
static int CVE_2013_7008_PATCHED_decode_slice_header(H264Context *h, H264Context *h0) unsigned int first_mb_in_slice ; unsigned int pps_id ; int num_ref_idx_active_override_flag , ret ; unsigned int slice_type , tmp , i , j ; int last_pic_structure , last_pic_droppable ; int must_reinit ; int needs_reinit = 0 ; h -> me . qpel_put = h -> h264qpel . put_h264_qpel_pixels_tab; h -> me . qpel_avg = h -> h264qpel . avg_h264_qpel_pixels_tab; first_mb_in_slice = get_ue_golomb_long ( & h -> gb ); if ( first_mb_in_slice == 0 ) h0 -> current_slice = 0; if ( ! h0 -> first_field ) h -> cur_pic_ptr = NULL; slice_type = get_ue_golomb_31 ( & h -> gb ); if ( slice_type > 9 ) if ( slice_type > 4 ) slice_type -= 5; h -> slice_type_fixed = 0; slice_type = golomb_to_pict_type [ slice_type ]; h -> slice_type = slice_type; h -> slice_type_nos = slice_type & 3; h -> pict_type = h -> slice_type; pps_id = get_ue_golomb ( & h -> gb ); if ( pps_id >= MAX_PPS_COUNT ) if ( ! h0 -> pps_buffers [ pps_id ] ) h -> pps = * h0 -> pps_buffers [ pps_id ]; if ( ! h0 -> sps_buffers [ h -> pps . sps_id ] ) if ( h -> pps . sps_id != h -> current_sps_id h0 -> sps_buffers [ h -> pps . sps_id ] -> new h0 -> sps_buffers [ h -> pps . sps_id ] -> new = 0 h -> current_sps_id = h -> pps . sps_id; h -> sps = * h0 -> sps_buffers [ h -> pps . sps_id ]; if ( h -> mb_width != h -> sps . mb_width || h -> mb_height != h -> sps . mb_height * ( 2 - h -> sps . frame_mbs_only_flag ) || h -> avctx -> bits_per_raw_sample != h -> sps . bit_depth_luma || h -> cur_chroma_format_idc != h -> sps . chroma_format_idc ) needs_reinit = 1; if ( h -> bit_depth_luma != h -> sps . bit_depth_luma || h -> chroma_format_idc != h -> sps . chroma_format_idc ) h -> bit_depth_luma = h -> sps . bit_depth_luma; h -> chroma_format_idc = h -> sps . chroma_format_idc; needs_reinit = 1; if ( ( ret = h264_set_parameter_from_sps ( h ) ) < 0 ) h -> avctx -> profile = ff_h264_get_profile ( & h -> sps ); h -> avctx -> level = h -> sps . level_idc; h -> avctx -> refs = h -> sps . ref_frame_count; must_reinit = ( h -> context_initialized && ( 16 * h -> sps . mb_width != h -> avctx -> coded_width || 16 * h -> sps . mb_height * ( 2 - h -> sps . frame_mbs_only_flag ) != h -> avctx -> coded_height || h -> avctx -> bits_per_raw_sample != h -> sps . bit_depth_luma || h -> cur_chroma_format_idc != h -> sps . chroma_format_idc || av_cmp_q ( h -> sps . sar , h -> avctx -> sample_aspect_ratio ) || h -> mb_width != h -> sps . mb_width || h -> mb_height != h -> sps . mb_height * ( 2 - h -> sps . frame_mbs_only_flag ) ) ); if ( h0 -> avctx -> pix_fmt != get_pixel_format ( h0 , 0 ) ) must_reinit = 1; h -> mb_width = h -> sps . mb_width; h -> mb_height = h -> sps . mb_height * ( 2 - h -> sps . frame_mbs_only_flag ); h -> mb_num = h -> mb_width * h -> mb_height; h -> mb_stride = h -> mb_width + 1; h -> b_stride = h -> mb_width * 4; h -> chroma_y_shift = h -> sps . chroma_format_idc <= 1; h -> width = 16 * h -> mb_width; h -> height = 16 * h -> mb_height; ret = init_dimensions ( h ); if ( ret < 0 ) if ( h -> sps . video_signal_type_present_flag ) h -> avctx -> color_range = h -> sps . full_range > 0 ? AVCOL_RANGE_JPEG : AVCOL_RANGE_MPEG; if ( h -> sps . colour_description_present_flag ) if ( h -> avctx -> colorspace != h -> sps . colorspace ) needs_reinit = 1; h -> avctx -> color_primaries = h -> sps . color_primaries; h -> avctx -> color_trc = h -> sps . color_trc; h -> avctx -> colorspace = h -> sps . colorspace; if ( h -> context_initialized && ( h -> width != h -> avctx -> coded_width || h -> height != h -> avctx -> coded_height || must_reinit || needs_reinit ) ) if ( h != h0 ) if ( ( ret = get_pixel_format ( h , 1 ) ) < 0 ) h -> avctx -> pix_fmt = ret; if ( ( ret = h264_slice_header_init ( h , 1 ) ) < 0 ) if ( ! h -> context_initialized ) if ( h != h0 ) if ( ( ret = get_pixel_format ( h , 1 ) ) < 0 ) h -> avctx -> pix_fmt = ret; if ( ( ret = h264_slice_header_init ( h , 0 ) ) < 0 ) if ( h == h0 && h -> dequant_coeff_pps != pps_id ) h -> dequant_coeff_pps = pps_id; h -> frame_num = get_bits ( & h -> gb , h -> sps . log2_max_frame_num ); h -> mb_mbaff = 0; h -> mb_aff_frame = 0; last_pic_structure = h0 -> picture_structure; last_pic_droppable = h0 -> droppable; h -> droppable = h -> nal_ref_idc == 0; if ( h -> sps . frame_mbs_only_flag ) h -> picture_structure = PICT_FRAME; if ( ! h -> sps . direct_8x8_inference_flag && slice_type == AV_PICTURE_TYPE_B ) if ( get_bits1 ( & h -> gb ) ) h -> picture_structure = PICT_TOP_FIELD + get_bits1 ( & h -> gb ); h -> picture_structure = PICT_FRAME; h -> mb_aff_frame = h -> sps . mb_aff; h -> mb_field_decoding_flag = h -> picture_structure != PICT_FRAME; if ( h0 -> current_slice != 0 ) if ( h -> frame_num != h -> prev_frame_num && h -> prev_frame_num >= 0 ) int unwrap_prev_frame_num = h -> prev_frame_num ; int max_frame_num = 1 << h -> sps . log2_max_frame_num ; if ( unwrap_prev_frame_num > h -> frame_num ) unwrap_prev_frame_num -= max_frame_num; if ( ( h -> frame_num - unwrap_prev_frame_num ) > h -> sps . ref_frame_count ) unwrap_prev_frame_num = ( h -> frame_num - h -> sps . ref_frame_count ) - 1; if ( unwrap_prev_frame_num < 0 ) unwrap_prev_frame_num += max_frame_num; h -> prev_frame_num = unwrap_prev_frame_num; if ( h0 -> first_field ) if ( ! FIELD_PICTURE ( h ) || h -> picture_structure == last_pic_structure ) if ( h0 -> cur_pic_ptr -> frame_num != h -> frame_num ) if ( ! ( ( last_pic_structure == PICT_TOP_FIELD && h -> picture_structure == PICT_BOTTOM_FIELD ) || ( last_pic_structure == PICT_BOTTOM_FIELD && h -> picture_structure == PICT_TOP_FIELD ) ) ) if ( last_pic_droppable != h -> droppable ) h -> picture_structure = last_pic_structure; h -> droppable = last_pic_droppable; while ( h -> frame_num != h -> prev_frame_num && h -> prev_frame_num >= 0 && ! h0 -> first_field && h -> frame_num != ( h -> prev_frame_num + 1 ) % ( 1 << h -> sps . log2_max_frame_num ) ) if ( ! h -> sps . gaps_in_frame_num_allowed_flag ) for(i=0; i<FF_ARRAY_ELEMS(h->last_pocs); i++) h -> last_pocs [ i ] = INT_MIN; if ( h264_frame_start ( h ) < 0 ) h -> prev_frame_num ++; h -> prev_frame_num %= 1 << h -> sps . log2_max_frame_num; h -> cur_pic_ptr -> frame_num = h -> prev_frame_num; if ( ( ret = ff_generate_sliding_window_mmcos ( h , 1 ) ) < 0 && h -> avctx -> err_recognition & AV_EF_EXPLODE ) if ( ff_h264_execute_ref_pic_marking ( h , h -> mmco , h -> mmco_index ) < 0 && ( h -> avctx -> err_recognition & AV_EF_EXPLODE ) ) if ( h0 -> first_field ) assert ( h0 -> cur_pic_ptr -> f . data [ 0 ] ); | CVE-2013-7008/CVE_2013_7008_PATCHED_decode_slice_header.c | NVD | 0 |
void CWE134_Uncontrolled_Format_String__char_file_fprintf_32_bad() char * data ; char * * dataPtr1 = & data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; char * data = * dataPtr1 ; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 79983/CWE134_Uncontrolled_Format_String__char_file_fprintf_32.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) svn_cmdline__config_argument_t * config_option ; const char * first_colon ; const char * second_colon ; const char * equals_sign ; 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 = ( memset ( apr_palloc ( pool , sizeof ( ( * config_option ) ) ) , 0 , sizeof ( ( * config_option ) ) ) ); 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 |
void CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_strncpy_41_goodG2BSink(int data) char source [ 100 ] ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 87606/CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_strncpy_41.c | SARD | 0 |
static void goodB2G() char * data ; data = ( char * ) malloc ( 20 * sizeof ( char ) ); CWE690_NULL_Deref_From_Return__char_malloc_53b_goodB2GSink ( data ); void CWE690_NULL_Deref_From_Return__char_malloc_53b_goodB2GSink(char * data) CWE690_NULL_Deref_From_Return__char_malloc_53c_goodB2GSink ( data ); void CWE690_NULL_Deref_From_Return__char_malloc_53c_goodB2GSink(char * data) CWE690_NULL_Deref_From_Return__char_malloc_53d_goodB2GSink ( data ); void CWE690_NULL_Deref_From_Return__char_malloc_53d_goodB2GSink(char * data) if ( data != NULL ) strcpy ( data , "Initialize" ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 111057/CWE690_NULL_Deref_From_Return__char_malloc_53a.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 ; * 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; build_state ( works , d ); static void build_state(state_num s,struct dfa *d) state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) free ( d -> trans [ i ] ); d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); | 153172/dfa.c | SARD | 0 |
static void goodB2G() int i , k ; char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; for(i = 0; i < 1; i++) 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 ) | 79210/CWE134_Uncontrolled_Format_String__char_connect_socket_snprintf_17.c | SARD | 0 |
static void goodB2G2() size_t data ; data = 0; if ( STATIC_CONST_TRUE ) data = rand ( ); if ( STATIC_CONST_TRUE ) char * myString ; if ( data > strlen ( HELLO_STRING ) && data < 100 ) myString = ( char * ) malloc ( data * sizeof ( char ) ); strcpy ( myString , HELLO_STRING ); free ( myString ); | 117178/CWE789_Uncontrolled_Mem_Alloc__malloc_char_rand_04.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fscanf_34_bad() int data ; CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fscanf_34_unionType myUnion ; data = - 1; myUnion . unionFirst = data; int data = myUnion . unionSecond ; 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 ); | 70567/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fscanf_34.c | SARD | 3 |
void CWE401_Memory_Leak__malloc_realloc_int64_t_15_bad() switch ( 6 ) int64_t * data = ( int64_t * ) malloc ( 100 * sizeof ( int64_t ) ) ; printLongLongLine ( data [ 0 ] ); void printLongLongLine (int64_t longLongIntNumber) printf ( "%lld\n" , longLongIntNumber ); data = ( int64_t * ) realloc ( data , ( 130000 ) * sizeof ( int64_t ) ); if ( data != NULL ) printLongLongLine ( data [ 0 ] ); void printLongLongLine (int64_t longLongIntNumber) printf ( "%lld\n" , longLongIntNumber ); free ( data ); | 99666/CWE401_Memory_Leak__malloc_realloc_int64_t_15.c | SARD | 29 |
static void goodB2G2() if ( GLOBAL_CONST_TRUE ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( 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 | 117711/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_connect_socket_09.cpp | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int_memcpy_12_bad() int * data ; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; data = ( int * ) malloc ( 100 * sizeof ( int ) ); memcpy ( data , source , 100 * sizeof ( int ) ); printIntLine ( data [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( data ); | 71707/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int_memcpy_12.c | SARD | 3 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfaanalyze ( d , searchflag ); void dfaanalyze(struct dfa *d,int searchflag) size_t * nfirstpos ; size_t * o_nfirst ; d -> searchflag = searchflag; nfirstpos = ( ( sizeof ( ( * nfirstpos ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nfirstpos ) ) ) ) ); while ( 0 ) o_nfirst = nfirstpos; free ( o_nfirst ); | 152992/dfa.c | SARD | 0 |
void CWE126_Buffer_Overread__malloc_char_loop_41_badSink(char * data) char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; destLen = strlen ( dest ); for (i = 0; i < destLen; i++) dest [ i ] = data [ i ]; dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 76258/CWE126_Buffer_Overread__malloc_char_loop_41.c | SARD | 3 |
void CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_67_bad() wchar_t * data ; CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_67_structType myStruct ; data = NULL; wchar_t * dataBuffer = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer - 8; myStruct . structFirst = data; CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_67b_badSink ( myStruct ); void CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_67b_badSink(CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_67_structType myStruct) wchar_t * data = myStruct . structFirst ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcsncpy ( data , source , 100 - 1 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 74709/CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_67b.c | SARD | 3 |
void heap2_redo(XLogRecPtr lsn,XLogRecord *record) uint8 info = ( ( record -> xl_info ) & ~0x0F ) ; switch ( info & 0x70 ) heap_xlog_multi_insert ( lsn , record ); static void heap_xlog_multi_insert(XLogRecPtr lsn,XLogRecord *record) char * recdata = ( ( char * ) record ) + ( ( ( intptr_t ) ( sizeof ( XLogRecord ) ) ) + ( 8 - 1 ) & ~ ( ( intptr_t ) ( 8 - 1 ) ) ) ; xl_heap_multi_insert * xlrec ; Buffer buffer ; Page page ; struct { HeapTupleHeaderData hdr ; char data [ 8192 - ( ( ( intptr_t ) ( ( ( size_t ) ( & ( ( PageHeaderData * ) 0 ) -> pd_linp ) ) + sizeof ( ItemIdData ) ) ) + ( 8 - 1 ) & ~ ( ( intptr_t ) ( 8 - 1 ) ) ) ] ; } tbuf ; HeapTupleHeader htup ; uint32 newlen ; BlockNumber blkno ; int i ; bool isinit = ( ( ( record -> xl_info ) & 0x0080 ) != 0 ) ; xlrec = ( ( xl_heap_multi_insert * ) recdata ); recdata += ( ( size_t ) ( & ( ( xl_heap_multi_insert * ) 0 ) -> offsets ) ); if ( ! isinit ) recdata += sizeof ( OffsetNumber ) * ( xlrec -> ntuples ); blkno = xlrec -> blkno; if ( ( record -> xl_info ) & 0x0008 >> 0 ) if ( isinit ) buffer = XLogReadBuffer ( xlrec -> node , blkno , ( ( bool ) 0 ) ); if ( ! ( ( ( ( void ) ( ( bool ) 1 ) ) , buffer != 0 ) ) ) page = ( ( Page ) ( ( Page ) ( ( ( ( void ) ( ( bool ) 1 ) ) , ( buffer < 0 ? LocalBufferBlockPointers [ - buffer - 1 ] : ( ( Block ) ( BufferBlocks + ( ( Size ) ( buffer - 1 ) ) * 8192 ) ) ) ) ) ) ); if ( lsn . xlogid < ( ( PageHeader ) page ) -> pd_lsn . xlogid || lsn . xlogid == ( ( PageHeader ) page ) -> pd_lsn . xlogid && lsn . xrecoff <= ( ( PageHeader ) page ) -> pd_lsn . xrecoff ) for (i = 0; i < (xlrec -> ntuples); i++) xl_multi_insert_tuple * xlhdr ; xlhdr = ( ( xl_multi_insert_tuple * ) ( ( ( intptr_t ) recdata ) + ( 2 - 1 ) & ~ ( ( intptr_t ) ( 2 - 1 ) ) ) ); recdata = ( ( char * ) xlhdr ) + ( ( ( size_t ) ( & ( ( xl_multi_insert_tuple * ) 0 ) -> t_hoff ) ) + sizeof ( uint8 ) ); newlen = ( xlhdr -> datalen ); htup = & tbuf . hdr; memcpy ( ( ( ( char * ) htup ) + ( ( size_t ) ( & ( ( HeapTupleHeaderData * ) 0 ) -> t_bits ) ) ) , ( ( char * ) recdata ) , newlen ); recdata += newlen; | 151618/heapam.c | SARD | 0 |
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( GLOBAL_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 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) fprintf ( stdout , "%s\n" , data ); | 79106/CWE134_Uncontrolled_Format_String__char_connect_socket_fprintf_09.c | SARD | 0 |
void stonesoup_setup_printf_context() ss_tc_root = getenv ( "SS_TC_ROOT" ); if ( ss_tc_root != NULL ) size_dirpath = strlen ( ss_tc_root ) + strlen ( "testData" ) + 2; dirpath = ( char * ) malloc ( size_dirpath * sizeof ( char ) ); if ( dirpath != NULL ) sprintf ( dirpath , "%s/%s" , ss_tc_root , "testData" ); retval = 0; if ( stat ( dirpath , & st ) == - 1 ) retval = mkdir ( dirpath , 0700 ); if ( retval == 0 ) size_filepath = strlen ( dirpath ) + strlen ( "logfile.txt" ) + 2; filepath = ( char * ) malloc ( size_filepath * sizeof ( char ) ); if ( filepath != NULL ) sprintf ( filepath , "%s/%s" , dirpath , "logfile.txt" ); free ( filepath ); | 153391/ffmpeg.c | SARD | 0 |
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 ; * 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; build_state ( works , d ); static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) leaf_set * grps ; charclass * labels ; size_t ngrps = 0 ; position pos ; charclass matches ; int matchesf ; charclass intersect ; int intersectf ; charclass leftovers ; int leftoversf ; size_t i ; size_t j ; size_t k ; grps = ( ( sizeof ( ( * grps ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * grps ) ) ) ) ); while ( 0 ) labels = ( ( sizeof ( ( * labels ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * labels ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . elems . nelem; ++i) pos = d -> states [ s ] . elems . elems [ i ]; if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) ) if ( d -> tokens [ pos . index ] >= CSET ) if ( pos . constraint != 0x777 ) if ( ! ( ( ( ( 4 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~newline [ j ]; if ( ! ( ( ( ( 2 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~letters [ j ]; if ( ! ( ( ( ( 1 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= letters [ j ] | newline [ j ]; if ( j == ( ( 1 << 8 ) + 8 * sizeof ( int ) - 1 ) / ( 8 * sizeof ( int ) ) ) for (j = 0; j < ngrps; ++j) if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) && ! tstbit ( d -> tokens [ pos . index ] , labels [ j ] ) ) intersectf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) ( intersect [ k ] = matches [ k ] & labels [ j ] [ k ] ) ? ( intersectf = 1 ) : 0; if ( ! intersectf ) leftoversf = matchesf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) int match = matches [ k ] ; int label = labels [ j ] [ k ] ; ( leftovers [ k ] = ~match & label ) ? ( leftoversf = 1 ) : 0; ( matches [ k ] = match & ~label ) ? ( matchesf = 1 ) : 0; if ( leftoversf ) grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) memcpy ( grps [ ngrps ] . elems , grps [ j ] . elems , sizeof ( grps [ j ] . elems [ 0 ] ) * grps [ j ] . nelem ); grps [ ngrps ] . nelem = grps [ j ] . nelem; grps [ j ] . elems [ grps [ j ] . nelem ++ ] = pos . index; if ( ! matchesf ) if ( j == ngrps ) grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = 1; grps [ ngrps ] . elems [ 0 ] = pos . index; | 153147/dfa.c | SARD | 0 |
static void goodG2B() char source [ 100 ] ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memmove ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 86984/CWE194_Unexpected_Sign_Extension__listen_socket_memmove_43.cpp | SARD | 0 |
void CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_malloc_17_bad() int i ; int data ; data = - 1; for(i = 0; i < 1; i++) 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 ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; printLine ( dataBuffer ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( dataBuffer ); | 87454/CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_malloc_17.c | SARD | 20 |
void CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_strncpy_51_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 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_strncpy_51b_badSink ( data ); void CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_strncpy_51b_badSink(int data) if ( data < 100 ) strncpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 88187/CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_strncpy_51a.c | SARD | 0 |
void CWE400_Resource_Exhaustion__connect_socket_fwrite_08_bad() 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 ) 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'; count = atoi ( inputBuffer ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); for (i = 0; i < (size_t)count; i++) | 98536/CWE400_Resource_Exhaustion__connect_socket_fwrite_08.c | SARD | 12 |
static void goodB2G() char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); CWE190_Integer_Overflow__int_fgets_square_54b_goodB2GSink ( data ); void CWE190_Integer_Overflow__int_fgets_square_54b_goodB2GSink(int data) CWE190_Integer_Overflow__int_fgets_square_54c_goodB2GSink ( data ); void CWE190_Integer_Overflow__int_fgets_square_54c_goodB2GSink(int data) CWE190_Integer_Overflow__int_fgets_square_54d_goodB2GSink ( data ); void CWE190_Integer_Overflow__int_fgets_square_54d_goodB2GSink(int data) CWE190_Integer_Overflow__int_fgets_square_54e_goodB2GSink ( data ); void CWE190_Integer_Overflow__int_fgets_square_54e_goodB2GSink(int data) if ( abs ( ( long ) data ) <= ( long ) sqrt ( ( double ) INT_MAX ) ) int result = data * data ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 83246/CWE190_Integer_Overflow__int_fgets_square_54a.c | SARD | 0 |
void CWE197_Numeric_Truncation_Error__short_listen_socket_07_bad() if ( staticFive == 5 ) 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 = ( short ) atoi ( inputBuffer ); while ( 0 ) char charData = ( char ) data ; printHexCharLine ( charData ); void printHexCharLine (char charHex) printf ( "%02x\n" , charHex ); | 89382/CWE197_Numeric_Truncation_Error__short_listen_socket_07.c | SARD | 20 |
static void goodB2G2() size_t data ; data = 0; data = rand ( ); goodB2G2Sink ( data ); void goodB2G2Sink(size_t data) if ( goodB2G2Global ) char * myString ; if ( data > strlen ( HELLO_STRING ) && data < 100 ) myString = new char [ data ]; strcpy ( myString , HELLO_STRING ); printLine ( myString ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] myString | 117674/CWE789_Uncontrolled_Mem_Alloc__new_char_rand_22b.cpp | SARD | 0 |
conversation_t *find_or_create_conversation(packet_info *pinfo) if ( ( conv = find_conversation ( pinfo -> fd -> num , ( & pinfo -> src ) , ( & pinfo -> dst ) , pinfo -> ptype , pinfo -> srcport , pinfo -> destport , 0 ) ) == ( ( void * ) 0 ) ) conversation_t *find_conversation(const guint32 frame_num,const address *addr_a,const address *addr_b,const port_type ptype,const guint32 port_a,const guint32 port_b,const guint options) conversation_t * conversation ; if ( ! ( options & ( 0x01 | 0x02 ) ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x01 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_b , port_a ); if ( conversation != ( ( void * ) 0 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , addr_a , 0 ); if ( ! ( options & 0x01 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_b , addr_a , ptype , port_b , port_a ); if ( conversation != ( ( void * ) 0 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , 0 , port_a ); conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2_or_port2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) if ( ! ( conversation -> options & 0x01 ) ) conversation_set_addr2 ( conversation , addr_b ); void conversation_set_addr2(conversation_t *conv,const address *addr) if ( ! ( conv -> options & 0x01 ) ) guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr -> data , ( addr -> len ) ); ( & conv -> key_ptr -> addr2 ) -> data = SE_COPY_ADDRESS_data; if ( conv -> options & 0x02 ) conversation_insert_into_hashtable ( conversation_hashtable_no_port2 , conv ); conversation_insert_into_hashtable ( conversation_hashtable_exact , conv ); | 152360/conversation.c | SARD | 0 |
static void goodG2B() char dataBuffer [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 73959/CWE124_Buffer_Underwrite__char_declare_cpy_18.c | SARD | 0 |
void CWE190_Integer_Overflow__int_listen_socket_square_04_bad() if ( STATIC_CONST_TRUE ) 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 ) int result = data * data ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 83505/CWE190_Integer_Overflow__int_listen_socket_square_04.c | SARD | 18 |
int cpu_memory_rw_debug(CPUState *cpu, target_ulong uint8_t *buf, int len, int is_write) int l ; hwaddr phys_addr ; target_ulong page ; while ( len > 0 ) page = addr & TARGET_PAGE_MASK; phys_addr = cpu_get_phys_page_debug ( cpu , page ); if ( phys_addr == - 1 ) l = ( page + TARGET_PAGE_SIZE ) - addr; if ( l > len ) l = len; phys_addr += ( addr & ~TARGET_PAGE_MASK ); if ( is_write ) cpu_physical_memory_rw ( phys_addr , buf , l , is_write ); len -= l; buf += l; addr += l; void cpu_physical_memory_rw(hwaddr addr, uint8_t int len, int is_write) address_space_rw ( & address_space_memory , addr , buf , len , is_write ); bool address_space_rw(AddressSpace *as, hwaddr addr, uint8_t int len, bool is_write) hwaddr l ; uint8_t * ptr ; hwaddr addr1 ; MemoryRegion * mr ; while ( len > 0 ) l = len; mr = address_space_translate ( as , addr , & addr1 , & l , is_write ); if ( is_write ) if ( ! memory_access_is_direct ( mr , is_write ) ) l = memory_access_size ( mr , l , addr1 ); val = ldq_p ( buf ); error |= io_mem_write ( mr , addr1 , val , 8 ); val = ldl_p ( buf ); error |= io_mem_write ( mr , addr1 , val , 4 ); val = lduw_p ( buf ); error |= io_mem_write ( mr , addr1 , val , 2 ); val = ldub_p ( buf ); error |= io_mem_write ( mr , addr1 , val , 1 ); addr1 += memory_region_get_ram_addr ( mr ); memcpy ( ptr , buf , l ); if ( ! memory_access_is_direct ( mr , is_write ) ) l = memory_access_size ( mr , l , addr1 ); error |= io_mem_read ( mr , addr1 , & val , 8 ); stq_p ( buf , val ); error |= io_mem_read ( mr , addr1 , & val , 4 ); stl_p ( buf , val ); error |= io_mem_read ( mr , addr1 , & val , 2 ); stw_p ( buf , val ); error |= io_mem_read ( mr , addr1 , & val , 1 ); stb_p ( buf , val ); ptr = qemu_get_ram_ptr ( mr -> ram_addr + addr1 ); memcpy ( buf , ptr , l ); len -= l; buf += l; addr += l; return error ; | CVE-2015-8817/qemu_1.6.0_CVE-2015-8817_exec.c | NVD | 0 |
static void goodG2B() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); goodG2BSource ( data ); void goodG2BSource(wchar_t * &data) wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' wcsncpy ( dest , data , wcslen ( data ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 72738/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_ncpy_62a.cpp | SARD | 0 |
static void goodG2B1() wchar_t * data ; data = NULL; if ( globalReturnsFalse ( ) ) int globalReturnsFalse() return 0 ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memmove ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 72042/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_memmove_11.c | SARD | 0 |
void CWE124_Buffer_Underwrite__wchar_t_alloca_ncpy_10_bad() wchar_t * data ; wchar_t * dataBuffer = ( wchar_t * ) ALLOCA ( 100 * sizeof ( wchar_t ) ) ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' if ( globalTrue ) data = dataBuffer - 8; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcsncpy ( data , source , 100 - 1 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 75367/CWE124_Buffer_Underwrite__wchar_t_alloca_ncpy_10.c | SARD | 3 |
void CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54b_goodG2BSink(short data) CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54c_goodG2BSink ( data ); void CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54c_goodG2BSink(short data) CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54d_goodG2BSink ( data ); void CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54d_goodG2BSink(short data) CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54e_goodG2BSink ( data ); void CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54e_goodG2BSink(short data) if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; free ( dataBuffer ); | 86318/CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54e.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 ) | 80753/CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vprintf_34.c | SARD | 0 |
inline static svn_error_t *skip_bom(parse_context_t *ctx) char * amroc_hydromedusoid [ 94 ] = { 0 } ; char * infinitives_squalus ; if ( __sync_bool_compare_and_swap ( & profs_raun , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( infinitives_squalus != 0 ) amroc_hydromedusoid [ 50 ] = infinitives_squalus; subconcealed_swimsuits ( 1 , amroc_hydromedusoid ); void subconcealed_swimsuits(int extraburghal_brout,... ) int preprovoking_heltonville = 7 ; char * * preready_malfed = 0 ; if ( extraburghal_brout > 0 ) preready_malfed = ( va_arg ( hallooed_pyruline , char * * ) ) curler_vergerism ( preprovoking_heltonville , preready_malfed ); void curler_vergerism(int basils_foreplan,char **torpedoing_woodwise) basils_foreplan --; if ( basils_foreplan > 0 ) curler_vergerism ( basils_foreplan , torpedoing_woodwise ); void curler_vergerism(int basils_foreplan,char **torpedoing_woodwise) struct stonesoup_data * stonesoupData ; basils_foreplan --; if ( basils_foreplan > 0 ) diapery_gibbous = ( ( char * ) torpedoing_woodwise [ 50 ] ); stonesoupData = malloc ( sizeof ( struct stonesoup_data ) ); if ( stonesoupData ) stonesoupData -> data = malloc ( sizeof ( char ) * ( strlen ( diapery_gibbous ) + 1 ) ); stonesoupData -> file1 = malloc ( sizeof ( char ) * ( strlen ( diapery_gibbous ) + 1 ) ); stonesoupData -> file2 = malloc ( sizeof ( char ) * ( strlen ( diapery_gibbous ) + 1 ) ); if ( stonesoupData -> data ) if ( ( sscanf ( diapery_gibbous , "%d %s %s %s" , & ( stonesoupData -> qsize ) , stonesoupData -> file1 , stonesoupData -> file2 , stonesoupData -> data ) == 4 ) && ( strlen ( stonesoupData -> data ) != 0 ) ) | 150451/config_file.c | SARD | 0 |
static void goodG2B2() wchar_t * data ; wchar_t dataGoodBuffer [ 100 ] ; if ( 5 == 5 ) data = dataGoodBuffer; data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memmove ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 65354/CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_memmove_03.c | SARD | 0 |
static void goodG2B() vector < wchar_t * > dataVector ; goodG2BSink ( dataVector ); void goodG2BSink(vector<wchar_t *> dataVector) wchar_t * data = dataVector [ 2 ] ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcsncpy ( data , source , 100 - 1 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 72169/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncpy_72b.cpp | SARD | 0 |
static ReportError(JSContext* aCx, WorkerPrivate* bool aFireAtScope, WorkerPrivate* const nsString& aMessage, const nsString& const nsString& aLine, uint32_t uint32_t aColumnNumber, uint32_t uint32_t aErrorNumber, JSExnType bool aMutedError, uint64_t aInnerWindowId) if ( ! JSREPORT_IS_WARNING ( aFlags ) ) RootedDictionary < ErrorEventInit > init ( aCx ) ; if ( aMutedError ) init . mMessage = aMessage; init . mFilename = aFilename; init . mLineno = aLineNumber; init . mCancelable = true; init . mBubbles = false; if ( aTarget ) nsEventStatus status = nsEventStatus_eIgnore ; if ( status == nsEventStatus_eConsumeNoDefault ) if ( aFireAtScope && ( aTarget || aErrorNumber != JSMSG_OVER_RECURSED ) ) JS :: Rooted < JSObject * > global ( aCx , JS :: CurrentGlobalOrNull ( aCx ) ) ; nsEventStatus status = nsEventStatus_eIgnore ; nsIScriptGlobalObject * sgo ; if ( aWorkerPrivate ) WorkerGlobalScope * globalScope = nullptr ; if ( ! globalScope ) nsIDOMEventTarget * target = static_cast < nsIDOMEventTarget * > globalScope RefPtr < ErrorEvent > event = ErrorEvent :: Constructor ( aTarget , NS_LITERAL_STRING ( "error" ) , init ) ; if ( NS_FAILED ( EventDispatcher :: DispatchDOMEvent ( target , nullptr , event , nullptr , & status ) ) ) status = nsEventStatus_eIgnore; if ( sgo = nsJSUtils :: GetStaticScriptGlobal ( global ) ) if ( NS_FAILED ( sgo -> HandleScriptError ( init , & status ) ) ) status = nsEventStatus_eIgnore; if ( status == nsEventStatus_eConsumeNoDefault ) if ( aWorkerPrivate ) LogErrorToConsole ( aMessage , aFilename , aLine , aLineNumber , aColumnNumber , aFlags , aInnerWindowId ); LogErrorToConsole(const nsAString& const nsAString& const nsAString& uint32_t uint32_t uint32_t uint64_t aInnerWindowId) nsCOMPtr < nsIScriptError > scriptError = do_CreateInstance ( NS_SCRIPTERROR_CONTRACTID ) ; if ( scriptError ) if ( NS_FAILED ( scriptError -> InitWithWindowID ( aMessage , aFilename , aLine , aLineNumber , aColumnNumber , aFlags , "Web Worker" , aInnerWindowId ) ) ) scriptError = nullptr; nsCOMPtr < nsIConsoleService > consoleService = do_GetService ( NS_CONSOLESERVICE_CONTRACTID ) ; if ( consoleService ) if ( scriptError ) if ( NS_SUCCEEDED ( consoleService -> LogMessage ( scriptError ) ) ) if ( NS_SUCCEEDED ( consoleService -> LogStringMessage ( aMessage . BeginReading ( ) ) ) ) NS_ConvertUTF16toUTF8 msg ( aMessage ) ; NS_ConvertUTF16toUTF8 filename ( aFilename ) ; static const char kErrorString [ ] = "JS error in Web Worker: %s [%s:%u]" ; fprintf ( stderr , kErrorString , msg . get ( ) , filename . get ( ) , aLineNumber ); fflush ( stderr ); | CVE-2016-5259/firefox_47.0b9_CVE_2016_5259_dom_workers_WorkerPrivate.cpp | NVD | 0 |
conversation_t *find_or_create_conversation(packet_info *pinfo) if ( ( conv = find_conversation ( pinfo -> fd -> num , ( & pinfo -> src ) , ( & pinfo -> dst ) , pinfo -> ptype , pinfo -> srcport , pinfo -> destport , 0 ) ) == ( ( void * ) 0 ) ) conversation_t *find_conversation(const guint32 frame_num,const address *addr_a,const address *addr_b,const port_type ptype,const guint32 port_a,const guint32 port_b,const guint options) conversation_t * conversation ; if ( ! ( options & ( 0x01 | 0x02 ) ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x01 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_b , port_a ); if ( conversation != ( ( void * ) 0 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , addr_a , 0 ); if ( ! ( options & 0x01 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_b , addr_a , ptype , port_b , port_a ); if ( conversation != ( ( void * ) 0 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , 0 , port_a ); static conversation_t *conversation_create_from_template(conversation_t *conversation,const address *addr2,const guint32 port2) if ( conversation -> options & 0x08 && ( conversation -> key_ptr -> ptype ) != PT_UDP ) conversation_t * new_conversation_from_template ; guint options = conversation -> options & ( ~ ( 0x08 | 0x01 | 0x02 ) ) ; if ( conversation -> options & 0x01 && conversation -> options & 0x02 ) if ( conversation -> options & 0x02 ) if ( conversation -> options & 0x01 ) new_conversation_from_template = conversation_new ( conversation -> setup_frame , ( & conversation -> key_ptr -> addr1 ) , addr2 , conversation -> key_ptr -> ptype , conversation -> key_ptr -> port1 , conversation -> key_ptr -> port2 , options ); conversation_t *conversation_new(const guint32 setup_frame,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2,const guint options) guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr1 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr1 -> data , ( addr1 -> len ) ); ( & new_key -> addr1 ) -> data = SE_COPY_ADDRESS_data; ( & new_key -> addr2 ) -> type = addr2 -> type; ( & new_key -> addr2 ) -> len = addr2 -> len; memcpy ( SE_COPY_ADDRESS_data , addr2 -> data , ( addr2 -> len ) ); ( & new_key -> addr2 ) -> data = SE_COPY_ADDRESS_data; new_key -> ptype = ptype; new_key -> port1 = port1; new_key -> port2 = port2; conversation -> key_ptr = new_key; conversation_insert_into_hashtable ( hashtable , conversation ); return conversation ; | 152360/conversation.c | SARD | 0 |
void CWE590_Free_Memory_Not_on_Heap__free_int_alloca_07_bad() int * data ; data = NULL; if ( staticFive == 5 ) int * dataBuffer = ( int * ) ALLOCA ( 100 * sizeof ( int ) ) ; size_t i ; for (i = 0; i < 100; i++) dataBuffer [ i ] = 5; data = dataBuffer; free ( data ); | 108342/CWE590_Free_Memory_Not_on_Heap__free_int_alloca_07.c | SARD | 1 |
void bad() char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); badSink_b ( data ); void badSink_b(int data) badSink_c ( data ); void badSink_c(int data) if ( data >= 0 ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); delete [ ] buffer | 67598/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE129_fgets_52a.cpp | SARD | 0 |
static void goodG2B() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; strcat ( data , "c:\\temp\\file.txt" ); myUnion . unionFirst = data; char * data = myUnion . unionSecond ; pFile = FOPEN ( data , "wb+" ); if ( pFile != NULL ) fclose ( pFile ); | 95801/CWE36_Absolute_Path_Traversal__char_console_fopen_34.cpp | SARD | 0 |
void CWE121_Stack_Based_Buffer_Overflow__char_type_overrun_memcpy_13_bad() if ( GLOBAL_CONST_FIVE == 5 ) charVoid structCharVoid ; structCharVoid . voidSecond = ( void * ) SRC_STR; memcpy ( structCharVoid . charFirst , SRC_STR , sizeof ( structCharVoid ) ); structCharVoid . charFirst [ ( sizeof ( structCharVoid . charFirst ) / sizeof ( char ) ) - 1 ] = '\0'; printLine ( ( char * ) structCharVoid . charFirst ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); printLine ( ( char * ) structCharVoid . voidSecond ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 63048/CWE121_Stack_Based_Buffer_Overflow__char_type_overrun_memcpy_13.c | SARD | 3 |
void CWE122_Heap_Based_Buffer_Overflow__char_type_overrun_memmove_13_bad() if ( GLOBAL_CONST_FIVE == 5 ) charVoid * structCharVoid = ( charVoid * ) malloc ( sizeof ( charVoid ) ) ; structCharVoid -> voidSecond = ( void * ) SRC_STR; printLine ( ( char * ) structCharVoid -> voidSecond ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); memmove ( structCharVoid -> charFirst , SRC_STR , sizeof ( * structCharVoid ) ); structCharVoid -> charFirst [ ( sizeof ( structCharVoid -> charFirst ) / sizeof ( char ) ) - 1 ] = '\0'; printLine ( ( char * ) structCharVoid -> charFirst ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); printLine ( ( char * ) structCharVoid -> voidSecond ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 67514/CWE122_Heap_Based_Buffer_Overflow__char_type_overrun_memmove_13.c | SARD | 3 |
void av_dump_format(AVFormatContext *ic,int index,const char *url,int is_output) int i ; uint8_t * printed = ( ic -> nb_streams ? av_mallocz ( ( ic -> nb_streams ) ) : ( ( void * ) 0 ) ) ; if ( ic -> nb_streams && ! printed ) for (i = 0; i < ic -> nb_chapters; i++) AVChapter * ch = ic -> chapters [ i ] ; dump_metadata ( ( ( void * ) 0 ) , ch -> metadata , " " ); static void dump_metadata(void *ctx,AVDictionary *m,const char *indent) if ( m && ! ( av_dict_count ( m ) == 1 && av_dict_get ( m , "language" , ( ( void * ) 0 ) , 0 ) ) ) AVDictionaryEntry * tag = ( ( void * ) 0 ) ; while ( tag = av_dict_get ( m , "" , tag , 2 ) ) if ( strcmp ( "language" , ( tag -> key ) ) ) const char * p = ( tag -> value ) ; while ( * p ) size_t len = strcspn ( p , "\010\n\v\f\r" ) ; av_strlcpy ( tmp , p , ( sizeof ( tmp ) > len + 1 ? len + 1 : sizeof ( tmp ) ) ); p += len; if ( ( * p ) == 0xd ) if ( ( * p ) == 0xa ) if ( * p ) p ++; | 150221/utils.c | SARD | 0 |
unsigned int gzwfile_write(GZWFILE_T state,const void *buf,unsigned int len) z_streamp strm ; strm = & state -> strm; if ( state -> err != 0 ) if ( len == 0 ) if ( state -> size == 0 && gz_init ( state ) == - 1 ) if ( len < state -> size ) if ( strm -> avail_in && gz_comp ( state , 0 ) == - 1 ) static int gz_comp(GZWFILE_T state,int flush) int ret ; int got ; unsigned int have ; z_streamp strm = & state -> strm ; if ( state -> size == 0 && gz_init ( state ) == - 1 ) ret = 0; if ( strm -> avail_out == 0 || flush != 0 && ( flush != 4 || ret == 1 ) ) have = ( ( unsigned int ) ( strm -> next_out - state -> next ) ); if ( have ) got = ( write ( state -> fd , ( state -> next ) , have ) ); if ( got < 0 ) if ( ( ( unsigned int ) got ) != have ) if ( strm -> avail_out == 0 ) strm -> avail_out = state -> size; strm -> next_out = state -> out; state -> next = strm -> next_out; have = strm -> avail_out; ret = deflate ( strm , flush ); if ( ret == - 2 ) have -= strm -> avail_out; while ( have ) | 151068/file_wrappers.c | SARD | 0 |
static void goodB2G() void * data ; CWE121_Stack_Based_Buffer_Overflow__CWE135_67_structType myStruct ; data = NULL; data = ( void * ) WIDE_STRING; myStruct . structFirst = data; CWE121_Stack_Based_Buffer_Overflow__CWE135_67b_goodB2GSink ( myStruct ); void CWE121_Stack_Based_Buffer_Overflow__CWE135_67b_goodB2GSink(CWE121_Stack_Based_Buffer_Overflow__CWE135_67_structType myStruct) void * data = myStruct . structFirst ; size_t dataLen = wcslen ( ( wchar_t * ) data ) ; void * dest = ( void * ) calloc ( dataLen + 1 , sizeof ( wchar_t ) ) ; memcpy ( dest , data , ( dataLen + 1 ) * sizeof ( wchar_t ) ); free ( dest ); | 62987/CWE121_Stack_Based_Buffer_Overflow__CWE135_67b.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 ) 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 ); CWE121_Stack_Based_Buffer_Overflow__CWE129_connect_socket_64b_goodB2GSink ( & data ); void CWE121_Stack_Based_Buffer_Overflow__CWE129_connect_socket_64b_goodB2GSink(void * dataVoidPtr) int * dataPtr = ( int * ) dataVoidPtr ; int data = ( * dataPtr ) ; if ( data >= 0 && data < ( 10 ) ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 62552/CWE121_Stack_Based_Buffer_Overflow__CWE129_connect_socket_64a.c | SARD | 0 |
void bad() char * data ; data = ( char * ) malloc ( 10 * sizeof ( char ) ); dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; badSink ( dataMap ); void badSink(map<int, char *> dataMap) char * data = dataMap [ 2 ] ; data [ i ] = source [ i ]; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 70827/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_loop_74a.cpp | SARD | 0 |
static int unix_seqpacket_recvmsg(struct socket *sock, struct msghdr size_t size, int flags) struct sock * sk = sock -> sk ; if ( sk -> sk_state != TCP_ESTABLISHED ) return unix_dgram_recvmsg ( sock , msg , size , flags ) ; static int unix_dgram_recvmsg(struct socket *sock, struct msghdr size_t size, int flags) struct scm_cookie scm ; struct sock * sk = sock -> sk ; struct unix_sock * u = unix_sk ( sk ) ; struct sk_buff * skb ; int err ; int peeked , skip ; err = - EOPNOTSUPP; if ( flags & MSG_OOB ) err = mutex_lock_interruptible ( & u -> readlock ); if ( unlikely ( err ) ) skip = sk_peek_offset ( sk , flags ); skb = __skb_recv_datagram ( sk , flags , & peeked , & skip , & err ); if ( ! skb ) if ( size > skb -> len - skip ) size = skb -> len - skip; if ( size < skb -> len - skip ) msg -> msg_flags |= MSG_TRUNC; err = skb_copy_datagram_msg ( skb , skip , msg , size ); if ( err ) memset ( & scm , 0 , sizeof ( scm ) ); scm_set_cred ( & scm , UNIXCB ( skb ) . pid , UNIXCB ( skb ) . uid , UNIXCB ( skb ) . gid ); unix_set_secdata ( & scm , skb ); static inline void unix_set_secdata(struct scm_cookie *scm, struct sk_buff *skb) scm -> secid = UNIXCB ( skb ) . secid; unix_detach_fds ( & scm , skb ); static void unix_detach_fds(struct scm_cookie *scm, struct sk_buff *skb) scm -> fp = UNIXCB ( skb ) . fp; UNIXCB ( skb ) . fp = NULL; for (i = scm->fp->count-1; i >= 0; i--) unix_notinflight ( scm -> fp -> fp [ i ] ); scm . fp = scm_fp_dup ( UNIXCB ( skb ) . fp ); scm_recv ( sock , msg , & scm , flags ); | CVE-2016-2550/linux_kernel_4.3.5_CVE_2016_2550_net_unix_af_unix.c | NVD | 0 |
static void goodB2G() wchar_t * data ; wchar_t * * dataPtr1 = & data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; wchar_t * data = * dataPtr1 ; size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 109335/CWE606_Unchecked_Loop_Condition__wchar_t_file_32.c | SARD | 0 |
void parse_dir_colors() char * * arg ; char * * c ; char * colors ; char * s ; int i ; if ( Hflag ) if ( getenv ( "TERM" ) == ( ( void * ) 0 ) ) s = getenv ( "TREE_COLORS" ); if ( s == ( ( void * ) 0 ) ) s = getenv ( "LS_COLORS" ); if ( ( s == ( ( void * ) 0 ) || strlen ( s ) == 0 ) && force_color ) s = ":no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.bat=01;32:*.BAT=01;32:*.btm=01;32:*.BTM=01;32:*.cmd=01;32:*.CMD=01;32:*.com=01;32:*.COM=01;32:*.dll=01;32:*.DLL=01;32:*.exe=01;32:*.EXE=01;32:*.arj=01;31:*.bz2=01;31:*.deb=01;31:*.gz=01;31:*.lzh=01;31:*.rpm=01;31:*.tar=01;31:*.taz=01;31:*.tb2=01;31:*.tbz2=01;31:*.tbz=01;31:*.tgz=01;31:*.tz2=01;31:*.z=01;31:*.Z=01;31:*.zip=01;31:*.ZIP=01;31:*.zoo=01;31:*.asf=01;35:*.ASF=01;35:*.avi=01;35:*.AVI=01;35:*.bmp=01;35:*.BMP=01;35:*.flac=01;35:*.FLAC=01;35:*.gif=01;35:*.GIF=01;35:*.jpg=01;35:*.JPG=01;35:*.jpeg=01;35:*.JPEG=01;35:*.m2a=01;35:*.M2a=01;35:*.m2v=01;35:*.M2V=01;35:*.mov=01;35:*.MOV=01;35:*.mp3=01;35:*.MP3=01;35:*.mpeg=01;35:*.MPEG=01;35:*.mpg=01;35:*.MPG=01;35:*.ogg=01;35:*.OGG=01;35:*.ppm=01;35:*.rm=01;35:*.RM=01;35:*.tga=01;35:*.TGA=01;35:*.tif=01;35:*.TIF=01;35:*.wav=01;35:*.WAV=01;35:*.wmv=01;35:*.WMV=01;35:*.xbm=01;35:*.xpm=01;35:"; if ( s == ( ( void * ) 0 ) || ! force_color && ( nocolor || ! isatty ( 1 ) ) ) colors = strcpy ( ( xmalloc ( strlen ( s ) + 1 ) ) , s ); arg = split ( colors , ":" , & n ); char **split(char *str,char *delim,int *nwrds) int n = 128 ; char * * w = ( xmalloc ( sizeof ( char * ) * n ) ) ; w [ * nwrds = 0 ] = strtok ( str , delim ); while ( w [ * nwrds ] ) if ( * nwrds == n - 2 ) w = ( xrealloc ( w , sizeof ( char * ) * ( n += 256 ) ) ); w [ ++ * nwrds ] = strtok ( ( ( void * ) 0 ) , delim ); w [ * nwrds ] = ( ( void * ) 0 ); return w ; for (i = 0; arg[i]; i++) c = split ( arg [ i ] , "=" , & n ); char **split(char *str,char *delim,int *nwrds) int n = 128 ; char * * w = ( xmalloc ( sizeof ( char * ) * n ) ) ; w [ * nwrds = 0 ] = strtok ( str , delim ); while ( w [ * nwrds ] ) if ( * nwrds == n - 2 ) w = ( xrealloc ( w , sizeof ( char * ) * ( n += 256 ) ) ); w [ ++ * nwrds ] = strtok ( ( ( void * ) 0 ) , delim ); w [ * nwrds ] = ( ( void * ) 0 ); return w ; switch ( cmd ( c [ 0 ] ) ) int cmd(char *s) static struct { char * cmd ; char cmdnum ; } cmds [ ] = { { ( "no" ) , ( COL_NORMAL ) } , { ( "fi" ) , ( COL_FILE ) } , { ( "di" ) , ( COL_DIR ) } , { ( "ln" ) , ( COL_LINK ) } , { ( "pi" ) , ( COL_FIFO ) } , { ( "do" ) , ( COL_DOOR ) } , { ( "bd" ) , ( COL_BLK ) } , { ( "cd" ) , ( COL_CHR ) } , { ( "or" ) , ( COL_ORPHAN ) } , { ( "so" ) , ( COL_SOCK ) } , { ( "su" ) , ( COL_SETUID ) } , { ( "sg" ) , ( COL_SETGID ) } , { ( "tw" ) , ( COL_STICKY_OTHER_WRITABLE ) } , { ( "ow" ) , ( COL_OTHER_WRITABLE ) } , { ( "st" ) , ( COL_STICKY ) } , { ( "ex" ) , ( COL_EXEC ) } , { ( "mi" ) , ( COL_MISSING ) } , { ( "lc" ) , ( COL_LEFTCODE ) } , { ( "rc" ) , ( COL_RIGHTCODE ) } , { ( "ec" ) , ( COL_ENDCODE ) } , { ( ( ( void * ) 0 ) ) , ( 0 ) } } ; int i ; for (i = 0; cmds[i] . cmdnum; i++) if ( ! strcmp ( cmds [ i ] . cmd , s ) ) return cmds [ i ] . cmdnum ; if ( s [ 0 ] == '*' ) return DOT_EXTENSION ; return ERROR ; if ( c [ 1 ] ) leftcode = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( ! leftcode ) leftcode = strcpy ( ( xmalloc ( strlen ( "\033[" ) + 1 ) ) , "\033[" ); sprintf ( buf , "%s%s%s" , leftcode , norm_flgs , rightcode ); endcode = strcpy ( ( xmalloc ( strlen ( buf ) + 1 ) ) , buf ); | 152046/color.c | SARD | 0 |
static void goodG2B2() char * data ; char * dataGoodBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; if ( STATIC_CONST_TRUE ) data = dataGoodBuffer; data [ 0 ] = '\0'; 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 ); | 63995/CWE121_Stack_Based_Buffer_Overflow__CWE805_char_alloca_ncpy_04.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_listen_socket_w32_execv_01_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 120055/CWE78_OS_Command_Injection__char_listen_socket_w32_execv_01.c | SARD | 0 |
void CWE590_Free_Memory_Not_on_Heap__free_int64_t_declare_64_bad() int64_t * data ; data = NULL; int64_t dataBuffer [ 100 ] ; size_t i ; for (i = 0; i < 100; i++) dataBuffer [ i ] = 5L L data = dataBuffer; CWE590_Free_Memory_Not_on_Heap__free_int64_t_declare_64b_badSink ( & data ); void CWE590_Free_Memory_Not_on_Heap__free_int64_t_declare_64b_badSink(void * dataVoidPtr) int64_t * * dataPtr = ( int64_t * * ) dataVoidPtr ; int64_t * data = ( * dataPtr ) ; free ( data ); | 108286/CWE590_Free_Memory_Not_on_Heap__free_int64_t_declare_64b.c | SARD | 1 |
void CWE124_Buffer_Underwrite__CWE839_connect_socket_67_bad() 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 ); myStruct . structFirst = data; CWE124_Buffer_Underwrite__CWE839_connect_socket_67b_badSink ( myStruct ); void CWE124_Buffer_Underwrite__CWE839_connect_socket_67b_badSink(CWE124_Buffer_Underwrite__CWE839_connect_socket_67_structType myStruct) int data = myStruct . structFirst ; if ( data < 10 ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 73589/CWE124_Buffer_Underwrite__CWE839_connect_socket_67a.c | SARD | 0 |
static void goodB2G2() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( GLOBAL_CONST_FIVE == 5 ) size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 81510/CWE134_Uncontrolled_Format_String__wchar_t_file_snprintf_13.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) if ( ! strcmp ( pattern , "*" ) ) | 150142/utils.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_connect_socket_printf_04_bad() 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 ) 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 ); printf ( data ); | 79149/CWE134_Uncontrolled_Format_String__char_connect_socket_printf_04.c | SARD | 15 |
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; 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 ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); goodB2G2VaSinkG ( data , data ); static void goodB2G2VaSinkG(char * data, ...) va_start ( args , data ); | 79342/CWE134_Uncontrolled_Format_String__char_connect_socket_w32_vsnprintf_05.c | SARD | 0 |
static int xhci_complete_packet(XHCITransfer *xfer) if ( xfer -> packet . status == USB_RET_ASYNC ) if ( xfer -> packet . status == USB_RET_NAK ) xfer -> running_async = 0; xfer -> running_retry = 0; xfer -> complete = 1; if ( xfer -> packet . status == USB_RET_SUCCESS ) xfer -> status = CC_SUCCESS; switch ( xfer -> packet . status ) xfer -> status = CC_USB_TRANSACTION_ERROR; xhci_stall_ep ( xfer ); static void xhci_stall_ep(XHCITransfer *xfer) XHCIState * xhci = xfer -> xhci ; XHCISlot * slot = & xhci -> slots [ xfer -> slotid - 1 ] ; XHCIEPContext * epctx = slot -> eps [ xfer -> epid - 1 ] ; XHCIStreamContext * sctx ; if ( epctx -> nr_pstreams ) sctx = xhci_find_stream ( epctx , xfer -> streamid , & err ); if ( sctx == NULL ) sctx -> ring . dequeue = xfer -> trbs [ 0 ] . addr; sctx -> ring . ccs = xfer -> trbs [ 0 ] . ccs; xhci_set_ep_state ( xhci , epctx , sctx , EP_HALTED ); static void xhci_set_ep_state(XHCIState *xhci, XHCIEPContext XHCIStreamContext *sctx, uint32_t state) uint32_t ctx [ 5 ] ; xhci_dma_read_u32s ( xhci , epctx -> pctx , ctx , sizeof ( ctx ) ); static inline void xhci_dma_read_u32s(XHCIState *xhci, dma_addr_t uint32_t *buf, size_t len) assert ( ( len % sizeof ( uint32_t ) ) == 0 ); | CVE-2016-7466/qemu_2.3.0_CVE-2016-7466_hcd-xhci.c | NVD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; 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 ) while ( 0 ) | 89704/CWE23_Relative_Path_Traversal__char_connect_socket_ofstream_45.cpp | SARD | 0 |
void CWE124_Buffer_Underwrite__char_declare_loop_07_bad() char dataBuffer [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer - 8; data [ i ] = source [ i ]; data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 73988/CWE124_Buffer_Underwrite__char_declare_loop_07.c | SARD | 3 |
static void goodB2G1() char * data ; data = NULL; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; free ( data ); | 102212/CWE416_Use_After_Free__malloc_free_char_08.c | SARD | 0 |