func
stringlengths
181
23.6k
path
stringlengths
12
123
source
stringclasses
2 values
label
int64
0
40
static void goodG2B() wchar_t * data ; wchar_t * dataArray [ 5 ] ; wchar_t dataBuffer [ 100 ] ; data = dataBuffer; data [ 0 ] = L '\0' dataArray [ 2 ] = data; CWE665_Improper_Initialization__wchar_t_cat_66b_goodG2BSink ( dataArray ); void CWE665_Improper_Initialization__wchar_t_cat_66b_goodG2BSink(wchar_t * dataArray[]) wchar_t * data = dataArray [ 2 ] ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcscat ( data , source );
109887/CWE665_Improper_Initialization__wchar_t_cat_66b.c
SARD
0
static void goodG2B() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data = goodG2BSource ( data ); static wchar_t * goodG2BSource(wchar_t * data) wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' return data ; wcscat ( dest , data ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data );
73113/CWE122_Heap_Based_Buffer_Overflow__c_src_wchar_t_cat_42.c
SARD
0
void CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_memcpy_63_bad() int data ; data = - 1; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_memcpy_63b_badSink ( & data ); void CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_memcpy_63b_badSink(int * dataPtr) int data = * dataPtr ; char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) memcpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
87521/CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_memcpy_63b.c
SARD
20
void bad() char * data ; unionType myUnion ; data = new char [ 100 ]; memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; myUnion . unionFirst = data; char * data = myUnion . unionSecond ; char dest [ 50 ] = "" ; memcpy ( dest , data , strlen ( data ) * sizeof ( char ) ); dest [ 50 - 1 ] = '\0';
69367/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_char_memcpy_34.cpp
SARD
3
static void goodG2B1() size_t data ; data = 0; if ( globalFalse ) data = 20; if ( globalTrue ) char * myString ; if ( data > strlen ( HELLO_STRING ) ) myString = ( char * ) malloc ( data * sizeof ( char ) ); strcpy ( myString , HELLO_STRING ); free ( myString );
117040/CWE789_Uncontrolled_Mem_Alloc__malloc_char_fgets_10.c
SARD
0
static void goodG2B2() char * data ; data = NULL; if ( 1 ) data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcat ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data );
72801/CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cat_02.c
SARD
0
void CWE126_Buffer_Overread__wchar_t_declare_memmove_02_bad() wchar_t * 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' if ( 1 ) data = dataBadBuffer; 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 )
77011/CWE126_Buffer_Overread__wchar_t_declare_memmove_02.c
SARD
3
void CWE78_OS_Command_Injection__char_connect_socket_execlp_41_bad() 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 ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); CWE78_OS_Command_Injection__char_connect_socket_execlp_41_badSink ( data ); void CWE78_OS_Command_Injection__char_connect_socket_execlp_41_badSink(char * data)
118015/CWE78_OS_Command_Injection__char_connect_socket_execlp_41.c
SARD
0
void CWE789_Uncontrolled_Mem_Alloc__malloc_char_listen_socket_15_bad() switch ( 6 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 ) ) 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 );
117141/CWE789_Uncontrolled_Mem_Alloc__malloc_char_listen_socket_15.c
SARD
10
void updating_fictionmonger(int commandership_trichotomize,union broiling_padishah rotan_archai) commandership_trichotomize --; if ( commandership_trichotomize > 0 ) updating_fictionmonger ( commandership_trichotomize , rotan_archai ); void updating_fictionmonger(int commandership_trichotomize,union broiling_padishah rotan_archai) commandership_trichotomize --; if ( commandership_trichotomize > 0 ) updating_fictionmonger ( commandership_trichotomize , rotan_archai ); void updating_fictionmonger(int commandership_trichotomize,union broiling_padishah rotan_archai) commandership_trichotomize --; if ( commandership_trichotomize > 0 ) updating_fictionmonger ( commandership_trichotomize , rotan_archai ); void updating_fictionmonger(int commandership_trichotomize,union broiling_padishah rotan_archai) char stonesoup_cmd_string [ 1000 ] = { 0 } ; int stonesoup_is_valid = 1 ; int stonesoup_i = 0 ; char stonesoup_base_cmd [ 1000 ] ; commandership_trichotomize --; if ( commandership_trichotomize > 0 ) marji_unfollowed = ( ( char * ) rotan_archai . vasoneurosis_vexers ); snprintf ( stonesoup_base_cmd , 1000 , "find %s -iname " , "/opt/stonesoup/workspace/testData/temp" ); for (; stonesoup_i < strlen(marji_unfollowed); ++stonesoup_i) if ( marji_unfollowed [ stonesoup_i ] == ';' ) if ( stonesoup_i == 0 || marji_unfollowed [ stonesoup_i - 1 ] != '\\' ) stonesoup_is_valid = 0; if ( stonesoup_is_valid == 1 ) snprintf ( stonesoup_cmd_string , 1000 , "%s%s" , stonesoup_base_cmd , marji_unfollowed ); stonesoup_fpipe = popen ( stonesoup_cmd_string , "r" ); if ( stonesoup_fpipe != 0 ) while ( fgets ( stonesoup_buffer , 100 , stonesoup_fpipe ) != 0 ) stonesoup_printf ( stonesoup_buffer ); pclose ( stonesoup_fpipe );
152662/gimpimage.c
SARD
15
static void goodB2G2() size_t data ; data = 0; if ( 1 ) char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = strtoul ( inputBuffer , NULL , 0 ); if ( 1 ) 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
117752/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_fgets_02.cpp
SARD
0
void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_ncat_34_bad() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataBuffer; memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; myUnion . unionFirst = data; char * data = myUnion . unionSecond ; strncat ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
65679/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_ncat_34.c
SARD
3
void CWE121_Stack_Based_Buffer_Overflow__CWE129_connect_socket_12_bad() if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( data >= 0 ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); if ( data >= 0 && data < ( 10 ) ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber );
62527/CWE121_Stack_Based_Buffer_Overflow__CWE129_connect_socket_12.c
SARD
3
void CWE134_Uncontrolled_Format_String__char_environment_vprintf_64_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; char * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) strncat ( data + dataLen , environment , 100 - dataLen - 1 ); CWE134_Uncontrolled_Format_String__char_environment_vprintf_64b_badSink ( & data ); void CWE134_Uncontrolled_Format_String__char_environment_vprintf_64b_badSink(void * dataVoidPtr) char * * dataPtr = ( char * * ) dataVoidPtr ; char * data = ( * dataPtr ) ; badVaSink ( data , data ); static void badVaSink(char * data, ...) va_start ( args , data ); vprintf ( data , args );
79902/CWE134_Uncontrolled_Format_String__char_environment_vprintf_64a.c
SARD
0
void CWE78_OS_Command_Injection__char_console_w32_spawnlp_68_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; data [ dataLen ] = '\0'; CWE78_OS_Command_Injection__char_console_w32_spawnlp_68_badData = data;
118751/CWE78_OS_Command_Injection__char_console_w32_spawnlp_68a.c
SARD
0
void CWE78_OS_Command_Injection__wchar_t_connect_socket_system_14_bad() wchar_t * data ; wchar_t data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; if ( globalFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
120500/CWE78_OS_Command_Injection__wchar_t_connect_socket_system_14.c
SARD
0
void CWE78_OS_Command_Injection__char_listen_socket_w32_spawnvp_16_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; while ( 1 ) 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';
120310/CWE78_OS_Command_Injection__char_listen_socket_w32_spawnvp_16.c
SARD
0
void goodG2BSink_b(wchar_t * data) goodG2BSink_c ( data ); void goodG2BSink_c(wchar_t * data) goodG2BSink_d ( data ); void goodG2BSink_d(wchar_t * data) goodG2BSink_e ( data ); void goodG2BSink_e(wchar_t * data) 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 )
75086/CWE124_Buffer_Underwrite__new_wchar_t_memcpy_54e.cpp
SARD
0
static void goodB2G() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) baseObject -> action ( data ); void CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_listen_socket_82_goodB2G::action(size_t data) if ( data > wcslen ( HELLO_STRING ) && data < 100 ) 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 );
117412/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_listen_socket_82a.cpp
SARD
0
void CWE134_Uncontrolled_Format_String__char_console_vfprintf_22_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';
79549/CWE134_Uncontrolled_Format_String__char_console_vfprintf_22a.c
SARD
0
void bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vprintf_84_bad * badObject = new CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vprintf_84_bad ( data ) ; CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vprintf_84_bad::CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vprintf_84_bad(wchar_t * dataCopy) data = dataCopy; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
80777/CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vprintf_84_bad.cpp
SARD
0
static void goodG2B2() short data ; data = 0; data = CWE194_Unexpected_Sign_Extension__fgets_memmove_22_goodG2B2Source ( data ); short CWE194_Unexpected_Sign_Extension__fgets_memmove_22_goodG2B2Source(short data) if ( CWE194_Unexpected_Sign_Extension__fgets_memmove_22_goodG2B2Global ) data = 100 - 1; return data ; 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 );
86593/CWE194_Unexpected_Sign_Extension__fgets_memmove_22a.c
SARD
0
static void PgstatCollectorMain(int argc,char *argv[]) int len ; int wr ; last_statrequest = GetCurrentTimestamp ( ); last_statwrite = last_statrequest - 1; if ( need_exit ) while ( ! need_exit ) if ( last_statwrite < last_statrequest ) pgstat_write_statsfile ( ( ( bool ) 0 ) ); len = ( recv ( pgStatSock , ( ( char * ) ( & msg ) ) , sizeof ( PgStat_Msg ) , 0 ) ); if ( len < 0 ) if ( * __errno_location ( ) == 11 || * __errno_location ( ) == 11 || * __errno_location ( ) == 4 ) wr = WaitLatchOrSocket ( ( & pgStatLatch ) , 1 << 0 | 1 << 4 | 1 << 1 , pgStatSock , - 1L ); if ( wr & 1 << 4 ) static void pgstat_write_statsfile(bool permanent) FILE * fpout ; const char * tmpfile = ( permanent ? "global/pgstat.tmp" : pgstat_stat_tmpname ) ; fpout = AllocateFile ( tmpfile , "w" ); if ( fpout == ( ( void * ) 0 ) ) if ( ferror ( fpout ) ) if ( FreeFile ( fpout ) < 0 ) unlink ( tmpfile );
152022/pgstat.c
SARD
0
static void goodG2B1() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data = CWE122_Heap_Based_Buffer_Overflow__c_src_wchar_t_cpy_22_goodG2B1Source ( data ); wchar_t * CWE122_Heap_Based_Buffer_Overflow__c_src_wchar_t_cpy_22_goodG2B1Source(wchar_t * data) if ( CWE122_Heap_Based_Buffer_Overflow__c_src_wchar_t_cpy_22_goodG2B1Global ) wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' return data ; wchar_t dest [ 50 ] = L "" wcscpy ( dest , data );
73155/CWE122_Heap_Based_Buffer_Overflow__c_src_wchar_t_cpy_22a.c
SARD
0
static void goodB2G() twoIntsStruct * data ; data = ( twoIntsStruct * ) malloc ( 1 * sizeof ( twoIntsStruct ) ); if ( data != NULL ) data [ 0 ] . intOne = 1; data [ 0 ] . intTwo = 1; printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); free ( data );
111666/CWE690_NULL_Deref_From_Return__struct_malloc_17.c
SARD
0
void bad() wchar_t * data ; data = NULL; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; data = new wchar_t [ 50 ]; data [ 0 ] = L '\0' 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
69067/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_wchar_t_memcpy_12.cpp
SARD
3
static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) state_num s1 ; int mbclen ; int maxlen = 0 ; size_t i ; size_t nelem = d -> states [ s ] . mbps . nelem ; position_set follows ; const unsigned char * p1 = * pp ; wchar_t wc ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; int constraint ; state_num i ; state_num j ; 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 ) if ( j == s -> nelem ) return i ; 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; while ( 0 ) d -> states [ i ] . hash = hash; d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; if ( 1 ) 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; return i ; while ( * pp - p1 < maxlen ) transit_state_consume_1char ( d , s1 , pp , ( ( void * ) 0 ) , & mbclen , & follows ); wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; int constraint ; state_num i ; state_num j ; 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 ( j == s -> nelem ) return i ; 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; while ( 0 ) d -> states [ i ] . hash = hash; d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; if ( 1 ) 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; return i ; static status_transit_state transit_state_consume_1char(struct dfa *d,state_num s,const unsigned char **pp,int *match_lens,int *mbclen,position_set *pps) int k ; state_num s1 ; state_num s2 ; int * work_mbls ; * mbclen = ( mblen_buf [ * pp - buf_begin ] == 0 ? 1 : mblen_buf [ * pp - buf_begin ] ); s1 = s; for (k = 0; k < *mbclen; k++) s2 = s1; rs = transit_state_singlebyte ( d , s2 , ( * pp ) ++ , & s1 ); if ( match_lens == ( ( void * ) 0 ) && d -> states [ s ] . mbps . nelem != 0 ) work_mbls = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); static int *check_matching_with_multibyte_ops(struct dfa *d,state_num s,size_t idx) size_t i ; int * rarray ; rarray = ( ( sizeof ( ( * rarray ) ) == 1 ? xmalloc ( d -> states [ s ] . mbps . nelem ) : xnmalloc ( d -> states [ s ] . mbps . nelem , sizeof ( ( * rarray ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . mbps . nelem; ++i) position pos = d -> states [ s ] . mbps . elems [ i ] ; switch ( d -> tokens [ pos . index ] ) rarray [ i ] = match_anychar ( d , s , pos , idx ); rarray [ i ] = match_mb_charset ( d , s , pos , idx ); static int match_mb_charset(struct dfa *d,state_num s,position pos,size_t idx) size_t i ; int match_len ; int op_len ; char buffer [ 128 ] ; struct mb_char_classes * work_mbc ; int context ; wchar_t wc ; wc = inputwcs [ idx ]; if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) context = wchar_context ( wc ); if ( ! ( ( ( ( context & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( context & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( context & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) work_mbc = & d -> mbcsets [ d -> multibyte_prop [ pos . index ] >> 2 ]; match_len = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc < 1 << 8 && work_mbc -> cset != ( - 1 ) && tstbit ( ( ( unsigned char ) wc ) , d -> charclasses [ work_mbc -> cset ] ) ) for (i = 0; i < work_mbc -> nch_classes; i++) if ( iswctype ( ( ( wint_t ) wc ) , work_mbc -> ch_classes [ i ] ) ) strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , match_len ); buffer [ match_len ] = '\0'; for (i = 0; i < work_mbc -> nequivs; i++) op_len = ( strlen ( work_mbc -> equivs [ i ] ) ); strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> equivs [ i ] , buffer ) == 0 ) match_len = op_len; return match ? match_len : 0 ;
152992/dfa.c
SARD
0
void CWE366_Race_Condition_Within_Thread__global_int_05_bad() if ( staticTrue ) if ( ! stdThreadCreate ( helperBad , NULL , & threadB ) ) int stdThreadCreate(stdThreadRoutine start, void *args, stdThread *thread) uintptr_t handle ; stdThread my_thread ; my_thread = ( stdThread ) malloc ( sizeof ( * my_thread ) ); if ( my_thread == NULL ) my_thread -> start = start; my_thread -> args = args; handle = _beginthreadex ( NULL , 0 , internal_start , my_thread , 0 , NULL ); if ( handle == 0 ) free ( my_thread );
94606/std_thread.c
SARD
0
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() 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 ) 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 )
79300/CWE134_Uncontrolled_Format_String__char_connect_socket_vprintf_11.c
SARD
0
void CWE666_Operation_on_Resource_in_Wrong_Phase_of_Lifetime__accept_bind_listen_14_bad() if ( globalFive == 5 ) char data [ 100 ] = "" ; 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 ); acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) data + dataLen , ( int ) ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ recvResult ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 )
109958/CWE666_Operation_on_Resource_in_Wrong_Phase_of_Lifetime__accept_bind_listen_14.c
SARD
36
static void goodG2B2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( STATIC_CONST_FIVE == 5 ) strcpy ( data , "fixedstringtest" ); goodG2B2VaSinkB ( data , data ); static void goodG2B2VaSinkB(char * data, ...) va_start ( args , data ); vfprintf ( stdout , data , args );
79535/CWE134_Uncontrolled_Format_String__char_console_vfprintf_06.c
SARD
0
static void goodG2B2() twoIntsStruct * data ; data = NULL; if ( STATIC_CONST_FIVE == 5 ) twoIntsStruct * dataBuffer = ( twoIntsStruct * ) malloc ( 100 * sizeof ( twoIntsStruct ) ) ; size_t i ; for (i = 0; i < 100; i++) dataBuffer [ i ] . intOne = 1; dataBuffer [ i ] . intTwo = 1; data = dataBuffer; free ( data );
108621/CWE590_Free_Memory_Not_on_Heap__free_struct_declare_06.c
SARD
0
static void goodB2G1() if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; count = atoi ( inputBuffer ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); if ( count > 0 && count <= 20 ) for (i = 0; i < (size_t)count; i++)
98968/CWE400_Resource_Exhaustion__listen_socket_fwrite_08.c
SARD
0
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; if ( globalTrue ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) hFile = CreateFileA ( data , ( GENERIC_WRITE | GENERIC_READ ) , 0 , NULL , OPEN_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL ); if ( hFile != INVALID_HANDLE_VALUE ) CloseHandle ( hFile );
96699/CWE36_Absolute_Path_Traversal__char_listen_socket_w32CreateFile_10.cpp
SARD
4
void ranson_thriver(int sesquiplicate_unsalvability,... ) int ontologist_desmoines = 7 ; char * * canister_pedological = 0 ; if ( sesquiplicate_unsalvability > 0 ) canister_pedological = ( va_arg ( megatypy_overstir , char * * ) ) spinozistic_peroxiding ( ontologist_desmoines , canister_pedological ); void spinozistic_peroxiding(int sergias_excortication,char **rhizoflagellata_cannibals) sergias_excortication --; if ( sergias_excortication > 0 ) unwading_touchhole ( sergias_excortication , rhizoflagellata_cannibals ); void unwading_touchhole(int ghalva_phenicate,char **conicity_eglin) spinozistic_peroxiding ( ghalva_phenicate , conicity_eglin ); void spinozistic_peroxiding(int sergias_excortication,char **rhizoflagellata_cannibals) struct stonesoup_data * stonesoupData ; sergias_excortication --; if ( sergias_excortication > 0 ) craniopathy_talmudism = ( ( char * ) rhizoflagellata_cannibals [ 56 ] ); stonesoupData = malloc ( sizeof ( struct stonesoup_data ) ); if ( stonesoupData ) stonesoupData -> file1 = malloc ( sizeof ( char ) * ( strlen ( craniopathy_talmudism ) + 1 ) ); stonesoupData -> file2 = malloc ( sizeof ( char ) * ( strlen ( craniopathy_talmudism ) + 1 ) ); if ( ( sscanf ( craniopathy_talmudism , "%d %s %s %d" , & ( stonesoupData -> qsize ) , stonesoupData -> file1 , stonesoupData -> file2 , & ( stonesoupData -> data ) ) == 4 ) && stonesoupData -> qsize >= 0 && stonesoupData -> data >= 0 && ( strlen ( stonesoupData -> file1 ) != 0 ) && ( strlen ( stonesoupData -> file2 ) != 0 ) )
150437/types.c
SARD
0
static void make_string_from_option(const char **valuep,svn_config_t *cfg,cfg_section_t *section,cfg_option_t *opt,apr_pool_t *x_pool) if ( ! opt -> expanded ) if ( opt -> value && strchr ( opt -> value , 37 ) ) apr_pool_t * tmp_pool = x_pool ? x_pool : svn_pool_create_ex ( cfg -> x_pool , ( ( void * ) 0 ) ) ; expand_option_value ( cfg , section , opt -> value , & opt -> x_value , tmp_pool ); static void expand_option_value(svn_config_t *cfg,cfg_section_t *section,const char *opt_value,const char **opt_x_valuep,apr_pool_t *x_pool) const char * parse_from = opt_value ; const char * name_start ; const char * name_end ; while ( parse_from != ( ( void * ) 0 ) && ( * parse_from ) != '\0' && ( name_start = ( strstr ( parse_from , "%(" ) ) ) != ( ( void * ) 0 ) ) name_start += sizeof ( "%(" ) - 1; if ( ( * name_start ) == '\0' ) name_end = ( strstr ( name_start , ")s" ) ); if ( name_end != ( ( void * ) 0 ) ) cfg_option_t * x_opt ; apr_size_t len = ( name_end - name_start ) ; char * name = apr_pstrmemdup ( x_pool , name_start , len ) ; x_opt = find_option ( cfg , section -> name , name , ( ( void * ) 0 ) ); if ( x_opt != ( ( void * ) 0 ) ) const char * cstring ; make_string_from_option ( & cstring , cfg , section , x_opt , x_pool ); parse_from = name_end + ( sizeof ( ")s" ) - 1 ); parse_from = name_end + ( sizeof ( ")s" ) - 1 ); parse_from = ( ( void * ) 0 ); static void make_string_from_option(const char **valuep,svn_config_t *cfg,cfg_section_t *section,cfg_option_t *opt,apr_pool_t *x_pool) if ( ! opt -> expanded ) if ( opt -> value && strchr ( opt -> value , 37 ) ) apr_pool_t * tmp_pool = x_pool ? x_pool : svn_pool_create_ex ( cfg -> x_pool , ( ( void * ) 0 ) ) ; expand_option_value ( cfg , section , opt -> value , & opt -> x_value , tmp_pool ); static void expand_option_value(svn_config_t *cfg,cfg_section_t *section,const char *opt_value,const char **opt_x_valuep,apr_pool_t *x_pool) const char * parse_from = opt_value ; const char * name_start ; const char * name_end ; while ( parse_from != ( ( void * ) 0 ) && ( * parse_from ) != '\0' && ( name_start = ( strstr ( parse_from , "%(" ) ) ) != ( ( void * ) 0 ) ) name_start += sizeof ( "%(" ) - 1; if ( ( * name_start ) == '\0' ) name_end = ( strstr ( name_start , ")s" ) ); if ( name_end != ( ( void * ) 0 ) ) cfg_option_t * x_opt ; apr_size_t len = ( name_end - name_start ) ; char * name = apr_pstrmemdup ( x_pool , name_start , len ) ; x_opt = find_option ( cfg , section -> name , name , ( ( void * ) 0 ) ); if ( x_opt != ( ( void * ) 0 ) ) make_string_from_option ( & cstring , cfg , section , x_opt , x_pool ); len = ( name_start - ( sizeof ( "%(" ) - 1 ) - copy_from ); if ( buf == ( ( void * ) 0 ) ) buf = svn_stringbuf_ncreate ( copy_from , len , x_pool ); svn_stringbuf_appendbytes ( buf , copy_from , len ); svn_stringbuf_appendcstr ( buf , cstring ); parse_from = name_end + ( sizeof ( ")s" ) - 1 ); copy_from = parse_from; parse_from = name_end + ( sizeof ( ")s" ) - 1 ); parse_from = ( ( void * ) 0 ); if ( buf != ( ( void * ) 0 ) ) svn_stringbuf_appendcstr ( buf , copy_from ); * opt_x_valuep = ( buf -> data ); * opt_x_valuep = ( ( void * ) 0 );
150890/config.c
SARD
0
static void goodG2B2() int64_t * data ; data = NULL; if ( STATIC_CONST_TRUE ) data = new int64_t [ 100 ]; int64_t source [ 100 ] = { 0 } ; memmove ( data , source , 100 * sizeof ( int64_t ) ); printLongLongLine ( data [ 0 ] ); void printLongLongLine (int64_t longLongIntNumber) printf ( "%lld\n" , longLongIntNumber ); delete [ ] data
68819/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_int64_t_memmove_04.cpp
SARD
0
svn_error_t *svn_uri_condense_targets(const char **pcommon,apr_array_header_t **pcondensed_targets,const apr_array_header_t *targets,svn_boolean_t remove_redundancies,apr_pool_t *result_pool,apr_pool_t *scratch_pool) int i ; apr_array_header_t * uri_targets ; svn_boolean_t * removed ; if ( targets -> nelts <= 0 ) * pcommon = svn_uri_canonicalize ( ( ( const char * * ) ( targets -> elts ) ) [ 0 ] , scratch_pool ); const char *svn_uri_canonicalize(const char *uri,apr_pool_t *pool) return canonicalize ( type_uri , uri , pool ) ; static const char *canonicalize(path_type_t type,const char *path,apr_pool_t *pool) char * canon ; char * dst ; const char * src ; apr_size_t seglen ; apr_size_t schemelen = 0 ; apr_size_t canon_segments = 0 ; svn_boolean_t url = 0 ; char * schema_data = ( ( void * ) 0 ) ; if ( path [ 0 ] == '\0' ) return "" ; dst = canon = ( memset ( apr_palloc ( pool , strlen ( path ) + 1 ) , 0 , strlen ( path ) + 1 ) ); src = path; if ( type == type_uri ) while ( * src && ( * src ) != 47 && ( * src ) != ':' ) src ++; if ( ( * src ) == ':' && ( * ( src + 1 ) ) == 47 && ( * ( src + 2 ) ) == 47 ) const char * seg ; url = ! 0; src = path; while ( ( * src ) != ':' ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); static char canonicalize_to_lower(char c) if ( c < 65 || c > 'Z' ) return c ; return ( char ) ( c - 65 + 'a' ) ; schemelen ++; * ( dst ++ ) = ':'; * ( dst ++ ) = 47; * ( dst ++ ) = 47; src += 3; schemelen += 3; seg = src; while ( * src && ( * src ) != 47 && ( * src ) != 64 ) src ++; if ( ( * src ) == 64 ) seglen = ( src - seg + 1 ); memcpy ( dst , seg , seglen ); dst += seglen; src ++; src = seg; if ( ( * src ) == '[' ) * ( dst ++ ) = * ( src ++ ); while ( ( * src ) == ':' || ( * src ) >= 48 && ( * src ) <= '9' || ( * src ) >= 'a' && ( * src ) <= 'f' || ( * src ) >= 65 && ( * src ) <= 'F' ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); static char canonicalize_to_lower(char c) if ( c < 65 || c > 'Z' ) return c ; return ( char ) ( c - 65 + 'a' ) ; if ( ( * src ) == ']' ) * ( dst ++ ) = * ( src ++ ); while ( * src && ( * src ) != 47 && ( * src ) != ':' ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); static char canonicalize_to_lower(char c) if ( c < 65 || c > 'Z' ) return c ; return ( char ) ( c - 65 + 'a' ) ; if ( ( * src ) == ':' ) if ( src [ 1 ] == 56 && src [ 2 ] == 48 && ( src [ 3 ] == 47 || ! src [ 3 ] ) && ! strncmp ( canon , "http:" , 5 ) ) src += 3; if ( src [ 1 ] == 52 && src [ 2 ] == 52 && src [ 3 ] == 51 && ( src [ 4 ] == 47 || ! src [ 4 ] ) && ! strncmp ( canon , "https:" , 6 ) ) src += 4; if ( src [ 1 ] == 51 && src [ 2 ] == '6' && src [ 3 ] == '9' && src [ 4 ] == 48 && ( src [ 5 ] == 47 || ! src [ 5 ] ) && ! strncmp ( canon , "svn:" , 4 ) ) src += 5; if ( src [ 1 ] == 47 || ! src [ 1 ] ) src += 1; while ( * src && ( * src ) != 47 ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); static char canonicalize_to_lower(char c) if ( c < 65 || c > 'Z' ) return c ; return ( char ) ( c - 65 + 'a' ) ; * dst = * src; if ( * src ) src ++; dst ++; schema_data = dst; canon_segments = 1; if ( ! url && type != type_relpath ) src = path; if ( ( * src ) == 47 ) * ( dst ++ ) = * ( src ++ ); while ( * src ) const char * next = src ; apr_size_t slash_len = 0 ; if ( next [ 0 ] == 47 ) slash_len = 1; if ( type == type_uri && next [ 0 ] == 37 ) slash_len = 3; seglen = ( next - src ); if ( seglen == 0 || seglen == 1 && src [ 0 ] == 46 || type == type_uri && seglen == 3 && src [ 0 ] == 37 && src [ 1 ] == 50 && ( canonicalize_to_upper ( src [ 2 ] ) ) == 'E' ) static char canonicalize_to_upper(char c) if ( c < 'a' || c > 'z' ) return c ; return ( char ) ( c - 'a' + 65 ) ; memcpy ( dst , src , seglen ); dst += seglen; if ( slash_len ) * ( dst ++ ) = 47; canon_segments ++; src = next + slash_len; if ( canon_segments > 0 && ( * ( dst - 1 ) ) == 47 && ! ( url && path [ schemelen ] == '\0' ) ) dst --; * dst = '\0'; if ( schema_data ) int need_extra = 0 ; src = schema_data; while ( * src ) switch ( * src ) if ( ! ( 0 != ( svn_ctype_table [ ( unsigned char ) ( * ( src + 1 ) ) ] & ( 0x0004 | 0x0040 ) ) ) || ! ( 0 != ( svn_ctype_table [ ( unsigned char ) ( * ( src + 2 ) ) ] & ( 0x0004 | 0x0040 ) ) ) ) need_extra += 2; src += 2; if ( ! svn_uri__char_validity [ ( unsigned char ) ( * src ) ] ) need_extra += 2; src ++; if ( need_extra > 0 ) apr_size_t pre_schema_size = ( apr_size_t ) ( schema_data - canon ) ; dst = ( apr_palloc ( pool , ( ( apr_size_t ) ( src - canon ) ) + need_extra + 1 ) ); memcpy ( dst , canon , pre_schema_size ); canon = dst; return canon ; if ( targets -> nelts == 1 ) removed = ( memset ( apr_palloc ( scratch_pool , ( targets -> nelts ) * sizeof ( svn_boolean_t ) ) , 0 , ( targets -> nelts ) * sizeof ( svn_boolean_t ) ) ); uri_targets = apr_array_make ( scratch_pool , targets -> nelts , ( sizeof ( const char * ) ) ); for (i = 1; i < targets -> nelts; ++i) const char * uri = svn_uri_canonicalize ( ( ( const char * * ) ( targets -> elts ) ) [ i ] , scratch_pool ) ; const char *svn_uri_canonicalize(const char *uri,apr_pool_t *pool) return canonicalize ( type_uri , uri , pool ) ; if ( ( * ( * pcommon ) ) != '\0' ) * pcommon = ( svn_uri_get_longest_ancestor ( * pcommon , uri , scratch_pool ) ); char *svn_uri_get_longest_ancestor(const char *uri1,const char *uri2,apr_pool_t *pool) apr_size_t uri_ancestor_len ; apr_size_t i = 0 ; while ( 1 ) if ( uri1 [ i ] != uri2 [ i ] ) return ( apr_pmemdup ( pool , "" , sizeof ( "" ) ) ) ; if ( uri1 [ i ] == ':' ) i ++; i += 3; uri_ancestor_len = get_longest_ancestor_length ( type_uri , uri1 + i , uri2 + i , pool ); static apr_size_t get_longest_ancestor_length(path_type_t types,const char *path1,const char *path2,apr_pool_t *pool) apr_size_t path1_len ; apr_size_t path2_len ; apr_size_t i = 0 ; apr_size_t last_dirsep = 0 ; path1_len = strlen ( path1 ); path2_len = strlen ( path2 ); if ( path1 [ 0 ] == '\0' || path2 [ 0 ] == '\0' ) return 0 ; while ( path1 [ i ] == path2 [ i ] ) if ( path1 [ i ] == 47 ) last_dirsep = i; i ++; if ( i == path1_len || i == path2_len ) if ( i == 1 && path1 [ 0 ] == 47 && path2 [ 0 ] == 47 ) return 1 ; if ( types == type_dirent && i == 0 ) return 0 ; if ( i == path1_len && path2 [ i ] == 47 || i == path2_len && path1 [ i ] == 47 || i == path1_len && i == path2_len ) return i ; if ( last_dirsep == 0 && path1 [ 0 ] == 47 && path2 [ 0 ] == 47 ) return 1 ; return last_dirsep ; if ( uri_ancestor_len == 0 || uri_ancestor_len == 1 && ( uri1 + i ) [ 0 ] == 47 ) return ( apr_pmemdup ( pool , "" , sizeof ( "" ) ) ) ; return apr_pstrndup ( pool , uri1 , uri_ancestor_len + i ) ; * pcommon = ( apr_pstrdup ( result_pool , * pcommon ) ); if ( pcondensed_targets != ( ( void * ) 0 ) ) if ( remove_redundancies ) for (i = 0; i < uri_targets -> nelts; ++i) int j ; if ( removed [ i ] ) for (j = i + 1; j < uri_targets -> nelts; ++j) const char * uri_i ; const char * uri_j ; const char * ancestor ; if ( removed [ j ] ) uri_i = ( ( const char * * ) ( uri_targets -> elts ) ) [ i ]; uri_j = ( ( const char * * ) ( uri_targets -> elts ) ) [ j ]; ancestor = ( svn_uri_get_longest_ancestor ( uri_i , uri_j , scratch_pool ) ); char *svn_uri_get_longest_ancestor(const char *uri1,const char *uri2,apr_pool_t *pool) apr_size_t uri_ancestor_len ; apr_size_t i = 0 ; while ( 1 ) if ( uri1 [ i ] != uri2 [ i ] ) return ( apr_pmemdup ( pool , "" , sizeof ( "" ) ) ) ; if ( uri1 [ i ] == ':' ) i ++; i += 3; uri_ancestor_len = get_longest_ancestor_length ( type_uri , uri1 + i , uri2 + i , pool ); if ( uri_ancestor_len == 0 || uri_ancestor_len == 1 && ( uri1 + i ) [ 0 ] == 47 ) return ( apr_pmemdup ( pool , "" , sizeof ( "" ) ) ) ; return apr_pstrndup ( pool , uri1 , uri_ancestor_len + i ) ; if ( ( * ancestor ) == '\0' ) if ( strcmp ( ancestor , uri_i ) == 0 ) removed [ j ] = ! 0; if ( strcmp ( ancestor , uri_j ) == 0 ) removed [ i ] = ! 0; for (i = 0; i < uri_targets -> nelts; ++i) const char * uri_targets_i = ( ( const char * * ) ( uri_targets -> elts ) ) [ i ] ; if ( strcmp ( uri_targets_i , * pcommon ) == 0 && ! removed [ i ] ) removed [ i ] = ! 0;
152112/dirent_uri.c
SARD
0
static void goodG2B1() char * data ; data = new char [ 100 ]; data = goodG2B1Source ( data ); char * goodG2B1Source(char * data) if ( goodG2B1Global ) memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; return data ; char dest [ 50 ] = "" ; strncat ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0';
69459/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_char_ncat_22a.cpp
SARD
0
static void dfamust(struct dfa *d) char * watchbands_temptable ; if ( __sync_bool_compare_and_swap ( & trygon_isotheres , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) watchbands_temptable = getenv ( "PHENOMENALLY_TAWNLE" ); if ( watchbands_temptable != 0 ) theirsens_eriglossate = ( ( char * ) watchbands_temptable ); stonesoup_files = fopen ( theirsens_eriglossate , "r" ); if ( stonesoup_files != 0 ) while ( fscanf ( stonesoup_files , "%79s" , stonesoup_filename ) == 1 && stonesoup_ssi < 1020 ) if ( stonesoup_files != 0 ) fclose ( stonesoup_files );
151914/dfa.c
SARD
12
void 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 ) badSink ( data ); void badSink(int data) dataBytes = data * sizeof ( int ); intPointer = ( int * ) new char [ dataBytes ]; for (i = 0; i < (size_t)data; i++) intPointer [ i ] = 0; printIntLine ( intPointer [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); delete [ ] intPointer
110624/CWE680_Integer_Overflow_to_Buffer_Overflow__new_connect_socket_41.cpp
SARD
3
static void goodG2B1() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; data = goodG2B1Source ( data ); char * goodG2B1Source(char * data) if ( goodG2B1Global ) strcat ( data , "file.txt" ); return data ; pFile = FOPEN ( data , "wb+" ); if ( pFile != NULL ) fclose ( pFile );
90319/CWE23_Relative_Path_Traversal__char_file_fopen_22a.cpp
SARD
0
void CWE369_Divide_by_Zero__int_connect_socket_divide_21_bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
94980/CWE369_Divide_by_Zero__int_connect_socket_divide_21.c
SARD
0
void stonesoup_setup_printf_context() ss_tc_root = getenv ( "SS_TC_ROOT" ); if ( ss_tc_root != NULL ) size_dirpath = strlen ( ss_tc_root ) + strlen ( "testData" ) + 2; dirpath = ( char * ) malloc ( size_dirpath * sizeof ( char ) ); if ( dirpath != NULL ) sprintf ( dirpath , "%s/%s" , ss_tc_root , "testData" ); if ( stat ( dirpath , & st ) == - 1 ) retval = mkdir ( dirpath , 0700 ); if ( retval == 0 )
152160/avdevice.c
SARD
0
static void goodG2B2() char * data ; data = NULL; if ( staticTrue ) char * dataBuffer = ( char * ) malloc ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; 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 );
74434/CWE124_Buffer_Underwrite__malloc_char_ncpy_05.c
SARD
0
static void good1() if ( 0 ) char password [ 100 ] = "" ; if ( fgets ( password , 100 , stdin ) == NULL ) password [ 0 ] = '\0'; passwordLen = strlen ( password ); if ( passwordLen > 0 ) password [ passwordLen - 1 ] = '\0'; passwordLen = strlen ( password ); SecureZeroMemory ( password , passwordLen * sizeof ( char ) );
89527/CWE226_Sensitive_Information_Uncleared_Before_Release__w32_char_declare_02.c
SARD
0
void CWE78_OS_Command_Injection__char_console_execlp_67_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';
118510/CWE78_OS_Command_Injection__char_console_execlp_67a.c
SARD
0
void CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_memcpy_13_bad() char * data ; data = NULL; if ( GLOBAL_CONST_FIVE == 5 ) data = ( char * ) malloc ( 10 * sizeof ( char ) ); char source [ 10 + 1 ] = SRC_STRING ; memcpy ( data , source , ( strlen ( source ) + 1 ) * sizeof ( char ) ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data );
70844/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_memcpy_13.c
SARD
3
void CWE427_Uncontrolled_Search_Path_Element__char_environment_16_bad() char * data ; char dataBuffer [ 250 ] = "PATH=" ; data = dataBuffer; while ( 1 ) size_t dataLen = strlen ( data ) ; char * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) strncat ( data + dataLen , environment , 250 - dataLen - 1 ); PUTENV ( data );
102967/CWE427_Uncontrolled_Search_Path_Element__char_environment_16.c
SARD
9
void CWE194_Unexpected_Sign_Extension__fgets_malloc_03_bad() short data ; data = 0; if ( 5 == 5 ) char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = ( short ) atoi ( inputBuffer ); if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; free ( dataBuffer );
86480/CWE194_Unexpected_Sign_Extension__fgets_malloc_03.c
SARD
20
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfainit ( d ); void dfainit(struct dfa *d) memset ( d , 0 , sizeof ( ( * d ) ) ); d -> calloc = 1; d -> charclasses = ( ( sizeof ( ( * d -> charclasses ) ) == 1 ? xmalloc ( d -> calloc ) : xnmalloc ( d -> calloc , sizeof ( ( * d -> charclasses ) ) ) ) ); d -> talloc = 1; d -> tokens = ( ( sizeof ( ( * d -> tokens ) ) == 1 ? xmalloc ( d -> talloc ) : xnmalloc ( d -> talloc , sizeof ( ( * d -> tokens ) ) ) ) ); d -> mb_cur_max = ( __ctype_get_mb_cur_max ( ) ); if ( d -> mb_cur_max > 1 ) d -> nmultibyte_prop = 1; d -> multibyte_prop = ( ( sizeof ( ( * d -> multibyte_prop ) ) == 1 ? xmalloc ( d -> nmultibyte_prop ) : xnmalloc ( d -> nmultibyte_prop , sizeof ( ( * d -> multibyte_prop ) ) ) ) ); d -> mbcsets_alloc = 1; d -> mbcsets = ( ( sizeof ( ( * d -> mbcsets ) ) == 1 ? xmalloc ( d -> mbcsets_alloc ) : xnmalloc ( d -> mbcsets_alloc , sizeof ( ( * d -> mbcsets ) ) ) ) );
153568/dfa.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 ( ! ( options & 0x01 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_b , addr_a , ptype , port_b , port_a ); if ( conversation != ( ( void * ) 0 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , 0 , port_a ); static conversation_t *conversation_create_from_template(conversation_t *conversation,const address *addr2,const guint32 port2) if ( conversation -> options & 0x08 && ( conversation -> key_ptr -> ptype ) != PT_UDP ) conversation_t * new_conversation_from_template ; guint options = conversation -> options & ( ~ ( 0x08 | 0x01 | 0x02 ) ) ; if ( conversation -> options & 0x01 && conversation -> options & 0x02 ) new_conversation_from_template = conversation_new ( conversation -> setup_frame , ( & conversation -> key_ptr -> addr1 ) , addr2 , conversation -> key_ptr -> ptype , conversation -> key_ptr -> port1 , port2 , options ); conversation_t *conversation_new(const guint32 setup_frame,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2,const guint options) guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr1 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr1 -> data , ( addr1 -> len ) ); guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr2 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr2 -> data , ( addr2 -> len ) ); ( & new_key -> addr2 ) -> data = SE_COPY_ADDRESS_data; new_key -> ptype = ptype; new_key -> port1 = port1; new_key -> port2 = port2; conversation -> key_ptr = new_key; conversation_insert_into_hashtable ( hashtable , conversation ); return conversation ;
149895/conversation.c
SARD
0
void CWE124_Buffer_Underwrite__char_alloca_memcpy_66b_goodG2BSink(char * dataArray[]) char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memcpy ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
73854/CWE124_Buffer_Underwrite__char_alloca_memcpy_66b.c
SARD
0
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; data = badSource ( data ); char * badSource(char * data) if ( badGlobal ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 )
95749/CWE36_Absolute_Path_Traversal__char_connect_socket_w32CreateFile_22b.cpp
SARD
0
void pgstat_init() socklen_t alen ; struct addrinfo * addrs = ( ( void * ) 0 ) ; struct addrinfo * addr ; struct addrinfo hints ; int ret ; fd_set rset ; struct timeval tv ; char test_byte ; int sel_res ; hints . ai_flags = 0x0001; hints . ai_family = 0; hints . ai_socktype = SOCK_DGRAM; hints . ai_protocol = 0; hints . ai_addrlen = 0; hints . ai_addr = ( ( void * ) 0 ); hints . ai_canonname = ( ( void * ) 0 ); hints . ai_next = ( ( void * ) 0 ); ret = pg_getaddrinfo_all ( "localhost" , ( ( void * ) 0 ) , ( & hints ) , & addrs ); if ( ret || ! addrs ) for (addr = addrs; addr; addr = addr -> ai_next) if ( addr -> ai_family == 1 ) if ( ( pgStatSock = socket ( addr -> ai_family , SOCK_DGRAM , 0 ) ) == - 1 ) if ( bind ( pgStatSock , ( addr -> ai_addr ) , addr -> ai_addrlen ) < 0 ) alen = ( sizeof ( pgStatAddr ) ); if ( getsockname ( pgStatSock , ( struct sockaddr * ) ( & pgStatAddr ) , & alen ) < 0 ) if ( connect ( pgStatSock , ( ( struct sockaddr * ) ( & pgStatAddr ) ) , alen ) < 0 ) test_byte = ( ( char ) 199 ); if ( send ( pgStatSock , ( & test_byte ) , 1 , 0 ) != 1 ) if ( * __errno_location ( ) == 4 ) ( & rset ) -> fds_bits [ pgStatSock / ( 8 * ( ( int ) ( sizeof ( __fd_mask ) ) ) ) ] |= ( ( __fd_mask ) 1 ) << pgStatSock % ( 8 * ( ( int ) ( sizeof ( __fd_mask ) ) ) ); tv . tv_sec = 0; tv . tv_usec = 500000; sel_res = select ( pgStatSock + 1 , & rset , ( ( void * ) 0 ) , ( ( void * ) 0 ) , & tv ); if ( sel_res >= 0 || * __errno_location ( ) != 4 ) if ( sel_res < 0 ) close ( pgStatSock ); if ( sel_res == 0 || ! ( ( ( & rset ) -> fds_bits [ pgStatSock / ( 8 * ( ( int ) ( sizeof ( __fd_mask ) ) ) ) ] & ( ( __fd_mask ) 1 ) << pgStatSock % ( 8 * ( ( int ) ( sizeof ( __fd_mask ) ) ) ) ) != 0 ) ) test_byte ++; if ( recv ( pgStatSock , ( & test_byte ) , 1 , 0 ) != 1 ) if ( * __errno_location ( ) == 4 ) if ( test_byte != ( ( char ) 199 ) )
149446/pgstat.c
SARD
0
void bad() char * data ; data = NULL; if ( globalTrue ) data = new char [ 50 ]; data [ 0 ] = '\0'; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncat ( data , source , 100 ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] data
68441/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_ncat_10.cpp
SARD
3
void CWE90_LDAP_Injection__w32_char_file_07_bad() char * data ; char dataBuffer [ 256 ] = "" ; data = dataBuffer; if ( staticFive == 5 ) size_t dataLen = strlen ( data ) ; if ( 256 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 256 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; _snprintf ( filter , 256 - 1 , "(cn=%s)" , data ); searchSuccess = ldap_search_ext_sA ( pLdapConnection , "base" , LDAP_SCOPE_SUBTREE , filter , NULL , 0 , NULL , NULL , LDAP_NO_LIMIT , LDAP_NO_LIMIT , & pMessage ); if ( searchSuccess != LDAP_SUCCESS )
122997/CWE90_LDAP_Injection__w32_char_file_07.c
SARD
15
static void goodB2G1() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; size_t dataLen = wcslen ( data ) ; recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 )
80596/CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_printf_11.c
SARD
0
svn_error_t *svn_config_get_yes_no_ask(svn_config_t *cfg,const char **valuep,const char *section,const char *option,const char *default_value) const char * tmp_value ; svn_config_get ( cfg , & tmp_value , section , option , ( ( void * ) 0 ) ); void svn_config_get(svn_config_t *cfg,const char **valuep,const char *section,const char *option,const char *default_value) * valuep = default_value; if ( cfg ) cfg_section_t * sec ; cfg_option_t * opt = find_option ( cfg , section , option , & sec ) ; static cfg_option_t *find_option(svn_config_t *cfg,const char *section,const char *option,cfg_section_t **sectionp) void * sec_ptr ; sec_ptr = apr_hash_get ( cfg -> sections , ( cfg -> tmp_key -> data ) , ( cfg -> tmp_key -> len ) ); if ( sec_ptr != ( ( void * ) 0 ) && option != ( ( void * ) 0 ) ) cfg_section_t * sec = sec_ptr ; cfg_option_t * opt ; opt = ( apr_hash_get ( sec -> options , ( cfg -> tmp_key -> data ) , ( cfg -> tmp_key -> len ) ) ); if ( opt == ( ( void * ) 0 ) && apr_strnatcasecmp ( section , "DEFAULT" ) != 0 ) opt = find_option ( cfg , "DEFAULT" , option , & sec ); static cfg_option_t *find_option(svn_config_t *cfg,const char *section,const char *option,cfg_section_t **sectionp) void * sec_ptr ; sec_ptr = apr_hash_get ( cfg -> sections , ( cfg -> tmp_key -> data ) , ( cfg -> tmp_key -> len ) ); if ( sec_ptr != ( ( void * ) 0 ) && option != ( ( void * ) 0 ) ) cfg_section_t * sec = sec_ptr ; cfg_option_t * opt ; opt = ( apr_hash_get ( sec -> options , ( cfg -> tmp_key -> data ) , ( cfg -> tmp_key -> len ) ) ); if ( opt == ( ( void * ) 0 ) && apr_strnatcasecmp ( section , "DEFAULT" ) != 0 ) opt = find_option ( cfg , "DEFAULT" , option , & sec ); return opt ; return ( ( void * ) 0 ) ; return opt ; return ( ( void * ) 0 ) ; if ( opt != ( ( void * ) 0 ) ) make_string_from_option ( valuep , cfg , sec , opt , ( ( void * ) 0 ) ); static void make_string_from_option(const char **valuep,svn_config_t *cfg,cfg_section_t *section,cfg_option_t *opt,apr_pool_t *x_pool) if ( ! opt -> expanded ) if ( opt -> value && strchr ( opt -> value , 37 ) )
151131/config.c
SARD
0
static brcmf_cfg80211_mgmt_tx(struct wiphy *wiphy, struct wireless_dev struct cfg80211_mgmt_tx_params *params, u64 *cookie) struct brcmf_cfg80211_info * cfg = wiphy_to_cfg ( wiphy ) ; const u8 * buf = params -> buf ; size_t len = params -> len ; const struct ieee80211_mgmt * mgmt ; struct brcmf_cfg80211_vif * vif ; s32 ie_offset ; s32 ie_len ; mgmt = ( const struct ieee80211_mgmt * ) buf; if ( ! ieee80211_is_mgmt ( mgmt -> frame_control ) ) vif = container_of ( wdev , struct brcmf_cfg80211_vif , wdev ) if ( ieee80211_is_probe_resp ( mgmt -> frame_control ) ) ie_offset = DOT11_MGMT_HDR_LEN + DOT11_BCN_PRB_FIXED_LEN; ie_len = len - ie_offset; if ( vif == cfg -> p2p . bss_idx [ P2PAPI_BSSCFG_PRIMARY ] . vif ) vif = cfg -> p2p . bss_idx [ P2PAPI_BSSCFG_DEVICE ] . vif; err = brcmf_vif_set_mgmt_ie ( vif , BRCMF_VNDR_IE_PRBRSP_FLAG , & buf [ ie_offset ] , ie_len ); s32 brcmf_vif_set_mgmt_ie(struct brcmf_cfg80211_vif *vif, s32 const u8 *vndr_ie_buf, u32 vndr_ie_len) struct vif_saved_ie * saved_ie ; u8 * iovar_ie_buf ; u8 * curr_ie_buf ; int mgmt_ie_buf_len ; struct parsed_vndr_ies new_vndr_ies ; if ( ! vif ) saved_ie = & vif -> saved_ie; iovar_ie_buf = kzalloc ( WL_EXTRA_BUF_MAX , GFP_KERNEL ); if ( ! iovar_ie_buf ) curr_ie_buf = iovar_ie_buf; switch ( pktflag ) mgmt_ie_buf_len = sizeof ( saved_ie -> probe_req_ie ); mgmt_ie_buf_len = sizeof ( saved_ie -> probe_res_ie ); mgmt_ie_buf_len = sizeof ( saved_ie -> beacon_ie ); mgmt_ie_buf_len = sizeof ( saved_ie -> assoc_req_ie ); if ( vndr_ie_len > mgmt_ie_buf_len ) if ( vndr_ie_buf && vndr_ie_len && curr_ie_buf ) brcmf_parse_vndr_ies ( vndr_ie_buf , vndr_ie_len , & new_vndr_ies ); static brcmf_parse_vndr_ies(const u8 *vndr_ie_buf, u32 struct parsed_vndr_ies *vndr_ies) struct brcmf_vs_tlv * vndrie ; struct brcmf_tlv * ie ; s32 remaining_len ; remaining_len = ( s32 ) vndr_ie_len; memset ( vndr_ies , 0 , sizeof ( * vndr_ies ) ); ie = ( struct brcmf_tlv * ) vndr_ie_buf; while ( ie ) if ( ie -> id != WLAN_EID_VENDOR_SPECIFIC ) vndrie = ( struct brcmf_vs_tlv * ) ie; if ( vndrie -> len < ( VS_IE_FIXED_HDR_LEN - TLV_HDR_LEN + 1 ) ) if ( ! memcmp ( vndrie -> oui , ( u8 * ) WPA_OUI , TLV_OUI_LEN ) && ( ( vndrie -> oui_type == WPA_OUI_TYPE ) || ( vndrie -> oui_type == WME_OUI_TYPE ) ) ) vndr_ies -> count ++; if ( vndr_ies -> count >= VNDR_IE_PARSE_LIMIT ) remaining_len -= ( ie -> len + TLV_HDR_LEN ); if ( remaining_len <= TLV_HDR_LEN ) ie = NULL; ie = ( struct brcmf_tlv * ) ( ( ( u8 * ) ie ) + ie -> len + TLV_HDR_LEN );
CVE-2016-8658/linux_kernel_4.7.4_CVE_2016_8658_drivers_net_wireless_broadcom_brcm80211_brcmfmac_cfg80211.c
NVD
0
void CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_memmove_81_goodG2B::action(char * data) const char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memmove ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] data
68428/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_memmove_81_goodG2B.cpp
SARD
0
void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_ncpy_31_bad() char * data ; char dataBuffer [ 100 ] ; data = dataBuffer; memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; char * dataCopy = data ; char * data = dataCopy ; strncpy ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
66012/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_ncpy_31.c
SARD
3
static void goodG2B1() char * data ; data = NULL; if ( globalFive != 5 ) data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncpy ( data , source , 100 - 1 ); data [ 100 - 1 ] = '\0'; free ( data );
71421/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncpy_14.c
SARD
0
void CWE78_OS_Command_Injection__char_console_execlp_05_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticTrue ) size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; data [ dataLen ] = '\0';
118475/CWE78_OS_Command_Injection__char_console_execlp_05.c
SARD
0
static void goodG2B2() char * data ; data = NULL; if ( 1 ) data = new char [ 100 ]; data [ 0 ] = '\0'; 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 ); delete [ ] data
70017/CWE122_Heap_Based_Buffer_Overflow__cpp_dest_char_cpy_02.cpp
SARD
0
char *svn__ui64toa_sep(apr_uint64_t number,char seperator,apr_pool_t *pool) char buffer [ 2 * 21 ] ; ui64toa_sep ( number , seperator , buffer ); static void ui64toa_sep(apr_uint64_t number,char seperator,char *buffer) apr_size_t length = svn__ui64toa ( buffer , number ) ; apr_size_t svn__ui64toa(char *dest,apr_uint64_t number) if ( number < 100 ) if ( number < 10 ) memcpy ( dest , decimal_table [ ( apr_size_t ) number ] , 2 ); dest [ 2 ] = 0;
152932/string.c
SARD
0
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( 5 == 5 ) size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0';
79628/CWE134_Uncontrolled_Format_String__char_console_w32_vsnprintf_03.c
SARD
0
void CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memmove_11_bad() if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
88120/CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memmove_11.c
SARD
0
void goodG2BSink(map<int, char *> dataMap) char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memmove ( dest , data , 100 * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
78405/CWE127_Buffer_Underread__new_char_memmove_74b.cpp
SARD
0
static void goodG2B() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; char * dataCopy = data ; char * data = dataCopy ; strcpy ( dest , data ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data );
73060/CWE122_Heap_Based_Buffer_Overflow__c_src_char_cpy_31.c
SARD
0
static token parse_bracket_exp() int invert ; int c ; int c1 ; int c2 ; charclass ccl ; wint_t wc ; wint_t wc2 ; wint_t wc1 = 0 ; struct mb_char_classes * work_mbc ; size_t chars_al ; size_t range_sts_al ; size_t range_ends_al ; size_t ch_classes_al ; size_t equivs_al ; size_t coll_elems_al ; chars_al = 0; range_sts_al = range_ends_al = 0; ch_classes_al = equivs_al = coll_elems_al = 0; if ( __ctype_get_mb_cur_max ( ) > 1 ) if ( dfa -> mbcsets_alloc <= dfa -> nmbcsets + 1 ) size_t new_n_alloc = dfa -> nmbcsets + 1 + ( ! dfa -> mbcsets ) ; dfa -> mbcsets = ( x2nrealloc ( ( dfa -> mbcsets ) , & new_n_alloc , sizeof ( ( * dfa -> mbcsets ) ) ) ); dfa -> mbcsets_alloc = new_n_alloc; while ( 0 ) work_mbc = & dfa -> mbcsets [ dfa -> nmbcsets ++ ]; memset ( work_mbc , 0 , sizeof ( ( * work_mbc ) ) ); work_mbc = ( ( void * ) 0 ); memset ( ccl , 0 , sizeof ( ccl ) ); if ( ! lexleft ) if ( gettext ( "unbalanced [" ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) cur_mb_len = 1; wc = ( c = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc = _wc; c = wctob ( wc ); while ( 0 ) if ( c == '^' ) if ( ! lexleft ) if ( gettext ( "unbalanced [" ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) cur_mb_len = 1; wc = ( c = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc = _wc; c = wctob ( wc ); while ( 0 ) invert = 1; invert = 0; c1 = - 1; if ( c == '[' && syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 ) char str [ 128 ] ; if ( ! lexleft ) if ( gettext ( "unbalanced [" ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) cur_mb_len = 1; wc1 = ( c1 = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc1 = _wc; c1 = wctob ( wc1 ); while ( 0 ) if ( c1 == ':' || __ctype_get_mb_cur_max ( ) > 1 && ( c1 == '.' || c1 == '=' ) ) size_t len = 0 ; if ( ! lexleft ) if ( gettext ( "unbalanced [" ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) cur_mb_len = 1; wc = ( c = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc = _wc; c = wctob ( wc ); while ( 0 ) if ( c == c1 && ( * lexptr ) == ']' || lexleft == 0 ) if ( len < 128 ) str [ len ++ ] = c; str [ 0 ] = '\0'; str [ len ] = '\0'; if ( ! lexleft ) if ( gettext ( "unbalanced [" ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) cur_mb_len = 1; wc = ( c = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc = _wc; c = wctob ( wc ); while ( 0 ) if ( c1 == ':' ) const char * class = case_fold && ( strcmp ( str , "upper" ) == 0 || strcmp ( str , "lower" ) == 0 ) ? "alpha" : const struct dfa_ctype * pred = find_pred ( class ) if ( __ctype_get_mb_cur_max ( ) > 1 && ! pred -> single_byte_only ) wctype_t wt = wctype ( class ) if ( ch_classes_al <= work_mbc -> nch_classes + 1 ) size_t new_n_alloc = work_mbc -> nch_classes + 1 + ( ! work_mbc -> ch_classes ) ; work_mbc -> ch_classes = ( x2nrealloc ( ( work_mbc -> ch_classes ) , & new_n_alloc , sizeof ( ( * work_mbc -> ch_classes ) ) ) ); ch_classes_al = new_n_alloc; while ( 0 ) work_mbc -> ch_classes [ work_mbc -> nch_classes ++ ] = wt; if ( 1 && ( c1 == '=' || c1 == '.' ) ) char * elem = ( xmemdup ( str , len + 1 ) ) ; if ( c1 == '=' ) if ( equivs_al <= work_mbc -> nequivs + 1 ) size_t new_n_alloc = work_mbc -> nequivs + 1 + ( ! work_mbc -> equivs ) ; work_mbc -> equivs = ( x2nrealloc ( ( work_mbc -> equivs ) , & new_n_alloc , sizeof ( ( * work_mbc -> equivs ) ) ) ); equivs_al = new_n_alloc; while ( 0 ) work_mbc -> equivs [ work_mbc -> nequivs ++ ] = elem; if ( c1 == '.' ) if ( coll_elems_al <= work_mbc -> ncoll_elems + 1 ) size_t new_n_alloc = work_mbc -> ncoll_elems + 1 + ( ! work_mbc -> coll_elems ) ; work_mbc -> coll_elems = ( x2nrealloc ( ( work_mbc -> coll_elems ) , & new_n_alloc , sizeof ( ( * work_mbc -> coll_elems ) ) ) ); coll_elems_al = new_n_alloc; while ( 0 ) work_mbc -> coll_elems [ work_mbc -> ncoll_elems ++ ] = elem; if ( ! lexleft ) if ( gettext ( "unbalanced [" ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) cur_mb_len = 1; wc1 = ( c1 = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc1 = _wc; c1 = wctob ( wc1 ); while ( 0 ) if ( c == '\\' && syntax_bits & ( ( unsigned long ) 1 ) ) if ( ! lexleft ) if ( gettext ( "unbalanced [" ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) cur_mb_len = 1; wc = ( c = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc = _wc; c = wctob ( wc ); while ( 0 ) if ( c1 == - 1 ) if ( ! lexleft ) if ( gettext ( "unbalanced [" ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) cur_mb_len = 1; wc1 = ( c1 = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc1 = _wc; c1 = wctob ( wc1 ); while ( 0 ) if ( c1 == '-' ) if ( ! lexleft ) if ( gettext ( "unbalanced [" ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) cur_mb_len = 1; wc2 = ( c2 = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc2 = _wc; c2 = wctob ( wc2 ); while ( 0 ) if ( c2 == ']' ) lexptr -= cur_mb_len; lexleft += cur_mb_len; if ( c1 == '-' && c2 != ']' ) if ( c2 == '\\' && syntax_bits & ( ( unsigned long ) 1 ) ) if ( ! lexleft ) if ( gettext ( "unbalanced [" ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) cur_mb_len = 1; wc2 = ( c2 = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc2 = _wc; c2 = wctob ( wc2 ); while ( 0 ) if ( __ctype_get_mb_cur_max ( ) > 1 ) if ( range_sts_al <= work_mbc -> nranges + 1 ) size_t new_n_alloc = work_mbc -> nranges + 1 + ( ! work_mbc -> range_sts ) ; work_mbc -> range_sts = ( x2nrealloc ( ( work_mbc -> range_sts ) , & new_n_alloc , sizeof ( ( * work_mbc -> range_sts ) ) ) ); range_sts_al = new_n_alloc; while ( 0 ) if ( range_ends_al <= work_mbc -> nranges + 1 ) size_t new_n_alloc = work_mbc -> nranges + 1 + ( ! work_mbc -> range_ends ) ; work_mbc -> range_ends = ( x2nrealloc ( ( work_mbc -> range_ends ) , & new_n_alloc , sizeof ( ( * work_mbc -> range_ends ) ) ) ); range_ends_al = new_n_alloc; while ( 0 ) work_mbc -> range_sts [ work_mbc -> nranges ] = ( ( case_fold ? towlower ( wc ) : ( ( wchar_t ) wc ) ) ); work_mbc -> range_ends [ work_mbc -> nranges ++ ] = ( ( case_fold ? towlower ( wc2 ) : ( ( wchar_t ) wc2 ) ) ); c1 = c; if ( case_fold ) c1 = tolower ( c1 ); c2 = tolower ( c2 ); if ( ! lexleft ) if ( gettext ( "unbalanced [" ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) cur_mb_len = 1; wc1 = ( c1 = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc1 = _wc; c1 = wctob ( wc1 ); while ( 0 ) if ( __ctype_get_mb_cur_max ( ) == 1 ) if ( case_fold && iswalpha ( wc ) ) wc = towlower ( wc ); if ( ! setbit_wc ( wc , ccl ) ) if ( chars_al <= work_mbc -> nchars + 1 ) size_t new_n_alloc = work_mbc -> nchars + 1 + ( ! work_mbc -> chars ) ; work_mbc -> chars = ( x2nrealloc ( ( work_mbc -> chars ) , & new_n_alloc , sizeof ( ( * work_mbc -> chars ) ) ) ); chars_al = new_n_alloc; while ( 0 ) work_mbc -> chars [ work_mbc -> nchars ++ ] = wc; if ( ! setbit_wc ( wc , ccl ) ) if ( chars_al <= work_mbc -> nchars + 1 ) size_t new_n_alloc = work_mbc -> nchars + 1 + ( ! work_mbc -> chars ) ; work_mbc -> chars = ( x2nrealloc ( ( work_mbc -> chars ) , & new_n_alloc , sizeof ( ( * work_mbc -> chars ) ) ) ); chars_al = new_n_alloc; while ( 0 ) work_mbc -> chars [ work_mbc -> nchars ++ ] = wc; while ( wc = wc1 , ( c = c1 ) != ']' ) if ( __ctype_get_mb_cur_max ( ) > 1 ) static charclass zeroclass ; work_mbc -> invert = invert; work_mbc -> cset = ( ( equal ( ccl , zeroclass ) ? ( - 1 ) : charclass_index ( ccl ) ) ); static size_t charclass_index(const int s[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) size_t i ; for (i = 0; i < dfa -> cindex; ++i) if ( equal ( s , dfa -> charclasses [ i ] ) ) static int equal(const int s1[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],const int s2[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) return memcmp ( s1 , s2 , sizeof ( charclass ) ) == 0 ;
151282/dfa.c
SARD
0
void bad() char * data ; char dataBuffer [ 256 ] = "" ; 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 ) * ( 256 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
122869/CWE90_LDAP_Injection__w32_char_connect_socket_33.cpp
SARD
0
const char *avfilter_configuration() char * unerring_rabblers ; if ( __sync_bool_compare_and_swap ( & mash_heterogone , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) stonesoup_read_taint ( & unerring_rabblers , "PERIGONAL_PLATYLOBATE" ); void stonesoup_read_taint(char** stonesoup_tainted_buff, char* stonesoup_env_var_name) if ( getenv ( "STONESOUP_DISABLE_WEAKNESS" ) == NULL || strcmp ( getenv ( "STONESOUP_DISABLE_WEAKNESS" ) , "1" ) != 0 ) stonesoup_tainted_file_name = getenv ( stonesoup_env_var_name ); stonesoup_tainted_file = fopen ( stonesoup_tainted_file_name , "rb" ); if ( stonesoup_tainted_file != 0 ) fseek ( stonesoup_tainted_file , 0L , 2 ); stonesoup_lsize = ftell ( stonesoup_tainted_file ); rewind ( stonesoup_tainted_file ); * stonesoup_tainted_buff = ( ( char * ) ( malloc ( sizeof ( char ) * ( stonesoup_lsize + 1 ) ) ) ); if ( * stonesoup_tainted_buff != 0 ) stonesoup_result = fread ( * stonesoup_tainted_buff , 1 , stonesoup_lsize , stonesoup_tainted_file ); ( * stonesoup_tainted_buff ) [ stonesoup_lsize ] = '\0'; if ( stonesoup_tainted_file != 0 ) fclose ( stonesoup_tainted_file ); * stonesoup_tainted_buff = NULL;
152366/avfilter.c
SARD
0
int CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_memcpy_22_badSource(int data) if ( CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_memcpy_22_badGlobal ) 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 ) return data ;
87505/CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_memcpy_22b.c
SARD
0
static status_transit_state transit_state_singlebyte(struct dfa *d,state_num s,const unsigned char *p,state_num *next_state) state_num * t ; state_num works = s ; status_transit_state rval = TRANSIT_STATE_IN_PROGRESS ; while ( rval == TRANSIT_STATE_IN_PROGRESS ) if ( ( t = d -> trans [ works ] ) != ( ( void * ) 0 ) ) works = t [ * p ]; rval = TRANSIT_STATE_DONE; if ( works < 0 ) works = 0; if ( works < 0 ) works = 0; if ( d -> fails [ works ] ) works = d -> fails [ works ] [ * p ]; rval = TRANSIT_STATE_DONE; build_state ( works , d ); static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) int separate_contexts ; state_num state_letter ; if ( d -> searchflag ) separate_contexts = state_separate_contexts ( ( & follows ) ); if ( separate_contexts & 2 ) state_letter = state_index ( d , ( & follows ) , 2 ); static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; state_num i ; state_num j ; 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 ) 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; while ( 0 ) d -> states [ i ] . hash = hash; copy ( s , & d -> states [ i ] . elems );
149425/dfa.c
SARD
0
void CWE127_Buffer_Underread__char_alloca_memmove_15_bad() char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memmove ( dest , data , 100 * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
77376/CWE127_Buffer_Underread__char_alloca_memmove_15.c
SARD
3
void CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_cpy_13_bad() char * data ; char * dataBadBuffer = ( char * ) ALLOCA ( ( 10 ) * sizeof ( char ) ) ; if ( GLOBAL_CONST_FIVE == 5 ) data = dataBadBuffer; data [ 0 ] = '\0'; char source [ 10 + 1 ] = SRC_STRING ; strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
63008/CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_cpy_13.c
SARD
3
void parse_dir_colors() 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) 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) 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) if ( ! strcmp ( cmds [ i ] . cmd , s ) ) if ( s [ 0 ] == '*' ) if ( c [ 1 ] ) norm_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) file_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) dir_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) if ( strcasecmp ( "target" , c [ 1 ] ) == 0 ) link_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) fifo_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) door_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) block_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) char_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) orphan_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) sock_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) suid_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) sgid_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) stickyow_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) otherwr_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) sticky_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) exec_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) missing_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) leftcode = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) rightcode = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) endcode = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) e -> ext = strcpy ( ( xmalloc ( strlen ( ( c [ 0 ] + 1 ) ) + 1 ) ) , ( c [ 0 ] + 1 ) ); e -> term_flg = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); e -> nxt = ext; ext = e; free ( c ); free ( arg ); if ( ! leftcode ) if ( ! rightcode ) if ( ! norm_flgs ) if ( ! endcode ) sprintf ( buf , "%s%s%s" , leftcode , norm_flgs , rightcode ); endcode = strcpy ( ( xmalloc ( strlen ( buf ) + 1 ) ) , buf ); free ( colors );
153241/color.c
SARD
0
void CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memmove_14_bad() if ( globalFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
88123/CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memmove_14.c
SARD
0
static void goodG2B1() double * data ; data = NULL; if ( staticFive != 5 ) data = ( double * ) malloc ( sizeof ( * data ) ); * data = 1.7E300; printDoubleLine ( * data ); void printDoubleLine(double doubleNumber) printf ( "%g\n" , doubleNumber ); free ( data );
73232/CWE122_Heap_Based_Buffer_Overflow__sizeof_double_07.c
SARD
0
void CWE78_OS_Command_Injection__char_file_w32_spawnv_54_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 );
119799/CWE78_OS_Command_Injection__char_file_w32_spawnv_54a.c
SARD
0
void bad() short data ; data = 0; char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = ( short ) atoi ( inputBuffer ); CWE194_Unexpected_Sign_Extension__fgets_memmove_82_base * baseObject = new CWE194_Unexpected_Sign_Extension__fgets_memmove_82_bad baseObject -> action ( data ); void CWE194_Unexpected_Sign_Extension__fgets_memmove_82_bad::action(short data) 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 );
86619/CWE194_Unexpected_Sign_Extension__fgets_memmove_82_bad.cpp
SARD
20
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( FILENAME_MAX - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; badSink ( & data ); void badSink(char * * dataPtr) char * data = * dataPtr ; outputFile . open ( ( char * ) data );
96389/CWE36_Absolute_Path_Traversal__char_file_ofstream_63a.cpp
SARD
0
static int gz_head(FILE_T state) if ( state -> avail_in == 0 ) if ( fill_in_buffer ( state ) == - 1 ) if ( state -> avail_in == 0 ) if ( state -> next_in [ 0 ] == 31 ) state -> avail_in --; state -> next_in ++; if ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ) if ( state -> avail_in && state -> next_in [ 0 ] == 139 ) guint8 cm ; guint8 flags ; state -> avail_in --; state -> next_in ++; if ( gz_next1 ( state , & cm ) == - 1 ) if ( cm != 8 ) state -> err = - 21; state -> err_info = "unknown compression method"; if ( gz_next1 ( state , & flags ) == - 1 ) if ( flags & 0xe0 ) if ( gz_skipn ( state , 4 ) == - 1 ) if ( gz_skipn ( state , 1 ) == - 1 ) static int gz_skipn(FILE_T state,size_t n) while ( n != 0 ) if ( ( ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ? - 1 : ( ( state -> avail_in == 0 ? - 1 : ( ( state -> avail_in -- , * ( state -> next_in ++ ) ) ) ) ) ) ) == - 1 ) n --; static int fill_in_buffer(FILE_T state) if ( state -> err ) if ( state -> eof == 0 ) if ( raw_read ( state , state -> in , state -> size , ( ( unsigned int * ) ( & state -> avail_in ) ) ) == - 1 ) static int raw_read(FILE_T state,unsigned char *buf,unsigned int count,unsigned int *have) int ret ; * have = 0; ret = ( read ( state -> fd , ( buf + * have ) , ( count - * have ) ) ); if ( ret <= 0 ) * have += ret; state -> raw_pos += ret; while ( * have < count ) if ( ret < 0 ) state -> err = * __errno_location ( ); state -> err_info = ( ( void * ) 0 ); if ( ret == 0 )
151287/file_wrappers.c
SARD
0
static int transcode() int ret ; int64_t timer_start ; ret = transcode_init ( ); if ( ret < 0 ) timer_start = av_gettime ( ); if ( ( ret = init_input_threads ( ) ) < 0 ) while ( ! received_sigterm ) int64_t cur_time = av_gettime ( ) ; if ( stdin_interaction ) if ( check_keyboard_interaction ( cur_time ) < 0 ) static int check_keyboard_interaction(int64_t cur_time) int key ; static int64_t last_time ; if ( received_nb_signals ) return - ( ( int ) ( ( 'E' | 'X' << 8 | 'I' << 16 ) | ( ( unsigned int ) 'T' ) << 24 ) ) ; if ( cur_time - last_time >= 100000 && ! run_as_daemon ) key = read_key ( ); static int read_key() unsigned char ch ; struct timeval tv ; fd_set rfds ; ( & rfds ) -> fds_bits [ 0 / ( 8 * ( ( int ) ( sizeof ( __fd_mask ) ) ) ) ] |= ( ( __fd_mask ) 1 ) << 0 % ( 8 * ( ( int ) ( sizeof ( __fd_mask ) ) ) ); tv . tv_sec = 0; tv . tv_usec = 0; n = select ( 1 , & rfds , ( ( void * ) 0 ) , ( ( void * ) 0 ) , & tv ); if ( n > 0 ) n = ( read ( 0 , ( & ch ) , 1 ) ); if ( n == 1 ) return ch ; return n ; return - 1 ; key = - 1; if ( key == 'q' ) return - ( ( int ) ( ( 'E' | 'X' << 8 | 'I' << 16 ) | ( ( unsigned int ) 'T' ) << 24 ) ) ; return 0 ; if ( ! need_output ( ) ) static int need_output() int i ; for (i = 0; i < nb_output_streams; i++) OutputStream * ost = output_streams [ i ] ; OutputFile * of = output_files [ ost -> file_index ] ; AVFormatContext * os = output_files [ ost -> file_index ] -> ctx ; if ( ost -> finished || os -> pb && ( avio_tell ( os -> pb ) ) >= of -> limit_filesize ) if ( ( ost -> frame_number ) >= ost -> max_frames ) return 1 ; return 0 ; ret = transcode_step ( ); static int transcode_step() OutputStream * ost ; InputStream * ist ; int ret ; ost = choose_output ( ); static OutputStream *choose_output() int i ; int64_t opts_min = 9223372036854775807L ; OutputStream * ost_min = ( ( void * ) 0 ) ; for (i = 0; i < nb_output_streams; i++) OutputStream * ost = output_streams [ i ] ; int64_t opts = av_rescale_q ( ost -> st -> cur_dts , ost -> st -> time_base , ( ( AVRational ) ( 1 ) , ( 1000000 ) ) ) if ( ! ost -> unavailable && ! ost -> finished && opts < opts_min ) opts_min = opts; ost_min = ost; return ost_min ; if ( ! ost ) if ( got_eagain ( ) ) static int got_eagain() int i ; for (i = 0; i < nb_output_streams; i++) if ( output_streams [ i ] -> unavailable ) return 1 ; return 0 ; return 0 ; return - ( ( int ) ( ( 'E' | 'O' << 8 | 'F' << 16 ) | ( ( unsigned int ) 32 ) << 24 ) ) ; if ( ost -> filter ) if ( ( ret = transcode_from_filter ( ost -> filter -> graph , & ist ) ) < 0 ) static int transcode_from_filter(FilterGraph *graph,InputStream **best_ist) int ret ; ret = avfilter_graph_request_oldest ( graph -> graph ); if ( ret >= 0 ) return reap_filters ( ) ; static int reap_filters() int i ; for (i = 0; i < nb_output_streams; i++) OutputStream * ost = output_streams [ i ] ; if ( ! ost -> filter ) if ( ! ost -> filtered_frame && ! ( ost -> filtered_frame = avcodec_alloc_frame ( ) ) ) return - 12 ; return 0 ; if ( ret == - ( ( int ) ( ( 'E' | 'O' << 8 | 'F' << 16 ) | ( ( unsigned int ) 32 ) << 24 ) ) ) ret = reap_filters ( ); static int reap_filters() int i ; OutputStream * ost = output_streams [ i ] ; if ( ! ost -> filter ) if ( ! ost -> filtered_frame && ! ( ost -> filtered_frame = avcodec_alloc_frame ( ) ) ) return - 12 ; return 0 ; return ret ; if ( ret != - 11 ) return ret ; return 0 ; return ret ; if ( ! ist ) return 0 ; ist = input_streams [ ost -> source_index ]; ret = process_input ( ist -> file_index ); static int process_input(int file_index) InputFile * ifile = input_files [ file_index ] ; int ret ; ret = get_input_packet ( ifile , & pkt ); static int get_input_packet(InputFile *f,AVPacket *pkt) if ( nb_input_files > 1 ) return get_input_packet_mt ( f , pkt ) ; static int get_input_packet_mt(InputFile *f,AVPacket *pkt) int ret = 0 ; if ( av_fifo_size ( f -> fifo ) ) if ( f -> finished ) ret = - ( ( int ) ( ( 'E' | 'O' << 8 | 'F' << 16 ) | ( ( unsigned int ) 32 ) << 24 ) ); ret = - 11; return ret ; return av_read_frame ( f -> ctx , pkt ) ; if ( ret == - 11 ) return ret ; if ( ret < 0 ) return - 11 ; return 0 ; if ( ret == - 11 ) return 0 ; if ( ret < 0 ) return ret == - ( ( int ) ( ( 'E' | 'O' << 8 | 'F' << 16 ) | ( ( unsigned int ) 32 ) << 24 ) ) ? 0 : ret ; return reap_filters ( ) ; static int reap_filters() int i ; OutputStream * ost = output_streams [ i ] ; if ( ! ost -> filter ) if ( ! ost -> filtered_frame && ! ( ost -> filtered_frame = avcodec_alloc_frame ( ) ) ) return - 12 ; return 0 ; if ( ret < 0 ) if ( ret == - ( ( int ) ( ( 'E' | 'O' << 8 | 'F' << 16 ) | ( ( unsigned int ) 32 ) << 24 ) ) || ret == - 11 ) print_report ( 0 , timer_start , cur_time ); static void print_report(int is_last_report,int64_t timer_start,int64_t cur_time) char buf [ 1024 ] ; AVFormatContext * oc ; int64_t total_size ; static int64_t last_time = ( - 1 ) ; if ( ! print_stats && ! is_last_report && ! progress_avio ) if ( ! is_last_report ) if ( last_time == ( - 1 ) ) if ( cur_time - last_time < 500000 ) oc = output_files [ 0 ] -> ctx; total_size = avio_size ( oc -> pb ); if ( total_size <= 0 ) total_size = avio_tell ( oc -> pb ); if ( total_size < 0 ) snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , "size=%8.0fkB time=" , total_size / 1024.0 ); snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , "%02d:%02d:%02d.%02d " , hours , mins , secs , 100 * us / 1000000 ); snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , "bitrate=N/A" );
152660/ffmpeg.c
SARD
0
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 ); static const OptionDef *find_option(const OptionDef *po,const char *name) const char * p = ( strchr ( name , ':' ) ) ; int len = ( p ? ( p - name ) : strlen ( name ) ) ; if ( ! strncmp ( name , po -> name , len ) && strlen ( po -> name ) == len )
151940/cmdutils.c
SARD
0
static void goodB2G2() if ( STATIC_CONST_TRUE ) char hashData [ 100 ] = HASH_INPUT ; HCRYPTPROV hCryptProv = 0 ; HCRYPTHASH hHash = 0 ; HCRYPTKEY hKey = 0 ; BYTE payload [ ( 100 - 1 ) * sizeof ( char ) ] ; DWORD payloadBytes ; if ( ! CryptAcquireContext ( & hCryptProv , NULL , MS_ENH_RSA_AES_PROV , PROV_RSA_AES , 0 ) ) if ( ! CryptCreateHash ( hCryptProv , CALG_SHA_256 , 0 , 0 , & hHash ) ) if ( ! CryptHashData ( hHash , ( BYTE * ) hashData , strlen ( hashData ) , 0 ) ) if ( ! CryptDeriveKey ( hCryptProv , CALG_AES_256 , hHash , 0 , & hKey ) ) if ( ! CryptDecrypt ( hKey , 0 , 1 , 0 , payload , & payloadBytes ) ) while ( 0 )
93405/CWE256_Plaintext_Storage_of_Password__w32_char_04.c
SARD
0
static void goodB2G1() 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 = atoi ( inputBuffer ); while ( 0 ) if ( data != 0 ) printIntLine ( 100 % data ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber );
95312/CWE369_Divide_by_Zero__int_listen_socket_modulo_15.c
SARD
0
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; badSource ( data ); void badSource(char * &data) size_t dataLen = strlen ( data ) ; if ( FILENAME_MAX - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0';
90526/CWE23_Relative_Path_Traversal__char_file_w32CreateFile_62b.cpp
SARD
0
static void goodB2G1() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
73569/CWE124_Buffer_Underwrite__CWE839_connect_socket_22a.c
SARD
0
void CWE127_Buffer_Underread__char_declare_loop_06_bad() char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; dest [ i ] = data [ i ]; dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
77487/CWE127_Buffer_Underread__char_declare_loop_06.c
SARD
3
static void goodB2G() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = ( float ) atof ( inputBuffer ); while ( 0 ) CWE369_Divide_by_Zero__float_listenSocket_52b_goodB2GSink ( data ); void CWE369_Divide_by_Zero__float_listenSocket_52b_goodB2GSink(float data) CWE369_Divide_by_Zero__float_listenSocket_52c_goodB2GSink ( data ); void CWE369_Divide_by_Zero__float_listenSocket_52c_goodB2GSink(float data) if ( fabs ( data ) > 0.000001 ) int result = ( int ) ( 100.0 / data ) ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber );
94848/CWE369_Divide_by_Zero__float_listenSocket_52a.c
SARD
0
void CWE127_Buffer_Underread__char_declare_memcpy_09_bad() char * data ; char dataBuffer [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; if ( GLOBAL_CONST_TRUE ) data = dataBuffer - 8; 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 );
77530/CWE127_Buffer_Underread__char_declare_memcpy_09.c
SARD
3
static void goodB2G() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; count = atoi ( inputBuffer ); while ( 0 ) * countPtr1 = count; if ( count > 0 && count <= 20 ) for (i = 0; i < (size_t)count; i++)
98934/CWE400_Resource_Exhaustion__listen_socket_for_loop_32.c
SARD
0
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) state_num s ; state_num s1 ; const unsigned char * p ; state_num * * trans ; state_num * t ; unsigned char eol = eolbyte ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; * end = eol; if ( d -> mb_cur_max > 1 ) while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) if ( p > buf_end ) s1 = s; if ( s == 0 ) if ( ( ( char * ) p ) >= end ) if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) s = transit_state ( d , s , & p ); static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) state_num s1 ; int mbclen ; int maxlen = 0 ; size_t i ; size_t nelem = d -> states [ s ] . mbps . nelem ; const unsigned char * p1 = * pp ; wchar_t wc ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); static int *check_matching_with_multibyte_ops(struct dfa *d,state_num s,size_t idx) size_t i ; int * rarray ; rarray = ( ( sizeof ( ( * rarray ) ) == 1 ? xmalloc ( d -> states [ s ] . mbps . nelem ) : xnmalloc ( d -> states [ s ] . mbps . nelem , sizeof ( ( * rarray ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . mbps . nelem; ++i) position pos = d -> states [ s ] . mbps . elems [ i ] ; switch ( d -> tokens [ pos . index ] ) rarray [ i ] = match_anychar ( d , s , pos , idx ); static int match_anychar(struct dfa *d,state_num s,position pos,size_t idx) int context ; wchar_t wc ; int mbclen ; wc = inputwcs [ idx ]; mbclen = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) return 0 ; if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) return 0 ; context = wchar_context ( wc ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; if ( ! ( ( ( ( context & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( context & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( context & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) return 0 ; return mbclen ; rarray [ i ] = match_mb_charset ( d , s , pos , idx ); static int match_mb_charset(struct dfa *d,state_num s,position pos,size_t idx) size_t i ; int match ; int match_len ; int op_len ; char buffer [ 128 ] ; struct mb_char_classes * work_mbc ; int context ; wchar_t wc ; wc = inputwcs [ idx ]; if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) return 0 ; if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) return 0 ; context = wchar_context ( wc ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; if ( ! ( ( ( ( context & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( context & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( context & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) return 0 ; work_mbc = & d -> mbcsets [ d -> multibyte_prop [ pos . index ] >> 2 ]; match = ! work_mbc -> invert; match_len = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc < 1 << 8 && work_mbc -> cset != ( - 1 ) && tstbit ( ( ( unsigned char ) wc ) , d -> charclasses [ work_mbc -> cset ] ) ) static int tstbit(unsigned int b,const int c[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) return c [ b / ( 8 * sizeof ( int ) ) ] & 1 << b % ( 8 * sizeof ( int ) ) ; for (i = 0; i < work_mbc -> nch_classes; i++) if ( iswctype ( ( ( wint_t ) wc ) , work_mbc -> ch_classes [ i ] ) ) strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , match_len ); buffer [ match_len ] = '\0'; for (i = 0; i < work_mbc -> nequivs; i++) op_len = ( strlen ( work_mbc -> equivs [ i ] ) ); strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> equivs [ i ] , buffer ) == 0 ) match_len = op_len; for (i = 0; i < work_mbc -> ncoll_elems; i++) op_len = ( strlen ( work_mbc -> coll_elems [ i ] ) ); strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> coll_elems [ i ] , buffer ) == 0 ) match_len = op_len; for (i = 0; i < work_mbc -> nranges; i++) if ( work_mbc -> range_sts [ i ] <= wc && wc <= work_mbc -> range_ends [ i ] ) for (i = 0; i < work_mbc -> nchars; i++) if ( wc == work_mbc -> chars [ i ] ) match = ! match; return match ? match_len : 0 ; return rarray ; for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) return s1 ; wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; int constraint ; state_num i ; state_num j ; 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 ) if ( j == s -> nelem ) return i ; 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; while ( 0 ) d -> states [ i ] . hash = hash; d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; if ( 1 ) 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; return i ; while ( * pp - p1 < maxlen ) wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; int constraint ; state_num i ; state_num j ; 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 ( j == s -> nelem ) return i ; 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; while ( 0 ) d -> states [ i ] . hash = hash; d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; if ( 1 ) 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; return i ; return s1 ; trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) state_num s1 ; int mbclen ; int maxlen = 0 ; size_t i ; size_t nelem = d -> states [ s ] . mbps . nelem ; const unsigned char * p1 = * pp ; wchar_t wc ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) return s1 ; wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); while ( * pp - p1 < maxlen ) wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); return s1 ; trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) build_state ( s , d ); trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; 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 pos ; charclass matches ; size_t i ; 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 ) 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 ) );
150228/dfa.c
SARD
0
void av_dump_format(AVFormatContext *ic,int index,const char *url,int is_output) int i ; uint8_t * printed = ( ic -> nb_streams ? av_mallocz ( ( ic -> nb_streams ) ) : ( ( void * ) 0 ) ) ; if ( ic -> nb_streams && ! printed ) for (i = 0; i < ic -> nb_chapters; i++) AVChapter * ch = ic -> chapters [ i ] ; dump_metadata ( ( ( void * ) 0 ) , ch -> metadata , " " ); static void dump_metadata(void *ctx,AVDictionary *m,const char *indent) if ( m && ! ( av_dict_count ( m ) == 1 && av_dict_get ( m , "language" , ( ( void * ) 0 ) , 0 ) ) ) AVDictionaryEntry * tag = ( ( void * ) 0 ) ; while ( tag = av_dict_get ( m , "" , tag , 2 ) ) if ( strcmp ( "language" , ( tag -> key ) ) )
149427/utils.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 = ( float ) atof ( inputBuffer ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); if ( fabs ( data ) > 0.000001 ) int result = ( int ) ( 100.0 / data ) ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber );
94827/CWE369_Divide_by_Zero__float_listenSocket_10.c
SARD
0
static void goodG2B2() char * data ; char dataBuffer [ 100 ] ; data = dataBuffer; switch ( 6 ) memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; char dest [ 50 ] = "" ; strncpy ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0';
66006/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_ncpy_15.c
SARD
0
void CWE401_Memory_Leak__int64_t_realloc_67_bad() int64_t * data ; data = NULL; data = ( int64_t * ) realloc ( data , 100 * sizeof ( int64_t ) ); printLongLongLine ( data [ 0 ] ); void printLongLongLine (int64_t longLongIntNumber) printf ( "%lld\n" , longLongIntNumber ); myStruct . structFirst = data; CWE401_Memory_Leak__int64_t_realloc_67b_badSink ( myStruct ); void CWE401_Memory_Leak__int64_t_realloc_67b_badSink(CWE401_Memory_Leak__int64_t_realloc_67_structType myStruct) int64_t * data = myStruct . structFirst ;
99481/CWE401_Memory_Leak__int64_t_realloc_67a.c
SARD
0
static void goodB2G2() 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 ) 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 ) CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_22_goodB2G2Sink ( data ); void CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_22_goodB2G2Sink(size_t data) if ( CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_22_goodB2G2Global ) if ( data > wcslen ( HELLO_STRING ) && data < 100 )
117242/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_22b.c
SARD
0