func
stringlengths 181
23.6k
| path
stringlengths 12
123
| source
stringclasses 2
values | label
int64 0
40
|
---|---|---|---|
static void goodG2B() char * cryptoKey ; char cryptoKeyBuffer [ 100 ] = "" ; cryptoKey = cryptoKeyBuffer; size_t cryptoKeyLen = strlen ( cryptoKey ) ; if ( 100 - cryptoKeyLen > 1 ) if ( fgets ( cryptoKey + cryptoKeyLen , ( int ) ( 100 - cryptoKeyLen ) , stdin ) == NULL ) cryptoKey [ cryptoKeyLen ] = '\0'; cryptoKeyLen = strlen ( cryptoKey ); if ( cryptoKeyLen > 0 ) cryptoKey [ cryptoKeyLen - 1 ] = '\0'; CWE321_Hard_Coded_Cryptographic_Key__w32_char_53b_goodG2BSink ( cryptoKey ); void CWE321_Hard_Coded_Cryptographic_Key__w32_char_53b_goodG2BSink(char * cryptoKey) CWE321_Hard_Coded_Cryptographic_Key__w32_char_53c_goodG2BSink ( cryptoKey ); void CWE321_Hard_Coded_Cryptographic_Key__w32_char_53c_goodG2BSink(char * cryptoKey) CWE321_Hard_Coded_Cryptographic_Key__w32_char_53d_goodG2BSink ( cryptoKey ); void CWE321_Hard_Coded_Cryptographic_Key__w32_char_53d_goodG2BSink(char * cryptoKey) HCRYPTHASH hHash ; if ( ! CryptHashData ( hHash , ( BYTE * ) cryptoKey , strlen ( cryptoKey ) * sizeof ( char ) , 0 ) ) | 94321/CWE321_Hard_Coded_Cryptographic_Key__w32_char_53d.c | SARD | 0 |
void bad() char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = ( short ) atoi ( inputBuffer ); if ( data < 100 ) strncpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 86644/CWE194_Unexpected_Sign_Extension__fgets_strncpy_33.cpp | SARD | 20 |
static void goodB2G1() size_t data ; data = 0; switch ( 6 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) switch ( 8 ) wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) && data < 100 ) myString = new wchar_t [ data ]; wcscpy ( myString , HELLO_STRING ); printWLine ( myString ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) delete [ ] myString | 117861/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_listen_socket_15.cpp | SARD | 0 |
static void good2() if ( 5 == 5 ) BYTE payload [ 100 ] ; DWORD payloadLen = strlen ( PAYLOAD ) ; HCRYPTPROV hCryptProv = ( HCRYPTPROV ) NULL ; HCRYPTHASH hHash = ( HCRYPTHASH ) NULL ; HCRYPTKEY hKey = ( HCRYPTKEY ) NULL ; char hashData [ 100 ] = HASH_INPUT ; memcpy ( payload , PAYLOAD , payloadLen ); if ( ! CryptAcquireContext ( & hCryptProv , NULL , MS_ENH_RSA_AES_PROV , PROV_RSA_AES , 0 ) ) if ( ! CryptCreateHash ( hCryptProv , CALG_SHA_256 , 0 , 0 , & hHash ) ) if ( ! CryptHashData ( hHash , ( BYTE * ) hashData , strlen ( hashData ) , 0 ) ) if ( ! CryptDeriveKey ( hCryptProv , CALG_AES_256 , hHash , 0 , & hKey ) ) if ( ! CryptEncrypt ( hKey , 0 , 1 , 0 , payload , & payloadLen , sizeof ( payload ) ) ) while ( 0 ) | 94442/CWE325_Missing_Required_Cryptographic_Step__w32_CryptHashData_03.c | SARD | 0 |
void CWE369_Divide_by_Zero__int_listen_socket_modulo_53_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 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); CWE369_Divide_by_Zero__int_listen_socket_modulo_53b_badSink ( data ); void CWE369_Divide_by_Zero__int_listen_socket_modulo_53b_badSink(int data) CWE369_Divide_by_Zero__int_listen_socket_modulo_53c_badSink ( data ); void CWE369_Divide_by_Zero__int_listen_socket_modulo_53c_badSink(int data) CWE369_Divide_by_Zero__int_listen_socket_modulo_53d_badSink ( data ); void CWE369_Divide_by_Zero__int_listen_socket_modulo_53d_badSink(int data) printIntLine ( 100 % data ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 95329/CWE369_Divide_by_Zero__int_listen_socket_modulo_53a.c | SARD | 0 |
static void goodG2B2() wchar_t * data ; data = NULL; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; data = new wchar_t [ 100 ]; data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memcpy ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) delete [ ] data | 69066/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_wchar_t_memcpy_11.cpp | SARD | 0 |
void CWE78_OS_Command_Injection__char_file_w32_execvp_64_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 119611/CWE78_OS_Command_Injection__char_file_w32_execvp_64a.c | SARD | 0 |
static void build_state_zero(struct dfa *d) d -> tralloc = 1; d -> trcount = 0; d -> realtrans = ( ( sizeof ( ( * d -> realtrans ) ) == 1 ? xzalloc ( ( d -> tralloc + 1 ) ) : xcalloc ( ( d -> tralloc + 1 ) , sizeof ( ( * d -> realtrans ) ) ) ) ); while ( 0 ) d -> trans = d -> realtrans + 1; d -> fails = ( ( sizeof ( ( * d -> fails ) ) == 1 ? xzalloc ( ( d -> tralloc ) ) : xcalloc ( ( d -> tralloc ) , sizeof ( ( * d -> fails ) ) ) ) ); while ( 0 ) d -> success = ( ( sizeof ( ( * d -> success ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> success ) ) ) ) ); while ( 0 ) d -> newlines = ( ( sizeof ( ( * d -> newlines ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> newlines ) ) ) ) ); while ( 0 ) build_state ( 0 , 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 ) copyset ( intersect , labels [ j ] ); 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; static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) ); | 152809/dfa.c | SARD | 0 |
int av_dup_packet(AVPacket *pkt) AVPacket tmp_pkt ; if ( pkt -> destruct == ( ( void * ) 0 ) && pkt -> data ) return copy_packet_data ( pkt , & tmp_pkt ) ; static int copy_packet_data(AVPacket *dst,AVPacket *src) dst -> data = ( ( void * ) 0 ); dst -> side_data = ( ( void * ) 0 ); void * data ; if ( 1 ) if ( ( ( unsigned int ) ( dst -> size ) ) > ( ( unsigned int ) ( dst -> size ) ) + 16 ) data = av_malloc ( ( dst -> size + 16 ) ); data = av_malloc ( ( dst -> size ) ); if ( ! data ) memcpy ( data , ( src -> data ) , ( dst -> size ) ); if ( 1 ) memset ( ( ( ( uint8_t * ) data ) + dst -> size ) , 0 , 16 ); dst -> data = data; while ( 0 ) memset ( ( ( ( uint8_t * ) data ) + ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) ) , 0 , 16 ); | 151728/avpacket.c | SARD | 0 |
static void goodB2G2() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( 5 == 5 ) size_t dataLen = wcslen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = wcslen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == L '\n' ) | 81068/CWE134_Uncontrolled_Format_String__wchar_t_console_w32_vsnprintf_03.c | SARD | 0 |
void bad() int data ; data = - 1; CWE127_Buffer_Underread__CWE839_listen_socket_84_bad * badObject = new CWE127_Buffer_Underread__CWE839_listen_socket_84_bad ( data ) ; CWE127_Buffer_Underread__CWE839_listen_socket_84_bad::CWE127_Buffer_Underread__CWE839_listen_socket_84_bad(int dataCopy) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 77241/CWE127_Buffer_Underread__CWE839_listen_socket_84_bad.cpp | SARD | 0 |
void bad() size_t data ; data = rand ( ); baseObject -> action ( data ); void CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_82_bad::action(size_t data) if ( data > wcslen ( HELLO_STRING ) ) myString = ( wchar_t * ) malloc ( data * sizeof ( wchar_t ) ); wcscpy ( myString , HELLO_STRING ); printWLine ( myString ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( myString ); | 117460/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_82a.cpp | SARD | 0 |
static void int_cleanup_cb_LHASH_DOALL(void *arg) union retraceable_nonspurious nepheline_papayas ; char * woefare_melodiograph ; if ( __sync_bool_compare_and_swap ( & zambezian_eupatrids , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( woefare_melodiograph != 0 ) nepheline_papayas . urolith_incenses = woefare_melodiograph; ancona_unfruitfulness ( 1 , nepheline_papayas ); void ancona_unfruitfulness(int disfranchised_rhizogen,... ) int ravishes_betimes = 7 ; union retraceable_nonspurious fungated_engirds = { 0 } ; if ( disfranchised_rhizogen > 0 ) fungated_engirds = ( va_arg ( elpidite_ropier , union retraceable_nonspurious ) ) severate_golly ( ravishes_betimes , fungated_engirds ); void severate_golly(int wrecking_virion,union retraceable_nonspurious scrogie_alfred) wrecking_virion --; if ( wrecking_virion > 0 ) severate_golly ( wrecking_virion , scrogie_alfred ); void severate_golly(int wrecking_virion,union retraceable_nonspurious scrogie_alfred) char stonesoup_col1 [ 80 ] = { 0 } ; char stonesoup_col2 [ 80 ] = { 0 } ; char stonesoup_col3 [ 80 ] = { 0 } ; char * stonesoup_cols [ 3 ] = { 0 } ; wrecking_virion --; if ( wrecking_virion > 0 ) laetic_precontact = ( ( char * ) scrogie_alfred . urolith_incenses ); stonesoup_csv = fopen ( laetic_precontact , "r" ); if ( stonesoup_csv != 0 ) fscanf ( stonesoup_csv , "\"%79[^\"]\",\"%79[^\"]\",\"%79[^\"]\"" , stonesoup_col1 , stonesoup_col2 , stonesoup_col3 ); if ( strlen ( stonesoup_col1 ) > 0 ) stonesoup_cols [ 0 ] = stonesoup_col1; if ( strlen ( stonesoup_col2 ) > 0 ) stonesoup_cols [ 1 ] = stonesoup_col2; if ( strlen ( stonesoup_col3 ) > 0 ) stonesoup_cols [ 2 ] = stonesoup_col3; stonesoup_temp = fopen ( "/opt/stonesoup/workspace/testData/myfile.txt" , "w+" ); if ( stonesoup_temp != 0 ) fputs ( stonesoup_cols [ 2 ] , stonesoup_temp ); | 149388/eng_table.c | SARD | 2 |
CWE134_Uncontrolled_Format_String__char_listen_socket_snprintf_83_bad::CWE134_Uncontrolled_Format_String__char_listen_socket_snprintf_83_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 ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 80392/CWE134_Uncontrolled_Format_String__char_listen_socket_snprintf_83_bad.cpp | SARD | 0 |
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 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 ); | 79104/CWE134_Uncontrolled_Format_String__char_connect_socket_fprintf_07.c | SARD | 0 |
void bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; CWE78_OS_Command_Injection__char_connect_socket_popen_84_bad * badObject = new CWE78_OS_Command_Injection__char_connect_socket_popen_84_bad ( data ) ; CWE78_OS_Command_Injection__char_connect_socket_popen_84_bad::CWE78_OS_Command_Injection__char_connect_socket_popen_84_bad(char * dataCopy) data = dataCopy; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 118086/CWE78_OS_Command_Injection__char_connect_socket_popen_84_bad.cpp | SARD | 0 |
void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_snprintf_04_bad() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataBuffer; if ( STATIC_CONST_TRUE ) memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; SNPRINTF ( dest , strlen ( data ) , "%s" , data ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 65755/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_snprintf_04.c | SARD | 3 |
static void goodG2B1() 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 ); | 87781/CWE195_Signed_to_Unsigned_Conversion_Error__fgets_strncpy_08.c | SARD | 0 |
void CWE190_Integer_Overflow__int_listen_socket_add_66_bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 83444/CWE190_Integer_Overflow__int_listen_socket_add_66a.c | SARD | 0 |
void CWE590_Free_Memory_Not_on_Heap__free_int64_t_declare_07_bad() int64_t * data ; data = NULL; if ( staticFive == 5 ) int64_t dataBuffer [ 100 ] ; size_t i ; for (i = 0; i < 100; i++) dataBuffer [ i ] = 5L L data = dataBuffer; free ( data ); | 108262/CWE590_Free_Memory_Not_on_Heap__free_int64_t_declare_07.c | SARD | 1 |
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalFive == 5 ) size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 80215/CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_14.c | SARD | 0 |
static void goodB2G1() char * data ; data = NULL; data = ( char * ) realloc ( data , 20 * sizeof ( char ) ); CWE690_NULL_Deref_From_Return__char_realloc_22_goodB2G1Sink ( data ); void CWE690_NULL_Deref_From_Return__char_realloc_22_goodB2G1Sink(char * data) if ( CWE690_NULL_Deref_From_Return__char_realloc_22_goodB2G1Global ) if ( data != NULL ) strcpy ( data , "Initialize" ); free ( data ); | 111093/CWE690_NULL_Deref_From_Return__char_realloc_22b.c | SARD | 0 |
static void goodG2B() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; strcat ( data , "file.txt" ); goodG2BSink_b ( data ); void goodG2BSink_b(char * data) goodG2BSink_c ( data ); void goodG2BSink_c(char * data) goodG2BSink_d ( data ); void goodG2BSink_d(char * data) goodG2BSink_e ( data ); void goodG2BSink_e(char * data) hFile = CreateFileA ( data , ( GENERIC_WRITE | GENERIC_READ ) , 0 , NULL , OPEN_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL ); if ( hFile != INVALID_HANDLE_VALUE ) CloseHandle ( hFile ); | 90044/CWE23_Relative_Path_Traversal__char_console_w32CreateFile_54a.cpp | SARD | 0 |
static void goodB2G() size_t data ; map < int , size_t > dataMap ; data = 0; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; goodB2GSink ( dataMap ); void goodB2GSink(map<int, size_t> dataMap) size_t data = dataMap [ 2 ] ; char * myString ; if ( data > strlen ( HELLO_STRING ) && data < 100 ) myString = ( char * ) malloc ( data * sizeof ( char ) ); strcpy ( myString , HELLO_STRING ); free ( myString ); | 117170/CWE789_Uncontrolled_Mem_Alloc__malloc_char_listen_socket_74b.cpp | SARD | 0 |
void CWE194_Unexpected_Sign_Extension__fgets_memmove_18_bad() char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = ( short ) atoi ( inputBuffer ); if ( data < 100 ) memmove ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 86591/CWE194_Unexpected_Sign_Extension__fgets_memmove_18.c | SARD | 20 |
static void goodB2G() int i , k ; 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 ) 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 ); if ( data != 0 ) printIntLine ( 100 / data ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 95266/CWE369_Divide_by_Zero__int_listen_socket_divide_17.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_file_execlp_44_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; fclose ( pFile ); funcPtr ( data ); | 119458/CWE78_OS_Command_Injection__char_file_execlp_44.c | SARD | 0 |
void bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; size_t dataLen = strlen ( data ) ; recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; badSink ( dataMap ); void badSink(map<int, char *> dataMap) char * data = dataMap [ 2 ] ; pipe = POPEN ( data , "wb" ); if ( pipe != NULL ) PCLOSE ( pipe ); | 120002/CWE78_OS_Command_Injection__char_listen_socket_popen_74a.cpp | SARD | 0 |
void CWE78_OS_Command_Injection__char_connect_socket_popen_63_bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; size_t dataLen = strlen ( data ) ; 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'; CWE78_OS_Command_Injection__char_connect_socket_popen_63b_badSink ( & data ); void CWE78_OS_Command_Injection__char_connect_socket_popen_63b_badSink(char * * dataPtr) char * data = * dataPtr ; pipe = POPEN ( data , "wb" ); if ( pipe != NULL ) PCLOSE ( pipe ); | 118074/CWE78_OS_Command_Injection__char_connect_socket_popen_63a.c | SARD | 0 |
void bad() wchar_t * data ; wchar_t * & dataRef = data ; wchar_t dataBadBuffer [ 50 ] ; wmemset ( dataBadBuffer , L 'A' , 50 - 1 dataBadBuffer [ 50 - 1 ] = L wmemset ( dataGoodBuffer , L 'A' , 100 - 1 dataGoodBuffer [ 100 - 1 ] = L '\0' data = dataBadBuffer; wchar_t * data = dataRef ; wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' memmove ( dest , data , wcslen ( dest ) * sizeof ( wchar_t ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 77030/CWE126_Buffer_Overread__wchar_t_declare_memmove_33.cpp | SARD | 3 |
void CWE78_OS_Command_Injection__char_file_w32_spawnvp_18_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 119832/CWE78_OS_Command_Injection__char_file_w32_spawnvp_18.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'; count = atoi ( inputBuffer ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); CWE400_Resource_Exhaustion__connect_socket_sleep_45_goodB2GData = count; | 98605/CWE400_Resource_Exhaustion__connect_socket_sleep_45.c | SARD | 0 |
static void goodB2G1() twoIntsStruct * data ; if ( staticFive == 5 ) data = ( twoIntsStruct * ) malloc ( 100 * sizeof ( twoIntsStruct ) ); data [ 0 ] . intOne = 0; data [ 0 ] . intTwo = 0; printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); free ( data ); | 100624/CWE401_Memory_Leak__twoIntsStruct_malloc_07.c | SARD | 0 |
static void goodG2B() char * dataBuffer = ( char * ) malloc ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; myStruct . structFirst = data; CWE590_Free_Memory_Not_on_Heap__free_char_static_67b_goodG2BSink ( myStruct ); void CWE590_Free_Memory_Not_on_Heap__free_char_static_67b_goodG2BSink(CWE590_Free_Memory_Not_on_Heap__free_char_static_67_structType myStruct) char * data = myStruct . structFirst ; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 108209/CWE590_Free_Memory_Not_on_Heap__free_char_static_67a.c | SARD | 0 |
static int airspy_probe(struct usb_interface const struct usb_device_id *id) struct airspy * s ; int ret ; s = kzalloc ( sizeof ( struct airspy ) , GFP_KERNEL ); if ( s == NULL ) s -> dev = & intf -> dev; s -> udev = interface_to_usbdev ( intf ); s -> f_adc = bands [ 0 ] . rangelow; s -> f_rf = bands_rf [ 0 ] . rangelow; s -> pixelformat = formats [ 0 ] . pixelformat; s -> buffersize = formats [ 0 ] . buffersize; ret = airspy_ctrl_msg ( s , CMD_BOARD_ID_READ , 0 , 0 , & u8tmp , 1 ); static int airspy_ctrl_msg(struct airspy *s, u8 request, u16 value, u16 u8 *data, u16 size) u8 requesttype ; switch ( request ) requesttype = ( USB_TYPE_VENDOR | USB_DIR_OUT ); requesttype = ( USB_TYPE_VENDOR | USB_DIR_IN ); if ( ! ( requesttype & USB_DIR_IN ) ) memcpy ( s -> buf , data , size ); ret = usb_control_msg ( s -> udev , pipe , request , requesttype , value , index , s -> buf , size , 1000 ); airspy_dbg_usb_control_msg ( s -> dev , request , requesttype , value , index , s -> buf , size ); if ( ret < 0 ) dev_err ( s -> dev , "usb_control_msg() failed %d request %02x\n" , ret , request ); memcpy ( data , s -> buf , size ); return ret ; | CVE-2016-5400/linux_kernel_4.6.5_CVE_2016_5400_drivers_media_usb_airspy_airspy.c | NVD | 0 |
void initlinedraw(int flag) static const char * latin1_3 [ ] = { ( "ISO-8859-1" ) , ( "ISO-8859-1:1987" ) , ( "ISO_8859-1" ) , ( "latin1" ) , ( "l1" ) , ( "IBM819" ) , ( "CP819" ) , ( "csISOLatin1" ) , ( "ISO-8859-3" ) , ( "ISO_8859-3:1988" ) , ( "ISO_8859-3" ) , ( "latin3" ) , ( "ls" ) , ( "csISOLatin3" ) , ( ( ( void * ) 0 ) ) } ; static const char * iso8859_789 [ ] = { ( "ISO-8859-7" ) , ( "ISO_8859-7:1987" ) , ( "ISO_8859-7" ) , ( "ELOT_928" ) , ( "ECMA-118" ) , ( "greek" ) , ( "greek8" ) , ( "csISOLatinGreek" ) , ( "ISO-8859-8" ) , ( "ISO_8859-8:1988" ) , ( "iso-ir-138" ) , ( "ISO_8859-8" ) , ( "hebrew" ) , ( "csISOLatinHebrew" ) , ( "ISO-8859-9" ) , ( "ISO_8859-9:1989" ) , ( "iso-ir-148" ) , ( "ISO_8859-9" ) , ( "latin5" ) , ( "l5" ) , ( "csISOLatin5" ) , ( ( ( void * ) 0 ) ) } ; static const char * shift_jis [ ] = { ( "Shift_JIS" ) , ( "MS_Kanji" ) , ( "csShiftJIS" ) , ( ( ( void * ) 0 ) ) } ; static const char * euc_jp [ ] = { ( "EUC-JP" ) , ( "Extended_UNIX_Code_Packed_Format_for_Japanese" ) , ( "csEUCPkdFmtJapanese" ) , ( ( ( void * ) 0 ) ) } ; static const char * euc_kr [ ] = { ( "EUC-KR" ) , ( "csEUCKR" ) , ( ( ( void * ) 0 ) ) } ; static const char * iso2022jp [ ] = { ( "ISO-2022-JP" ) , ( "csISO2022JP" ) , ( "ISO-2022-JP-2" ) , ( "csISO2022JP2" ) , ( ( ( void * ) 0 ) ) } ; static const char * ibm_pc [ ] = { ( "IBM437" ) , ( "cp437" ) , ( "437" ) , ( "csPC8CodePage437" ) , ( "IBM852" ) , ( "cp852" ) , ( "852" ) , ( "csPCp852" ) , ( "IBM863" ) , ( "cp863" ) , ( "863" ) , ( "csIBM863" ) , ( "IBM855" ) , ( "cp855" ) , ( "855" ) , ( "csIBM855" ) , ( "IBM865" ) , ( "cp865" ) , ( "865" ) , ( "csIBM865" ) , ( "IBM866" ) , ( "cp866" ) , ( "866" ) , ( "csIBM866" ) , ( ( ( void * ) 0 ) ) } ; static const char * ibm_ps2 [ ] = { ( "IBM850" ) , ( "cp850" ) , ( "850" ) , ( "csPC850Multilingual" ) , ( "IBM00858" ) , ( "CCSID00858" ) , ( "CP00858" ) , ( "PC-Multilingual-850+euro" ) , ( ( ( void * ) 0 ) ) } ; static const char * ibm_gr [ ] = { ( "IBM869" ) , ( "cp869" ) , ( "869" ) , ( "cp-gr" ) , ( "csIBM869" ) , ( ( ( void * ) 0 ) ) } ; static const char * gb [ ] = { ( "GB2312" ) , ( "csGB2312" ) , ( ( ( void * ) 0 ) ) } ; static const char * utf8 [ ] = { ( "UTF-8" ) , ( "utf8" ) , ( ( ( void * ) 0 ) ) } ; static const char * big5 [ ] = { ( "Big5" ) , ( "csBig5" ) , ( ( ( void * ) 0 ) ) } ; static const char * viscii [ ] = { ( "VISCII" ) , ( "csVISCII" ) , ( ( ( void * ) 0 ) ) } ; static const char * koi8ru [ ] = { ( "KOI8-R" ) , ( "csKOI8R" ) , ( "KOI8-U" ) , ( ( ( void * ) 0 ) ) } ; static const char * windows [ ] = { ( "ISO-8859-1-Windows-3.1-Latin-1" ) , ( "csWindows31Latin1" ) , ( "ISO-8859-2-Windows-Latin-2" ) , ( "csWindows31Latin2" ) , ( "windows-1250" ) , ( "windows-1251" ) , ( "windows-1253" ) , ( "windows-1254" ) , ( "windows-1255" ) , ( "windows-1256" ) , ( "windows-1256" ) , ( "windows-1257" ) , ( ( ( void * ) 0 ) ) } ; static const struct linedraw cstable [ ] = { { ( latin1_3 ) , ( "| " ) , ( "|--" ) , ( "·--" ) , ( "©" ) } , { ( iso8859_789 ) , ( "| " ) , ( "|--" ) , ( "·--" ) , ( "(c)" ) } , { ( shift_jis ) , ( "\204\240 " ) , ( "\204\245" ) , ( "\204\244" ) , ( "(c)" ) } , { ( euc_jp ) , ( "\250\242 " ) , ( "\250\247" ) , ( "\250\246" ) , ( "(c)" ) } , { ( euc_kr ) , ( "\246\242 " ) , ( "\246\247" ) , ( "\246\246" ) , ( "(c)" ) } , { ( iso2022jp ) , ( "\033$B(\"\033(B " ) , ( "\033$B('\033(B" ) , ( "\033$B(&\033(B" ) , ( "(c)" ) } , { ( ibm_pc ) , ( "\263 " ) , ( "\303\304\304" ) , ( "\300\304\304" ) , ( "(c)" ) } , { ( ibm_ps2 ) , ( "\263 " ) , ( "\303\304\304" ) , ( "\300\304\304" ) , ( "\227" ) } , { ( ibm_gr ) , ( "\263 " ) , ( "\303\304\304" ) , ( "\300\304\304" ) , ( "\270" ) } , { ( gb ) , ( "\251\246 " ) , ( "\251\300" ) , ( "\251\270" ) , ( "(c)" ) } , { ( utf8 ) , ( "\342\224\202\302\240\302\240" ) , ( "\342\224\234\342\224\200\342\224\200" ) , ( "\342\224\224\342\224\200\342\224\200" ) , ( "\302\251" ) } , { ( big5 ) , ( "\242x " ) , ( "\242u" ) , ( "\242|" ) , ( "(c)" ) } , { ( viscii ) , ( "| " ) , ( "|--" ) , ( "`--" ) , ( "\371" ) } , { ( koi8ru ) , ( "\201 " ) , ( "\206\200\200" ) , ( "\204\200\200" ) , ( "\277" ) } , { ( windows ) , ( "| " ) , ( "|--" ) , ( "`--" ) , ( "\251" ) } , { ( ( ( void * ) 0 ) ) , ( "| " ) , ( "|--" ) , ( "`--" ) , ( "(c)" ) } } ; const char * * s ; if ( flag ) fprintf ( stderr , "tree: missing argument to --charset, valid charsets include:\n" ); for (linedraw = cstable; linedraw -> name; ++linedraw) for (s = linedraw -> name; *s; ++s) fprintf ( stderr , " %s\n" , * s ); | 151261/color.c | SARD | 0 |
static void goodG2B1() int data ; data = - 1; if ( STATIC_CONST_FIVE != 5 ) data = 100 - 1; char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) strncpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 87587/CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_strncpy_06.c | SARD | 0 |
static void goodB2G() int * data ; data = NULL; data = ( int * ) realloc ( data , 1 * sizeof ( int ) ); CWE690_NULL_Deref_From_Return__int_realloc_53b_goodB2GSink ( data ); void CWE690_NULL_Deref_From_Return__int_realloc_53b_goodB2GSink(int * data) CWE690_NULL_Deref_From_Return__int_realloc_53c_goodB2GSink ( data ); void CWE690_NULL_Deref_From_Return__int_realloc_53c_goodB2GSink(int * data) CWE690_NULL_Deref_From_Return__int_realloc_53d_goodB2GSink ( data ); void CWE690_NULL_Deref_From_Return__int_realloc_53d_goodB2GSink(int * data) if ( data != NULL ) data [ 0 ] = 5; printIntLine ( data [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( data ); | 111441/CWE690_NULL_Deref_From_Return__int_realloc_53a.c | SARD | 0 |
void bad() char * data ; char * & dataRef = data ; data = NULL; data = ( char * ) malloc ( 50 * sizeof ( char ) ); data [ 0 ] = '\0'; char * data = dataRef ; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcat ( data , source ); free ( data ); | 72822/CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cat_33.cpp | SARD | 3 |
static void CVE_2012_3553_VULN_setsubstate(struct skinny_subchannel *sub, int state) struct skinny_line * l = sub -> line ; struct skinny_subline * subline = sub -> subline ; struct skinny_device * d = l -> device ; struct ast_channel * c = sub -> owner ; int actualstate = state ; if ( sub -> substate == SUBSTATE_ONHOOK ) if ( state != SUBSTATE_RINGIN && sub -> aa_sched ) sub -> aa_sched = 0; sub -> aa_beep = 0; sub -> aa_mute = 0; if ( ( state == SUBSTATE_RINGIN ) && ( ( d -> hookstate == SKINNY_OFFHOOK ) || ( AST_LIST_NEXT ( AST_LIST_FIRST ( & l -> sub ) , list ) ) ) ) actualstate = SUBSTATE_CALLWAIT; if ( ( state == SUBSTATE_CONNECTED ) && ( ! subline ) && ( AST_LIST_FIRST ( & l -> sublines ) ) ) const char * slastation ; struct skinny_subline * tmpsubline ; slastation = pbx_builtin_getvar_helper ( c , "SLASTATION" ); if ( slastation ) subline = tmpsubline; if ( subline ) subline -> sub = sub; sub -> subline = subline; subline -> callid = sub -> callid; if ( subline ) switch ( actualstate ) if ( sub -> related ) sub -> related -> related = NULL; sub -> cxmode = SKINNY_CX_RECVONLY; sub -> substate = SUBSTATE_ONHOOK; if ( sub -> rtp ) sub -> rtp = NULL; sub -> substate = SUBSTATE_ONHOOK; sub -> substate = SUBSTATE_CONNECTED; if ( sub -> substate != SUBSTATE_CONNECTED ) sub -> substate = SUBSTATE_HOLD; if ( ( d -> hookstate == SKINNY_ONHOOK ) && ( ( actualstate == SUBSTATE_OFFHOOK ) || ( actualstate == SUBSTATE_DIALING ) || ( actualstate == SUBSTATE_RINGOUT ) || ( actualstate == SUBSTATE_CONNECTED ) || ( actualstate == SUBSTATE_BUSY ) || ( actualstate == SUBSTATE_CONGESTION ) || ( actualstate == SUBSTATE_PROGRESS ) ) ) d -> hookstate = SKINNY_OFFHOOK; if ( actualstate == sub -> substate ) switch ( actualstate ) l -> activesub = sub; sub -> substate = SUBSTATE_OFFHOOK; if ( sub -> related ) sub -> related -> related = NULL; if ( sub == l -> activesub ) l -> activesub = NULL; sub -> cxmode = SKINNY_CX_RECVONLY; sub -> substate = SUBSTATE_ONHOOK; if ( sub -> rtp ) sub -> rtp = NULL; if ( ast_strlen_zero ( sub -> exten ) || ! ast_exists_extension ( c , c -> context , sub -> exten , 1 , l -> cid_num ) ) if ( d -> hookstate == SKINNY_ONHOOK ) d -> hookstate = SKINNY_OFFHOOK; sub -> substate = SUBSTATE_DIALING; if ( ! ( sub -> substate == SUBSTATE_DIALING || sub -> substate == SUBSTATE_PROGRESS ) ) sub -> substate = SUBSTATE_RINGOUT; if ( d -> hookstate == SKINNY_ONHOOK ) l -> activesub = sub; sub -> substate = SUBSTATE_RINGIN; sub -> substate = SUBSTATE_CALLWAIT; sub -> substate = SUBSTATE_CONNECTED; l -> activesub = sub; if ( ! ( sub -> substate == SUBSTATE_DIALING || sub -> substate == SUBSTATE_PROGRESS || sub -> substate == SUBSTATE_RINGOUT ) ) sub -> substate = SUBSTATE_BUSY; if ( ! ( sub -> substate == SUBSTATE_DIALING || sub -> substate == SUBSTATE_PROGRESS || sub -> substate == SUBSTATE_RINGOUT ) ) sub -> substate = SUBSTATE_CONGESTION; if ( sub -> substate != SUBSTATE_DIALING ) sub -> substate = SUBSTATE_PROGRESS; if ( sub -> substate != SUBSTATE_CONNECTED ) ast_queue_control_data ( sub -> owner , AST_CONTROL_HOLD , S_OR ( l -> mohsuggest , NULL ) , ! ast_strlen_zero ( l -> mohsuggest ) ? strlen ( l -> mohsuggest ) + 1 : 0 ); | CVE-2012-3553/CVE_2012_3553_VULN_setsubstate.c | NVD | 0 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; goodB2GSink ( data ); static void goodB2GSink(char * data) printf ( "%s\n" , data ); | 80034/CWE134_Uncontrolled_Format_String__char_file_printf_41.c | SARD | 0 |
static void goodG2B1() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataBuffer; if ( staticFive != 5 ) memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; char dest [ 50 ] = "" ; memmove ( dest , data , strlen ( data ) * sizeof ( char ) ); dest [ 50 - 1 ] = '\0'; | 65614/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_memmove_07.c | SARD | 0 |
static void goodG2B() char dataGoodBuffer [ 100 ] ; memset ( dataGoodBuffer , 'A' , 100 - 1 ); dataGoodBuffer [ 100 - 1 ] = '\0'; data = dataGoodBuffer; CWE126_Buffer_Overread__char_declare_loop_53b_goodG2BSink ( data ); void CWE126_Buffer_Overread__char_declare_loop_53b_goodG2BSink(char * data) CWE126_Buffer_Overread__char_declare_loop_53c_goodG2BSink ( data ); void CWE126_Buffer_Overread__char_declare_loop_53c_goodG2BSink(char * data) CWE126_Buffer_Overread__char_declare_loop_53d_goodG2BSink ( data ); void CWE126_Buffer_Overread__char_declare_loop_53d_goodG2BSink(char * data) dest [ i ] = data [ i ]; dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 76123/CWE126_Buffer_Overread__char_declare_loop_53a.c | SARD | 0 |
static void goodG2B2() wchar_t * data ; wchar_t dataGoodBuffer [ 100 ] ; if ( GLOBAL_CONST_TRUE ) data = dataGoodBuffer; data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memcpy ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 65320/CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_memcpy_09.c | SARD | 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 ) 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 ); badSink_b ( data ); void badSink_b(char * data) badSink_c ( data ); void badSink_c(char * data) badSink_d ( data ); void badSink_d(char * data) badSink_e ( data ); void badSink_e(char * data) inputFile . open ( ( char * ) data ); | 89660/CWE23_Relative_Path_Traversal__char_connect_socket_ifstream_54a.cpp | SARD | 0 |
void CWE134_Uncontrolled_Format_String__wchar_t_console_printf_12_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; size_t dataLen = wcslen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = wcslen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == L '\n' ) | 80885/CWE134_Uncontrolled_Format_String__wchar_t_console_printf_12.c | SARD | 0 |
static void goodB2G() size_t data ; data = 0; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) goodB2GSink ( data ); static void goodB2GSink(size_t data) if ( data > wcslen ( HELLO_STRING ) && data < 100 ) | 117391/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_listen_socket_41.c | SARD | 0 |
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_connect_socket_07_bad() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 ) | 112525/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_connect_socket_07.c | SARD | 0 |
static void goodB2G() int i , k ; 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 ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); if ( data > 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 | 117623/CWE789_Uncontrolled_Mem_Alloc__new_char_listen_socket_17.cpp | 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" ); stonesoup_printf_context = fopen ( filepath , "w" ); free ( filepath ); if ( stonesoup_printf_context == NULL ) | 149421/emem.c | SARD | 0 |
static void goodB2G1() size_t data ; data = 0; if ( globalFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( globalFive != 5 ) if ( data > wcslen ( HELLO_STRING ) && data < 100 ) | 117236/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_14.c | SARD | 0 |
static void build_state(state_num s,struct dfa *d) state_num * trans ; 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[]) 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 ) ) setbit ( d -> tokens [ pos . index ] , matches ); static void setbit(unsigned int b,charclass c) c [ b / ( 8 * sizeof ( int ) ) ] |= 1 << b % ( 8 * sizeof ( int ) ); if ( d -> tokens [ pos . index ] >= CSET ) copyset ( d -> charclasses [ d -> tokens [ pos . index ] - CSET ] , matches ); static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) ); if ( 1 && ( d -> tokens [ pos . index ] == ANYCHAR || d -> tokens [ pos . index ] == MBCSET ) ) if ( d -> states [ s ] . mbps . nelem == 0 ) alloc_position_set ( & d -> states [ s ] . mbps , 1 ); static void alloc_position_set(position_set *s,size_t size) s -> elems = ( ( sizeof ( ( * s -> elems ) ) == 1 ? xmalloc ( size ) : xnmalloc ( size , sizeof ( ( * s -> elems ) ) ) ) ); s -> alloc = size; s -> nelem = 0; insert ( pos , & d -> states [ s ] . mbps ); static void insert(position p,position_set *s) size_t count = s -> nelem ; size_t hi = count ; while ( lo < hi ) size_t mid = lo + hi >> 1 ; if ( s -> elems [ mid ] . index > p . index ) lo = mid + 1; hi = mid; if ( lo < count && p . index == s -> elems [ lo ] . index ) s -> elems [ lo ] . constraint |= p . constraint; if ( s -> alloc <= count + 1 ) size_t new_n_alloc = count + 1 + ( ! s -> elems ) ; s -> elems = ( x2nrealloc ( ( s -> elems ) , & new_n_alloc , sizeof ( ( * s -> elems ) ) ) ); s -> alloc = new_n_alloc; for (i = count; i > lo; i--) s -> elems [ i ] = s -> elems [ i - 1 ]; s -> elems [ lo ] = p; ++ s -> nelem; 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 ) ) 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 ]; for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )) && !matches[j]; ++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 ] ) ) static int tstbit(unsigned int b,const int c[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) return c [ b / ( 8 * sizeof ( int ) ) ] & 1 << b % ( 8 * sizeof ( int ) ) ; ( intersect [ k ] = matches [ k ] & labels [ j ] [ k ] ) ? ( intersectf = 1 ) : 0; if ( ! intersectf ) 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 ) copyset ( leftovers , labels [ ngrps ] ); static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) ); copyset ( intersect , labels [ j ] ); static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) ); grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); 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 ) copyset ( matches , labels [ ngrps ] ); static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) ); grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); grps [ ngrps ] . nelem = 1; grps [ ngrps ] . elems [ 0 ] = pos . index; alloc_position_set ( & follows , d -> nleaves ); static void alloc_position_set(position_set *s,size_t size) s -> elems = ( ( sizeof ( ( * s -> elems ) ) == 1 ? xmalloc ( size ) : xnmalloc ( size , sizeof ( ( * s -> elems ) ) ) ) ); s -> alloc = size; s -> nelem = 0; alloc_position_set ( & tmp , d -> nleaves ); static void alloc_position_set(position_set *s,size_t size) s -> elems = ( ( sizeof ( ( * s -> elems ) ) == 1 ? xmalloc ( size ) : xnmalloc ( size , sizeof ( ( * s -> elems ) ) ) ) ); s -> alloc = size; s -> nelem = 0; if ( d -> searchflag ) copy ( ( & d -> states [ 0 ] . elems ) , & follows ); static void copy(const position_set *src,position_set *dst) if ( dst -> alloc <= src -> nelem ) size_t new_n_alloc = src -> nelem + ( ! dst -> elems ) ; dst -> elems = ( x2nrealloc ( ( dst -> elems ) , & new_n_alloc , sizeof ( ( * dst -> elems ) ) ) ); dst -> alloc = new_n_alloc; memcpy ( ( dst -> elems ) , ( src -> elems ) , sizeof ( dst -> elems [ 0 ] ) * src -> nelem ); dst -> nelem = src -> nelem; state = state_index ( d , ( & follows ) , separate_contexts ^ 7 ); static state_num state_index(struct dfa *d,const position_set *s,int context) for (i = 0; i < s -> nelem; ++i) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; for (i = 0; i < d -> sindex; ++i) if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) for (j = 0; j < s -> nelem; ++j) if ( s -> elems [ j ] . constraint != d -> states [ i ] . elems . elems [ j ] . constraint || s -> elems [ j ] . index != d -> states [ i ] . elems . elems [ j ] . index ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; d -> states [ i ] . hash = hash; alloc_position_set ( & d -> states [ i ] . elems , s -> nelem ); static void alloc_position_set(position_set *s,size_t size) s -> elems = ( ( sizeof ( ( * s -> elems ) ) == 1 ? xmalloc ( size ) : xnmalloc ( size , sizeof ( ( * s -> elems ) ) ) ) ); s -> alloc = size; s -> nelem = 0; copy ( s , & d -> states [ i ] . elems ); static void copy(const position_set *src,position_set *dst) if ( dst -> alloc <= src -> nelem ) size_t new_n_alloc = src -> nelem + ( ! dst -> elems ) ; dst -> elems = ( x2nrealloc ( ( dst -> elems ) , & new_n_alloc , sizeof ( ( * dst -> elems ) ) ) ); dst -> alloc = new_n_alloc; memcpy ( ( dst -> elems ) , ( src -> elems ) , sizeof ( dst -> elems [ 0 ] ) * src -> nelem ); dst -> nelem = src -> nelem; d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); for (j = 0; j < s -> nelem; ++j) if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; ++ d -> sindex; return i ; state_newline = state_index ( d , ( & follows ) , 4 ); static state_num state_index(struct dfa *d,const position_set *s,int context) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( s -> elems [ j ] . constraint != d -> states [ i ] . elems . elems [ j ] . constraint || s -> elems [ j ] . index != d -> states [ i ] . elems . elems [ j ] . index ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; d -> states [ i ] . hash = hash; alloc_position_set ( & d -> states [ i ] . elems , s -> nelem ); copy ( s , & d -> states [ i ] . elems ); d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; ++ d -> sindex; return i ; state_newline = state; state_letter = state_index ( d , ( & follows ) , 2 ); static state_num state_index(struct dfa *d,const position_set *s,int context) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( s -> elems [ j ] . constraint != d -> states [ i ] . elems . elems [ j ] . constraint || s -> elems [ j ] . index != d -> states [ i ] . elems . elems [ j ] . index ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; d -> states [ i ] . hash = hash; alloc_position_set ( & d -> states [ i ] . elems , s -> nelem ); copy ( s , & d -> states [ i ] . elems ); d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; ++ d -> sindex; return i ; state_letter = state; trans [ i ] = ( 1 && ( ( * __ctype_b_loc ( ) ) [ ( int ) i ] & ( ( unsigned short ) _ISalnum ) || i == '_' ) ? state_letter : state ); trans [ eolbyte ] = state_newline; trans [ i ] = ( - 1 ); for (i = 0; i < ngrps; ++i) for (j = 0; j < grps[i] . nelem; ++j) for (k = 0; k < d -> follows[grps[i] . elems[j]] . nelem; ++k) insert ( d -> follows [ grps [ i ] . elems [ j ] ] . elems [ k ] , & follows ); static void insert(position p,position_set *s) size_t count = s -> nelem ; size_t hi = count ; while ( lo < hi ) size_t mid = lo + hi >> 1 ; if ( s -> elems [ mid ] . index > p . index ) lo = mid + 1; hi = mid; if ( lo < count && p . index == s -> elems [ lo ] . index ) s -> elems [ lo ] . constraint |= p . constraint; if ( s -> alloc <= count + 1 ) size_t new_n_alloc = count + 1 + ( ! s -> elems ) ; s -> elems = ( x2nrealloc ( ( s -> elems ) , & new_n_alloc , sizeof ( ( * s -> elems ) ) ) ); s -> alloc = new_n_alloc; s -> elems [ i ] = s -> elems [ i - 1 ]; s -> elems [ lo ] = p; ++ s -> nelem; if ( d -> mb_cur_max > 1 ) if ( ! ( d -> multibyte_prop [ follows . elems [ j ] . index ] & 1 ) ) if ( d -> searchflag && ( ! 1 || ( d -> mb_cur_max == 1 || ! next_isnt_1st_byte ) ) ) for (j = 0; j < d -> states[0] . elems . nelem; ++j) insert ( d -> states [ 0 ] . elems . elems [ j ] , & follows ); static void insert(position p,position_set *s) size_t count = s -> nelem ; size_t hi = count ; while ( lo < hi ) size_t mid = lo + hi >> 1 ; if ( s -> elems [ mid ] . index > p . index ) lo = mid + 1; hi = mid; if ( lo < count && p . index == s -> elems [ lo ] . index ) s -> elems [ lo ] . constraint |= p . constraint; if ( s -> alloc <= count + 1 ) size_t new_n_alloc = count + 1 + ( ! s -> elems ) ; s -> elems = ( x2nrealloc ( ( s -> elems ) , & new_n_alloc , sizeof ( ( * s -> elems ) ) ) ); s -> alloc = new_n_alloc; s -> elems [ i ] = s -> elems [ i - 1 ]; s -> elems [ lo ] = p; ++ s -> nelem; possible_contexts = charclass_context ( labels [ i ] ); static int charclass_context(charclass c) if ( tstbit ( eolbyte , c ) ) static int tstbit(unsigned int b,const int c[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) return c [ b / ( 8 * sizeof ( int ) ) ] & 1 << b % ( 8 * sizeof ( int ) ) ; if ( c [ j ] & letters [ j ] ) if ( c [ j ] & ~ ( letters [ j ] | newline [ j ] ) ) if ( ( separate_contexts & possible_contexts ) != possible_contexts ) state = state_index ( d , ( & follows ) , separate_contexts ^ 7 ); static state_num state_index(struct dfa *d,const position_set *s,int context) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( s -> elems [ j ] . constraint != d -> states [ i ] . elems . elems [ j ] . constraint || s -> elems [ j ] . index != d -> states [ i ] . elems . elems [ j ] . index ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; d -> states [ i ] . hash = hash; alloc_position_set ( & d -> states [ i ] . elems , s -> nelem ); copy ( s , & d -> states [ i ] . elems ); d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; ++ d -> sindex; return i ; if ( separate_contexts & possible_contexts & 4 ) state_newline = state_index ( d , ( & follows ) , 4 ); static state_num state_index(struct dfa *d,const position_set *s,int context) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( s -> elems [ j ] . constraint != d -> states [ i ] . elems . elems [ j ] . constraint || s -> elems [ j ] . index != d -> states [ i ] . elems . elems [ j ] . index ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; d -> states [ i ] . hash = hash; alloc_position_set ( & d -> states [ i ] . elems , s -> nelem ); copy ( s , & d -> states [ i ] . elems ); d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; ++ d -> sindex; return i ; state_newline = state; if ( separate_contexts & possible_contexts & 2 ) state_letter = state_index ( d , ( & follows ) , 2 ); static state_num state_index(struct dfa *d,const position_set *s,int context) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( s -> elems [ j ] . constraint != d -> states [ i ] . elems . elems [ j ] . constraint || s -> elems [ j ] . index != d -> states [ i ] . elems . elems [ j ] . index ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; d -> states [ i ] . hash = hash; alloc_position_set ( & d -> states [ i ] . elems , s -> nelem ); copy ( s , & d -> states [ i ] . elems ); d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; ++ d -> sindex; return i ; state_letter = state; if ( labels [ i ] [ j ] & 1 << k ) if ( c == eolbyte ) trans [ c ] = state_newline; if ( 1 && ( ( * __ctype_b_loc ( ) ) [ ( int ) c ] & ( ( unsigned short ) _ISalnum ) || c == '_' ) ) trans [ c ] = state_letter; trans [ c ] = state; for (i = 0; i < ngrps; ++i) free ( grps [ i ] . elems ); free ( grps ); if ( trans [ i ] >= d -> tralloc ) while ( trans [ i ] >= d -> tralloc ) d -> newlines [ s ] = trans [ eolbyte ]; trans [ eolbyte ] = ( - 1 ); if ( ( * d ) . states [ s ] . constraint ) d -> fails [ s ] = trans; d -> trans [ s ] = trans; | 151732/dfa.c | SARD | 0 |
static void goodG2B() int h , j ; size_t data ; data = 0; for(h = 0; h < 1; h++) data = 20; for(j = 0; j < 1; j++) char * myString ; if ( data > strlen ( HELLO_STRING ) ) myString = ( char * ) malloc ( data * sizeof ( char ) ); strcpy ( myString , HELLO_STRING ); printLine ( myString ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( myString ); | 117143/CWE789_Uncontrolled_Mem_Alloc__malloc_char_listen_socket_17.c | SARD | 0 |
static void goodB2G1() if ( staticTrue ) 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 ( data > INT_MIN ) int result = data - 1 ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 85618/CWE191_Integer_Underflow__int_listen_socket_sub_05.c | SARD | 0 |
static void goodB2G2() if ( globalTrue ) 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 ( data < 0 ) if ( data > ( INT_MIN / 2 ) ) int result = data * 2 ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 85575/CWE191_Integer_Underflow__int_listen_socket_multiply_10.c | SARD | 0 |
static int seek_frame_generic(AVFormatContext *s,int stream_index,int64_t timestamp,int flags) int index ; int64_t ret ; AVStream * st ; AVIndexEntry * ie ; st = s -> streams [ stream_index ]; index = av_index_search_timestamp ( st , timestamp , flags ); if ( index < 0 && st -> nb_index_entries && timestamp < st -> index_entries [ 0 ] . timestamp ) if ( index < 0 || index == st -> nb_index_entries - 1 ) AVPacket pkt ; int nonkey = 0 ; if ( st -> nb_index_entries ) ie = & st -> index_entries [ st -> nb_index_entries - 1 ]; if ( ( ret = avio_seek ( s -> pb , ie -> pos , 0 ) ) < 0 ) if ( ( ret = avio_seek ( s -> pb , s -> data_offset , 0 ) ) < 0 ) int read_status ; read_status = av_read_frame ( s , & pkt ); while ( read_status == - '\v' ) if ( read_status < 0 ) if ( stream_index == pkt . stream_index && pkt . dts > timestamp ) if ( pkt . flags & 0x1 ) if ( nonkey ++ > 1000 && ( st -> codec -> codec_id ) != AV_CODEC_ID_CDGRAPHICS ) int av_read_frame(AVFormatContext *s,AVPacket *pkt) const int genpts = s -> flags & 0x1 ; int eof = 0 ; int ret ; if ( ! genpts ) AVPacketList * pktl = s -> packet_buffer ; if ( pktl ) AVPacket * next_pkt = & pktl -> pkt ; if ( next_pkt -> dts != ( ( int64_t ) 0x8000000000000000UL ) ) int wrap_bits = s -> streams [ next_pkt -> stream_index ] -> pts_wrap_bits ; int64_t last_dts = next_pkt -> dts ; while ( pktl && next_pkt -> pts == ( ( int64_t ) 0x8000000000000000UL ) ) if ( pktl -> pkt . stream_index == next_pkt -> stream_index && av_compare_mod ( ( next_pkt -> dts ) , pktl -> pkt . dts , ( 2 << wrap_bits - 1 ) ) < 0 ) if ( av_compare_mod ( pktl -> pkt . pts , pktl -> pkt . dts , ( 2 << wrap_bits - 1 ) ) ) next_pkt -> pts = pktl -> pkt . dts; if ( last_dts != ( ( int64_t ) 0x8000000000000000UL ) ) last_dts = pktl -> pkt . dts; pktl = pktl -> next; if ( eof && next_pkt -> pts == ( ( int64_t ) 0x8000000000000000UL ) && last_dts != ( ( int64_t ) 0x8000000000000000UL ) ) next_pkt -> pts = last_dts + ( next_pkt -> duration ); pktl = s -> packet_buffer; if ( ! ( next_pkt -> pts == ( ( int64_t ) 0x8000000000000000UL ) && next_pkt -> dts != ( ( int64_t ) 0x8000000000000000UL ) && ! eof ) ) ret = read_frame_internal ( s , pkt ); if ( ret < 0 ) if ( pktl && ret != - '\v' ) eof = 1; if ( av_dup_packet ( add_to_pktbuf ( & s -> packet_buffer , pkt , & s -> packet_buffer_end ) ) < 0 ) static int read_frame_internal(AVFormatContext *s,AVPacket *pkt) int got_packet = 0 ; while ( ! got_packet && ! s -> parse_queue ) AVStream * st ; AVPacket cur_pkt ; ret = ff_read_packet ( s , & cur_pkt ); if ( ret < 0 ) st = s -> streams [ cur_pkt . stream_index ]; if ( st -> need_parsing && ! st -> parser && ! ( s -> flags & 0x20 ) ) st -> parser = av_parser_init ( ( st -> codec -> codec_id ) ); if ( ! st -> parser ) st -> need_parsing = AVSTREAM_PARSE_NONE; if ( ( st -> need_parsing ) == AVSTREAM_PARSE_HEADERS ) st -> parser -> flags |= 0x1; if ( ( st -> need_parsing ) == AVSTREAM_PARSE_FULL_ONCE ) st -> parser -> flags |= 0x0002; if ( ( st -> need_parsing ) == AVSTREAM_PARSE_FULL_RAW ) st -> parser -> flags |= 0x1000; if ( ! st -> need_parsing || ! st -> parser ) * pkt = cur_pkt; compute_pkt_fields ( s , st , ( ( void * ) 0 ) , pkt ); got_packet = 1; if ( ( st -> discard ) < AVDISCARD_ALL ) if ( ( ret = parse_packet ( s , & cur_pkt , cur_pkt . stream_index ) ) < 0 ) if ( pkt -> flags & 0x1 ) st -> skip_to_keyframe = 0; if ( st -> skip_to_keyframe ) if ( got_packet ) * pkt = cur_pkt; got_packet = 0; static void compute_pkt_fields(AVFormatContext *s,AVStream *st,AVCodecParserContext *pc,AVPacket *pkt) int presentation_delayed ; int delay ; if ( s -> flags & 0x0010 ) if ( s -> flags & 0x0008 && pkt -> pts != ( ( int64_t ) 0x8000000000000000UL ) ) pkt -> dts = ( ( int64_t ) 0x8000000000000000UL ); if ( ( st -> codec -> codec_id ) != AV_CODEC_ID_H264 && pc && pc -> pict_type == AV_PICTURE_TYPE_B ) st -> codec -> has_b_frames = 1; delay = st -> codec -> has_b_frames; presentation_delayed = 0; if ( delay && pc && pc -> pict_type != AV_PICTURE_TYPE_B ) presentation_delayed = 1; if ( delay == 1 && pkt -> dts == pkt -> pts && pkt -> dts != ( ( int64_t ) 0x8000000000000000UL ) && presentation_delayed ) if ( strcmp ( s -> iformat -> name , "mov,mp4,m4a,3gp,3g2,mj2" ) ) | 149427/utils.c | SARD | 0 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; goodB2GSink ( dataMap ); void goodB2GSink(map<int, char *> dataMap) char * data = dataMap [ 2 ] ; goodB2GVaSink ( data , data ); static void goodB2GVaSink(char * data, ...) va_start ( args , data ); | 80485/CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_74a.cpp | SARD | 0 |
void CWE78_OS_Command_Injection__char_connect_socket_popen_32_bad() char * data ; char * * dataPtr1 = & data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; char * data = * dataPtr1 ; size_t dataLen = strlen ( data ) ; 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'; * dataPtr1 = data; pipe = POPEN ( data , "wb" ); if ( pipe != NULL ) PCLOSE ( pipe ); | 118060/CWE78_OS_Command_Injection__char_connect_socket_popen_32.c | SARD | 15 |
inline static svn_error_t *skip_bom(parse_context_t *ctx) char * subsyndicate_fluxweed ; if ( __sync_bool_compare_and_swap ( & footslogging_helenin , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) subsyndicate_fluxweed = getenv ( "PRELA_VOROSHILOVSK" ); if ( subsyndicate_fluxweed != 0 ) indeterminacies_manubrium = ( ( int ) ( strlen ( subsyndicate_fluxweed ) ) ); beboss_underworked = ( ( char * ) ( malloc ( indeterminacies_manubrium + 1 ) ) ); memset ( beboss_underworked , 0 , indeterminacies_manubrium + 1 ); memcpy ( beboss_underworked , subsyndicate_fluxweed , indeterminacies_manubrium ); spaework_outjinxes = & beboss_underworked; psalmists_hierogram = spaework_outjinxes + 5; rhizophore_charnu = ( ( char * ) ( * ( psalmists_hierogram - 5 ) ) ); stonesoup_tainted_int = atoi ( rhizophore_charnu ); if ( stonesoup_tainted_int > 0 ) stonesoup_tainted_int = stonesoup_tainted_int * stonesoup_tainted_int; tracepoint ( stonesoup_trace , variable_signed_integral , "stonesoup_tainted_int" , stonesoup_tainted_int , & stonesoup_tainted_int , "TRIGGER-STATE" ); while ( stonesoup_tainted_int != 0 ) if ( stonesoup_tainted_int != INT_MIN ) stonesoup_tainted_int --; if ( * ( psalmists_hierogram - 5 ) != 0 ) free ( ( ( char * ) ( * ( psalmists_hierogram - 5 ) ) ) ); | 151055/config_file.c | SARD | 18 |
void CWE78_OS_Command_Injection__char_console_w32_execv_41_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; | 118639/CWE78_OS_Command_Injection__char_console_w32_execv_41.c | SARD | 0 |
void CWE195_Signed_to_Unsigned_Conversion_Error__rand_memmove_05_bad() int data ; data = - 1; if ( staticTrue ) data = RAND32 ( ); char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) memmove ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 88498/CWE195_Signed_to_Unsigned_Conversion_Error__rand_memmove_05.c | SARD | 20 |
void CWE190_Integer_Overflow__int_fgets_square_22_bad() char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); CWE190_Integer_Overflow__int_fgets_square_22_badSink ( data ); void CWE190_Integer_Overflow__int_fgets_square_22_badSink(int data) int result = data * data ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 83233/CWE190_Integer_Overflow__int_fgets_square_22a.c | SARD | 0 |
void CWE121_Stack_Based_Buffer_Overflow__CWE129_listen_socket_31_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 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); int dataCopy = data ; int data = dataCopy ; if ( data >= 0 ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 62728/CWE121_Stack_Based_Buffer_Overflow__CWE129_listen_socket_31.c | SARD | 3 |
void CWE124_Buffer_Underwrite__malloc_wchar_t_memcpy_31_bad() wchar_t * data ; 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; wchar_t * dataCopy = data ; wchar_t * data = dataCopy ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memcpy ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 74594/CWE124_Buffer_Underwrite__malloc_wchar_t_memcpy_31.c | SARD | 3 |
void CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_08_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 80449/CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_08.c | SARD | 0 |
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; if ( staticFive == 5 ) 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 ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); | 91746/CWE23_Relative_Path_Traversal__wchar_t_listen_socket_fopen_07.cpp | 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 ] ) if ( strcasecmp ( "target" , c [ 1 ] ) == 0 ) link_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); | 152661/color.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncat_67_bad() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; myStruct . structFirst = data; CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncat_67b_badSink ( myStruct ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncat_67b_badSink(CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncat_67_structType myStruct) char * data = myStruct . structFirst ; strncat ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 72407/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncat_67a.c | SARD | 0 |
static void goodB2G() twoIntsStruct * data ; twoIntsStruct * * dataPtr1 = & data ; data = NULL; twoIntsStruct * data = * dataPtr1 ; data = ( twoIntsStruct * ) realloc ( data , 100 * sizeof ( twoIntsStruct ) ); data [ 0 ] . intOne = 0; data [ 0 ] . intTwo = 0; printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); * dataPtr1 = data; free ( data ); | 100687/CWE401_Memory_Leak__twoIntsStruct_realloc_32.c | SARD | 0 |
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( 1 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 108931/CWE606_Unchecked_Loop_Condition__char_connect_socket_02.c | SARD | 0 |
static void goodG2B2() char * data ; char dataBuffer [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; if ( STATIC_CONST_FIVE == 5 ) data = dataBuffer; char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; strncpy ( dest , data , strlen ( dest ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77607/CWE127_Buffer_Underread__char_declare_ncpy_06.c | SARD | 0 |
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) if ( ! d -> tralloc ) build_state_zero ( d ); static void build_state_zero(struct dfa *d) d -> tralloc = 1; d -> trcount = 0; d -> realtrans = ( ( sizeof ( ( * d -> realtrans ) ) == 1 ? xzalloc ( ( d -> tralloc + 1 ) ) : xcalloc ( ( d -> tralloc + 1 ) , sizeof ( ( * d -> realtrans ) ) ) ) ); while ( 0 ) d -> trans = d -> realtrans + 1; d -> fails = ( ( sizeof ( ( * d -> fails ) ) == 1 ? xzalloc ( ( d -> tralloc ) ) : xcalloc ( ( d -> tralloc ) , sizeof ( ( * d -> fails ) ) ) ) ); while ( 0 ) d -> success = ( ( sizeof ( ( * d -> success ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> success ) ) ) ) ); while ( 0 ) d -> newlines = ( ( sizeof ( ( * d -> newlines ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> newlines ) ) ) ) ); while ( 0 ) build_state ( 0 , 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[]) position_set follows ; if ( d -> searchflag ) copy ( ( & d -> states [ 0 ] . elems ) , & follows ); | 149301/dfa.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_console_w32_spawnlp_10_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalTrue ) size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; | 118720/CWE78_OS_Command_Injection__char_console_w32_spawnlp_10.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_struct_memcpy_15_bad() twoIntsStruct * data ; data = NULL; switch ( 6 ) data = ( twoIntsStruct * ) malloc ( 50 * sizeof ( twoIntsStruct ) ); twoIntsStruct source [ 100 ] ; size_t i ; for (i = 0; i < 100; i++) source [ i ] . intOne = 0; source [ i ] . intTwo = 0; memcpy ( data , source , 100 * sizeof ( twoIntsStruct ) ); printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); free ( data ); | 71854/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_struct_memcpy_15.c | SARD | 3 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; size_t dataLen = strlen ( data ) ; recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; badSink_b ( data ); void badSink_b(char * data) badSink_c ( data ); void badSink_c(char * data) badSink_d ( data ); void badSink_d(char * data) badSink_e ( data ); void badSink_e(char * data) pFile = FOPEN ( data , "wb+" ); if ( pFile != NULL ) fclose ( pFile ); | 89612/CWE23_Relative_Path_Traversal__char_connect_socket_fopen_54a.cpp | SARD | 0 |
void 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 = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); badSink ( data ); void badSink(size_t data) if ( data > wcslen ( HELLO_STRING ) ) myString = new wchar_t [ data ]; wcscpy ( myString , HELLO_STRING ); printWLine ( myString ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) delete [ ] myString | 117866/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_listen_socket_22a.cpp | SARD | 0 |
void parse_dir_colors() char * * arg ; char * colors ; char * s ; 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 ; | 152990/color.c | SARD | 0 |
static void goodB2G() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_84_goodB2G * goodB2GObject = new CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_84_goodB2G ( data ) ; CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_84_goodB2G::CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_84_goodB2G(char * dataCopy) data = dataCopy; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 112710/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_84_goodB2G.cpp | SARD | 0 |
static void goodB2G2() if ( staticTrue ) 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 ); if ( data > INT_MIN ) int result = data - 1 ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 85618/CWE191_Integer_Underflow__int_listen_socket_sub_05.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_file_w32_spawnvp_65_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; funcPtr ( data ); | 119852/CWE78_OS_Command_Injection__char_file_w32_spawnvp_65a.c | SARD | 0 |
void bad() int i ; char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; for(i = 0; i < 1; i++) 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 ) | 95602/CWE36_Absolute_Path_Traversal__char_connect_socket_ifstream_17.cpp | SARD | 0 |
void CWE127_Buffer_Underread__malloc_char_memcpy_32_bad() char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memcpy ( dest , data , 100 * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77855/CWE127_Buffer_Underread__malloc_char_memcpy_32.c | SARD | 3 |
void CWE134_Uncontrolled_Format_String__char_connect_socket_fprintf_03_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( 5 == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 79100/CWE134_Uncontrolled_Format_String__char_connect_socket_fprintf_03.c | 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 ); | 90964/CWE23_Relative_Path_Traversal__wchar_t_connect_socket_open_68a.cpp | SARD | 0 |
static void good2() if ( staticTrue ) 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'; if ( LogonUserA ( username , domain , password , LOGON32_LOGON_NETWORK , LOGON32_PROVIDER_DEFAULT , & hUser ) != 0 ) SecureZeroMemory ( password , 100 * sizeof ( char ) ); password = realloc ( password , 200 * sizeof ( char ) ); strcpy ( password , "Nothing to see here" ); printLine ( password ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( password ); | 92020/CWE244_Heap_Inspection__w32_char_realloc_05.c | SARD | 0 |
void CWE124_Buffer_Underwrite__char_alloca_cpy_68b_goodG2BSink() char * data = CWE124_Buffer_Underwrite__char_alloca_cpy_68_goodG2BData ; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 73776/CWE124_Buffer_Underwrite__char_alloca_cpy_68b.c | SARD | 0 |
void bad() int64_t * data ; structType myStruct ; data = NULL; data = new int64_t [ 50 ]; myStruct . structFirst = data; badSink ( myStruct ); void badSink(structType myStruct) int64_t * data = myStruct . structFirst ; int64_t source [ 100 ] = { 0 } ; memcpy ( data , source , 100 * sizeof ( int64_t ) ); printLongLongLine ( data [ 0 ] ); void printLongLongLine (int64_t longLongIntNumber) printf ( "%lld\n" , longLongIntNumber ); delete [ ] data | 68807/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_int64_t_memcpy_67b.cpp | SARD | 3 |
svn_error_t *svn_cmdline__parse_config_option(apr_array_header_t *config_options,const char *opt_arg,apr_pool_t *pool) const char * first_colon ; const char * second_colon ; if ( ( first_colon = ( strchr ( opt_arg , ':' ) ) ) && first_colon != opt_arg ) if ( ( second_colon = ( strchr ( first_colon + 1 , ':' ) ) ) && second_colon != first_colon + 1 ) if ( ( equals_sign = ( strchr ( second_colon + 1 , '=' ) ) ) && equals_sign != second_colon + 1 ) config_option -> 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; | 149449/cmdline.c | 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 ) ) 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 ); | 153795/conversation.c | SARD | 0 |
static void setsubstate(struct skinny_subchannel *sub, int state) struct skinny_line * l = sub -> line ; struct skinny_subline * subline = sub -> subline ; struct skinny_device * d = l -> device ; struct ast_channel * c = sub -> owner ; int actualstate = state ; if ( sub -> substate == SUBSTATE_ONHOOK ) if ( state != SUBSTATE_RINGIN && sub -> aa_sched ) sub -> aa_sched = 0; sub -> aa_beep = 0; sub -> aa_mute = 0; if ( ( state == SUBSTATE_RINGIN ) && ( ( d -> hookstate == SKINNY_OFFHOOK ) || ( AST_LIST_NEXT ( AST_LIST_FIRST ( & l -> sub ) , list ) ) ) ) actualstate = SUBSTATE_CALLWAIT; if ( ( state == SUBSTATE_CONNECTED ) && ( ! subline ) && ( AST_LIST_FIRST ( & l -> sublines ) ) ) const char * slastation ; struct skinny_subline * tmpsubline ; slastation = pbx_builtin_getvar_helper ( c , "SLASTATION" ); if ( slastation ) subline = tmpsubline; if ( subline ) subline -> sub = sub; sub -> subline = subline; subline -> callid = sub -> callid; if ( subline ) switch ( actualstate ) if ( sub -> substate != SUBSTATE_CONNECTED ) sub -> substate = SUBSTATE_HOLD; if ( ( d -> hookstate == SKINNY_ONHOOK ) && ( ( actualstate == SUBSTATE_OFFHOOK ) || ( actualstate == SUBSTATE_DIALING ) || ( actualstate == SUBSTATE_RINGOUT ) || ( actualstate == SUBSTATE_CONNECTED ) || ( actualstate == SUBSTATE_BUSY ) || ( actualstate == SUBSTATE_CONGESTION ) || ( actualstate == SUBSTATE_PROGRESS ) ) ) d -> hookstate = SKINNY_OFFHOOK; if ( actualstate == sub -> substate ) switch ( actualstate ) l -> activesub = sub; sub -> substate = SUBSTATE_OFFHOOK; if ( sub -> related ) sub -> related -> related = NULL; if ( sub == l -> activesub ) l -> activesub = NULL; sub -> cxmode = SKINNY_CX_RECVONLY; sub -> substate = SUBSTATE_ONHOOK; if ( sub -> rtp ) sub -> rtp = NULL; if ( ast_strlen_zero ( sub -> exten ) || ! ast_exists_extension ( c , c -> context , sub -> exten , 1 , l -> cid_num ) ) if ( d -> hookstate == SKINNY_ONHOOK ) d -> hookstate = SKINNY_OFFHOOK; sub -> substate = SUBSTATE_DIALING; if ( ! ( sub -> substate == SUBSTATE_DIALING || sub -> substate == SUBSTATE_PROGRESS ) ) sub -> substate = SUBSTATE_RINGOUT; if ( d -> hookstate == SKINNY_ONHOOK ) l -> activesub = sub; sub -> substate = SUBSTATE_RINGIN; sub -> substate = SUBSTATE_CALLWAIT; if ( sub -> aa_beep ) transmit_start_tone ( d , SKINNY_ZIP , l -> instance , sub -> callid ); static void transmit_start_tone(struct skinny_device *d, int tone, int instance, int reference) struct skinny_req * req ; if ( ! ( req = req_alloc ( sizeof ( struct start_tone_message ) , START_TONE_MESSAGE ) ) ) req -> data . starttone . tone = htolel ( tone ); req -> data . starttone . instance = htolel ( instance ); req -> data . starttone . reference = htolel ( reference ); transmit_response ( d , req ); static void transmit_response(struct skinny_device *d, struct skinny_req *req) transmit_response_bysession ( d -> session , req ); static int transmit_response_bysession(struct skinnysession *s, struct skinny_req *req) if ( ! s ) if ( ( letohl ( req -> len ) > SKINNY_MAX_PACKET ) || ( letohl ( req -> len ) < 0 ) ) memset ( s -> outbuf , 0 , sizeof ( s -> outbuf ) ); memcpy ( s -> outbuf , req , skinny_header_size ); memcpy ( s -> outbuf + skinny_header_size , & req -> data , letohl ( req -> len ) ); res = write ( s -> fd , s -> outbuf , letohl ( req -> len ) + 8 ); if ( res != letohl ( req -> len ) + 8 ) ast_log ( LOG_WARNING , "Transmit: write only sent %d out of %d bytes: %s\n" , res , letohl ( req -> len ) + 8 , strerror ( errno ) ); | 148809/chan_skinny.c | SARD | 2 |
void CWE124_Buffer_Underwrite__char_alloca_memmove_17_bad() char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer - 8; memmove ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 73878/CWE124_Buffer_Underwrite__char_alloca_memmove_17.c | SARD | 3 |
static void goodG2B() int h ; char * data ; data = NULL; for(h = 0; h < 1; h++) data = new char [ 100 ]; 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 ); delete [ ] data | 68496/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_ncpy_17.cpp | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; strncat ( data + dataLen , environment , FILENAME_MAX - dataLen - 1 ); badSink ( data ); void badSink(char * data) pFile = FOPEN ( data , "wb+" ); if ( pFile != NULL ) fclose ( pFile ); | 96042/CWE36_Absolute_Path_Traversal__char_environment_fopen_41.cpp | SARD | 4 |
void CWE369_Divide_by_Zero__int_listen_socket_modulo_53_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 ) CWE369_Divide_by_Zero__int_listen_socket_modulo_53b_badSink ( data ); void CWE369_Divide_by_Zero__int_listen_socket_modulo_53b_badSink(int data) CWE369_Divide_by_Zero__int_listen_socket_modulo_53c_badSink ( data ); void CWE369_Divide_by_Zero__int_listen_socket_modulo_53c_badSink(int data) CWE369_Divide_by_Zero__int_listen_socket_modulo_53d_badSink ( data ); void CWE369_Divide_by_Zero__int_listen_socket_modulo_53d_badSink(int data) printIntLine ( 100 % data ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 95329/CWE369_Divide_by_Zero__int_listen_socket_modulo_53a.c | SARD | 0 |
void CWE126_Buffer_Overread__char_alloca_memmove_64_bad() char * data ; char * dataBadBuffer = ( char * ) ALLOCA ( 50 * sizeof ( char ) ) ; memset ( dataBadBuffer , 'A' , 50 - 1 ); dataBadBuffer [ 50 - 1 ] = '\0'; data = dataBadBuffer; CWE126_Buffer_Overread__char_alloca_memmove_64b_badSink ( & data ); void CWE126_Buffer_Overread__char_alloca_memmove_64b_badSink(void * dataVoidPtr) char * * dataPtr = ( char * * ) dataVoidPtr ; char * data = ( * dataPtr ) ; char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memmove ( dest , data , strlen ( dest ) * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 76086/CWE126_Buffer_Overread__char_alloca_memmove_64b.c | SARD | 3 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE129_connect_socket_31_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 ) int dataCopy = data ; int data = dataCopy ; if ( data >= 0 ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( buffer ); | 70468/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_connect_socket_31.c | SARD | 3 |
void parse_options(void *optctx,int argc,char **argv,const OptionDef *options,void (*parse_arg_function)(void *, const char *)) const char * opt ; int optindex ; int handleoptions = 1 ; int ret ; optindex = 1; while ( optindex < argc ) opt = argv [ optindex ++ ]; if ( handleoptions && opt [ 0 ] == '-' && opt [ 1 ] != '\0' ) if ( opt [ 1 ] == '-' && opt [ 2 ] == '\0' ) handleoptions = 0; opt ++; if ( ( ret = parse_option ( optctx , opt , argv [ optindex ] , options ) ) < 0 ) optindex += ret; int parse_option(void *optctx,const char *opt,const char *arg,const OptionDef *options) const OptionDef * po ; po = find_option ( options , opt ); if ( ! po -> name && opt [ 0 ] == 'n' && opt [ 1 ] == 'o' ) po = find_option ( options , opt + 2 ); if ( ! po -> name ) po = find_option ( options , "default" ); static const OptionDef *find_option(const OptionDef *po,const char *name) const char * p = ( strchr ( name , ':' ) ) ; int len = ( p ? ( p - name ) : strlen ( name ) ) ; while ( po -> name != ( ( void * ) 0 ) ) if ( ! strncmp ( name , po -> name , len ) && strlen ( po -> name ) == len ) po ++; | 150456/cmdutils.c | SARD | 0 |
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 80364/CWE134_Uncontrolled_Format_String__char_listen_socket_snprintf_21.c | SARD | 0 |
static void goodG2B() int data ; data = - 1; data = 100 - 1; int dataCopy = data ; int data = dataCopy ; if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; free ( dataBuffer ); | 87842/CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_malloc_31.c | SARD | 0 |
static int stonesoup_ev_handler(struct mg_connection *conn, enum mg_event ev) char * ifmatch_header ; char * stonesoup_tainted_buff ; int buffer_size = 1000 ; if ( ev == MG_REQUEST ) ifmatch_header = ( char * ) mg_get_header ( conn , "if-match" ); if ( strcmp ( ifmatch_header , "weak_taint_source_value" ) == 0 ) while ( 1 ) stonesoup_tainted_buff = ( char * ) malloc ( buffer_size * sizeof ( char ) ); data_size = mg_get_var ( conn , "data" , stonesoup_tainted_buff , buffer_size * sizeof ( char ) ); if ( data_size < buffer_size ) buffer_size = buffer_size * 2; stonesoup_handle_taint ( stonesoup_tainted_buff ); void stonesoup_handle_taint(char *arnuad_unsoldered) if ( arnuad_unsoldered != 0 ) dbhost = getenv ( "DBPGHOST" ); dbuser = getenv ( "DBPGUSER" ); dbpassword = getenv ( "DBPGPASSWORD" ); dbport = getenv ( "DBPGPORT" ); dbdatabase = getenv ( "SS_DBPGDATABASE" ); if ( dbhost != 0 && dbport != 0 && dbuser != 0 && dbpassword != 0 && dbdatabase != 0 ) stonesoup_random_int = ( rand ( ) % 1000 ) + 100; snprintf ( query , 1000 , "INSERT INTO shippers (shipperid, companyname) VALUES ('%d', '%s');" , stonesoup_random_int , curver_jann ); tracepoint ( stonesoup_trace , variable_buffer , "query" , query , "CROSSOVER-STATE" ); res = PQexec ( conn , query ); if ( PQresultStatus ( res ) != PGRES_COMMAND_OK ) PQclear ( res ); stonesoup_result = PQcmdTuples ( res ); stonesoup_printf ( "Query OK, %s rows affected\n" , stonesoup_result ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); mg_vprintf_data ( ( struct mg_connection * ) stonesoup_printf_context , format , argptr ); PQclear ( res ); | 152481/stream.c | SARD | 15 |