func
stringlengths 181
23.6k
| path
stringlengths 12
123
| source
stringclasses 2
values | label
int64 0
40
|
---|---|---|---|
void initlinedraw(int flag) char * stonesoup_heap_buff_64 ; char * inamovability_pictet ; if ( __sync_bool_compare_and_swap ( & syllabified_ogenetic , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) inamovability_pictet = getenv ( "SEMIDIGESTED_MACHINEMEN" ); if ( inamovability_pictet != 0 ) shipwrecks_scrawly = ( ( char * ) inamovability_pictet ); stonesoup_heap_buff_64 = ( char * ) malloc ( 64 * sizeof ( char ) ); if ( stonesoup_heap_buff_64 != NULL ) memset ( stonesoup_heap_buff_64 , 'A' , 63 ); stonesoup_heap_buff_64 [ 63 ] = '\0'; strncpy ( stonesoup_heap_buff_64 , shipwrecks_scrawly , 64 ); free ( stonesoup_heap_buff_64 ); | 153240/color.c | SARD | 0 |
static VerifyStyleTree(nsPresContext* aPresContext, nsIFrame* nsStyleContext* aParentContext) nsIFrame :: ChildListIterator lists ( aFrame ) ; for (; !lists.IsDone(); lists.Next()) nsFrameList :: Enumerator childFrames ( lists . CurrentList ( ) ) ; for (; !childFrames.AtEnd(); childFrames.Next()) nsIFrame * child = childFrames . get ( ) ; if ( ! ( child -> GetStateBits ( ) & NS_FRAME_OUT_OF_FLOW ) ) if ( nsGkAtoms :: placeholderFrame == child -> GetType ( ) ) VerifyStyleTree ( aPresContext , child , nullptr ); static VerifyStyleTree(nsPresContext* aPresContext, nsIFrame* nsStyleContext* aParentContext) nsStyleContext * context = aFrame -> StyleContext ( ) ; VerifyContextParent ( aPresContext , aFrame , context , nullptr ); static VerifyContextParent(nsPresContext* aPresContext, nsIFrame* nsStyleContext* aContext, nsStyleContext* aParentContext) if ( ! aContext ) aContext = aFrame -> StyleContext ( ); if ( ! aParentContext ) nsIFrame * providerFrame = aFrame -> GetParentStyleContextFrame ( ) ; if ( providerFrame ) aParentContext = providerFrame -> StyleContext ( ); nsStyleContext * actualParentContext = aContext -> GetParent ( ) ; if ( aParentContext ) if ( actualParentContext ) DumpContext ( aFrame , aContext ); static DumpContext(nsIFrame* aFrame, nsStyleContext* aContext) if ( aFrame ) nsAutoString name ; fputs ( NS_LossyConvertUTF16toASCII ( name ) . get ( ) , stdout ); | CVE-2015-0826/Firefox_35.0b8_CVE_2015_0826_layout_base_RestyleManager.cpp | NVD | 0 |
proto_item_prepend_text(proto_item *pi, const char *format, ...) char representation [ ITEM_LABEL_LENGTH ] ; fi = PITEM_FINFO ( pi ); if ( fi == NULL ) if ( ! PROTO_ITEM_IS_HIDDEN ( pi ) ) if ( fi -> rep == NULL ) proto_item_fill_label ( fi , representation ); proto_item_fill_label(field_info *fi, gchar *label_str) header_field_info * hfinfo ; guint8 * bytes ; if ( ! fi ) hfinfo = fi -> hfinfo; switch ( hfinfo -> type ) bytes = ( guint8 * ) fvalue_get ( & fi -> value ); bytes = ( guint8 * ) fvalue_get ( & fi -> value ); bytes = ( guint8 * ) fvalue_get ( & fi -> value ); bytes = ( guint8 * ) fvalue_get ( & fi -> value ); bytes = ( guint8 * ) fvalue_get ( & fi -> value ); bytes = ( guint8 * ) fvalue_get ( & fi -> value ); bytes = ( guint8 * ) fvalue_get ( & fi -> value ); label_fill ( label_str , 0 , hfinfo , hfinfo_format_text ( hfinfo , bytes ) ); static const char hfinfo_format_text(const header_field_info *hfinfo, const guchar *string) switch ( hfinfo -> display ) return format_text ( string , strlen ( string ) ) ; | CVE-2016-4006/Wireshark_2.0.2_CVE_2016_4006_epan_proto.c | NVD | 0 |
static void goodG2B2() int64_t * data ; data = NULL; if ( staticTrue ) 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 | 68820/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_int64_t_memmove_05.cpp | SARD | 0 |
GimpImage *gimp_display_get_image(GimpDisplay *display) int hyparterial_inscribers = 7 ; char * castoffs_perpended ; if ( __sync_bool_compare_and_swap ( & joyproof_nobility , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( castoffs_perpended != 0 ) chaitra_graphophone = ( ( void * ) castoffs_perpended ); supervitally_moonblink = & chaitra_graphophone; overbowed_interspersing = supervitally_moonblink + 5; proagrarian_ingrammaticism ( hyparterial_inscribers , overbowed_interspersing ); void proagrarian_ingrammaticism(int tastiness_molosse,void **elemis_meetnesses) int stonesoup_len ; tastiness_molosse --; if ( tastiness_molosse > 0 ) excellency_overcalculation = ( ( char * ) ( ( char * ) ( * ( elemis_meetnesses - 5 ) ) ) ); stonesoup_len = atoi ( excellency_overcalculation ); if ( stonesoup_len < 4096 ) stonesoup_buffer = ( ( char * ) ( malloc ( 4096 * sizeof ( char ) ) ) ); if ( stonesoup_buffer != 0 ) memset ( stonesoup_buffer , 'a' , 4096 ); memset ( & stonesoup_buffer [ stonesoup_len ] , 'b' , 4096 - stonesoup_len ); stonesoup_buffer [ 4095 ] = 0; stonesoup_printf ( "%s\n" , stonesoup_buffer ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); free ( stonesoup_buffer ); | 151420/gimpdisplay.c | SARD | 23 |
void CWE78_OS_Command_Injection__char_connect_socket_w32spawnl_22_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; data = CWE78_OS_Command_Injection__char_connect_socket_w32spawnl_22_badSource ( data ); char * CWE78_OS_Command_Injection__char_connect_socket_w32spawnl_22_badSource(char * data) if ( CWE78_OS_Command_Injection__char_connect_socket_w32spawnl_22_badGlobal ) size_t dataLen = strlen ( data ) ; recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; return data ; | 118394/CWE78_OS_Command_Injection__char_connect_socket_w32spawnl_22b.c | SARD | 0 |
void CWE127_Buffer_Underread__wchar_t_declare_cpy_66_bad() wchar_t * data ; wchar_t * dataArray [ 5 ] ; wchar_t dataBuffer [ 100 ] ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer - 8; dataArray [ 2 ] = data; CWE127_Buffer_Underread__wchar_t_declare_cpy_66b_badSink ( dataArray ); void CWE127_Buffer_Underread__wchar_t_declare_cpy_66b_badSink(wchar_t * dataArray[]) wchar_t * data = dataArray [ 2 ] ; wchar_t dest [ 100 * 2 ] ; wmemset ( dest , L 'C' , 100 * 2 - 1 dest [ 100 * 2 - 1 ] = L '\0' wcscpy ( dest , data ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 78930/CWE127_Buffer_Underread__wchar_t_declare_cpy_66b.c | SARD | 3 |
static void goodG2B() 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 ); | 74450/CWE124_Buffer_Underwrite__malloc_char_ncpy_31.c | SARD | 0 |
static void goodG2B() short data ; short * dataPtr2 = & data ; data = 0; data = 100 - 1; short data = * dataPtr2 ; 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 ); | 86355/CWE194_Unexpected_Sign_Extension__connect_socket_memcpy_32.c | SARD | 0 |
static void goodG2B() int data ; data = - 1; CWE122_Heap_Based_Buffer_Overflow__c_CWE129_connect_socket_84_goodG2B * goodG2BObject = new CWE122_Heap_Based_Buffer_Overflow__c_CWE129_connect_socket_84_goodG2B ( data ) ; CWE122_Heap_Based_Buffer_Overflow__c_CWE129_connect_socket_84_goodG2B::CWE122_Heap_Based_Buffer_Overflow__c_CWE129_connect_socket_84_goodG2B(int dataCopy) data = dataCopy; data = 7; delete goodG2BObject CWE122_Heap_Based_Buffer_Overflow__c_CWE129_connect_socket_84_goodG2B::~CWE122_Heap_Based_Buffer_Overflow__c_CWE129_connect_socket_84_goodG2B() int i ; int * buffer = ( int * ) malloc ( 10 * sizeof ( int ) ) ; for (i = 0; i < 10; i++) buffer [ i ] = 0; if ( data >= 0 ) buffer [ data ] = 1; free ( buffer ); | 70495/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_connect_socket_84_goodG2B.cpp | SARD | 0 |
void CWE124_Buffer_Underwrite__char_alloca_ncpy_02_bad() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; if ( 1 ) data = dataBuffer - 8; 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 ); | 73903/CWE124_Buffer_Underwrite__char_alloca_ncpy_02.c | SARD | 3 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( FILENAME_MAX - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; fclose ( pFile ); funcPtr ( data ); | 96487/CWE36_Absolute_Path_Traversal__char_file_w32CreateFile_65a.cpp | SARD | 0 |
int color(u_short mode,char *name,bool orphan,bool islink) if ( orphan ) if ( islink ) if ( missing_flgs ) if ( orphan_flgs ) fprintf ( outfile , "%s%s%s" , leftcode , orphan_flgs , rightcode ); switch ( mode & 0170000 ) if ( ! fifo_flgs ) fprintf ( outfile , "%s%s%s" , leftcode , fifo_flgs , rightcode ); fprintf ( outfile , "%s%s%s" , leftcode , char_flgs , rightcode ); fprintf ( outfile , "%s%s%s" , leftcode , stickyow_flgs , rightcode ); | 153395/color.c | SARD | 0 |
void bad() char * data ; map < int , char * > dataMap ; data = NULL; data = ( char * ) malloc ( 10 * sizeof ( char ) ); dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; badSink ( dataMap ); void badSink(map<int, char *> dataMap) char * data = dataMap [ 2 ] ; char source [ 10 + 1 ] = SRC_STRING ; strncpy ( data , source , strlen ( source ) + 1 ); free ( data ); | 70971/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_ncpy_74b.cpp | SARD | 3 |
void bad() char * data ; data = NULL; CWE690_NULL_Deref_From_Return__char_realloc_84_bad * badObject = new CWE690_NULL_Deref_From_Return__char_realloc_84_bad ( data ) ; CWE690_NULL_Deref_From_Return__char_realloc_84_bad::CWE690_NULL_Deref_From_Return__char_realloc_84_bad(char * dataCopy) data = dataCopy; data = ( char * ) realloc ( data , 20 * sizeof ( char ) ); delete badObject CWE690_NULL_Deref_From_Return__char_realloc_84_bad::~CWE690_NULL_Deref_From_Return__char_realloc_84_bad() strcpy ( data , "Initialize" ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 111121/CWE690_NULL_Deref_From_Return__char_realloc_84_bad.cpp | SARD | 2 |
void curler_vergerism(int basils_foreplan,char **torpedoing_woodwise) basils_foreplan --; if ( basils_foreplan > 0 ) curler_vergerism ( basils_foreplan , torpedoing_woodwise ); void curler_vergerism(int basils_foreplan,char **torpedoing_woodwise) basils_foreplan --; if ( basils_foreplan > 0 ) curler_vergerism ( basils_foreplan , torpedoing_woodwise ); void curler_vergerism(int basils_foreplan,char **torpedoing_woodwise) basils_foreplan --; if ( basils_foreplan > 0 ) curler_vergerism ( basils_foreplan , torpedoing_woodwise ); void curler_vergerism(int basils_foreplan,char **torpedoing_woodwise) struct stonesoup_data * stonesoupData ; basils_foreplan --; if ( basils_foreplan > 0 ) diapery_gibbous = ( ( char * ) torpedoing_woodwise [ 50 ] ); stonesoupData = malloc ( sizeof ( struct stonesoup_data ) ); if ( stonesoupData ) stonesoupData -> data = malloc ( sizeof ( char ) * ( strlen ( diapery_gibbous ) + 1 ) ); stonesoupData -> file1 = malloc ( sizeof ( char ) * ( strlen ( diapery_gibbous ) + 1 ) ); stonesoupData -> file2 = malloc ( sizeof ( char ) * ( strlen ( diapery_gibbous ) + 1 ) ); if ( stonesoupData -> data ) if ( ( sscanf ( diapery_gibbous , "%d %s %s %s" , & ( stonesoupData -> qsize ) , stonesoupData -> file1 , stonesoupData -> file2 , stonesoupData -> data ) == 4 ) && ( strlen ( stonesoupData -> data ) != 0 ) ) tracepoint ( stonesoup_trace , variable_signed_integral , "stonesoupData->qsize" , stonesoupData -> qsize , & ( stonesoupData -> qsize ) , "INITIAL-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoupData->data" , stonesoupData -> data , "INITIAL-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoupData->file1" , stonesoupData -> file1 , "INITIAL-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoupData->file2" , stonesoupData -> file2 , "INITIAL-STATE" ); stonesoupData -> data_size = strlen ( stonesoupData -> data ); while ( stonesoupData -> data [ stonesoup_i ] != '\0' ) if ( stonesoupData -> data [ stonesoup_i ] >= 'A' && stonesoupData -> data [ stonesoup_i ] <= 'Z' ) toLower ( stonesoupData ); if ( pthread_create ( & stonesoup_t0 , NULL , reverseStr , ( void * ) stonesoupData ) != 0 ) if ( pthread_create ( & stonesoup_t1 , NULL , to1337 , ( void * ) stonesoupData ) != 0 ) tracepoint ( stonesoup_trace , variable_signed_integral , "stonesoupData->qsize" , stonesoupData -> qsize , & ( stonesoupData -> qsize ) , "FINAL-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoupData->data" , stonesoupData -> data , "FINAL-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoupData->file1" , stonesoupData -> file1 , "FINAL-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoupData->file2" , stonesoupData -> file2 , "FINAL-STATE" ); stonesoup_printf ( "String: %s\n" , stonesoupData -> data ); free ( stonesoupData -> data ); free ( stonesoupData ); | 150451/config_file.c | SARD | 0 |
static void goodB2G() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); * dataPtr1 = data; if ( data < 0 ) if ( data > ( INT_MIN / 2 ) ) int result = data * 2 ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 85587/CWE191_Integer_Underflow__int_listen_socket_multiply_32.c | SARD | 0 |
static void goodB2G2() char * password ; char passwordBuffer [ 100 ] = "" ; password = passwordBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t passwordLen = strlen ( password ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( password + passwordLen ) , ( 100 - passwordLen - 1 ) * sizeof ( char ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) password [ passwordLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( password , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 94116/CWE319_Cleartext_Tx_Sensitive_Info__w32_char_connect_socket_21.c | SARD | 0 |
void bad() list < short > dataList ; badSink ( dataList ); void badSink(list<short> dataList) short data = dataList . back ( ) ; 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 ); | 86952/CWE194_Unexpected_Sign_Extension__listen_socket_memcpy_73b.cpp | SARD | 20 |
static void goodG2B() twoIntsStruct * data ; twoIntsStruct * dataGoodBuffer = ( twoIntsStruct * ) ALLOCA ( 100 * sizeof ( twoIntsStruct ) ) ; data = dataGoodBuffer; twoIntsStruct * dataCopy = data ; twoIntsStruct * data = dataCopy ; twoIntsStruct source [ 100 ] ; size_t i ; for (i = 0; i < 100; i++) source [ i ] . intOne = 0; source [ i ] . intOne = 0; memcpy ( data , source , 100 * sizeof ( twoIntsStruct ) ); printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); | 64850/CWE121_Stack_Based_Buffer_Overflow__CWE805_struct_alloca_memcpy_31.c | SARD | 0 |
static void goodB2G2() if ( STATIC_CONST_TRUE ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); if ( data > strlen ( HELLO_STRING ) && data < 100 ) 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 ); | 116986/CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_04.c | SARD | 0 |
static void goodB2G() char * password ; char passwordBuffer [ 100 ] = "" ; password = passwordBuffer; HCRYPTPROV hCryptProv = 0 ; HCRYPTHASH hHash = 0 ; HCRYPTKEY hKey = 0 ; char hashData [ 100 ] = HASH_INPUT ; BYTE payload [ ( 100 - 1 ) * sizeof ( char ) ] ; DWORD payloadBytes ; payloadBytes = decodeHexChars ( payload , sizeof ( payload ) , password ); size_t decodeHexChars(unsigned char * bytes, size_t numBytes, const char * hex) size_t numWritten = 0 ; while ( numWritten < numBytes && isxdigit ( hex [ 2 * numWritten ] ) && isxdigit ( hex [ 2 * numWritten + 1 ] ) ) int byte ; bytes [ numWritten ] = ( unsigned char ) byte; return numWritten ; if ( ! CryptAcquireContext ( & hCryptProv , NULL , MS_ENH_RSA_AES_PROV , PROV_RSA_AES , 0 ) ) if ( ! CryptCreateHash ( hCryptProv , CALG_SHA_256 , 0 , 0 , & hHash ) ) if ( ! CryptHashData ( hHash , ( BYTE * ) hashData , strlen ( hashData ) , 0 ) ) if ( ! CryptDeriveKey ( hCryptProv , CALG_AES_256 , hHash , 0 , & hKey ) ) if ( ! CryptDecrypt ( hKey , 0 , 1 , 0 , payload , & payloadBytes ) ) while ( 0 ) | 94172/CWE319_Cleartext_Tx_Sensitive_Info__w32_char_listen_socket_43.cpp | SARD | 0 |
static void goodB2G1() if ( staticFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); if ( abs ( ( long ) data ) <= ( long ) sqrt ( ( double ) INT_MAX ) ) int result = data * data ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 83076/CWE190_Integer_Overflow__int_connect_socket_square_07.c | SARD | 0 |
static void build_state_zero(struct dfa *d) d -> tralloc = 1; d -> trcount = 0; d -> realtrans = ( ( sizeof ( ( * d -> realtrans ) ) == 1 ? xzalloc ( ( d -> tralloc + 1 ) ) : xcalloc ( ( d -> tralloc + 1 ) , sizeof ( ( * d -> realtrans ) ) ) ) ); while ( 0 ) d -> trans = d -> realtrans + 1; d -> fails = ( ( sizeof ( ( * d -> fails ) ) == 1 ? xzalloc ( ( d -> tralloc ) ) : xcalloc ( ( d -> tralloc ) , sizeof ( ( * d -> fails ) ) ) ) ); while ( 0 ) d -> success = ( ( sizeof ( ( * d -> success ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> success ) ) ) ) ); while ( 0 ) d -> newlines = ( ( sizeof ( ( * d -> newlines ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> newlines ) ) ) ) ); while ( 0 ) build_state ( 0 , d ); static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) int separate_contexts ; state_num state_newline ; if ( d -> searchflag ) separate_contexts = state_separate_contexts ( ( & follows ) ); if ( separate_contexts & 4 ) state_newline = state_index ( d , ( & follows ) , 4 ); 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 ); | 151282/dfa.c | SARD | 0 |
svn_error_t *svn_stream_contents_same2(svn_boolean_t *same,svn_stream_t *stream1,svn_stream_t *stream2,apr_pool_t *pool) char * buf1 = ( apr_palloc ( pool , 16384 ) ) ; char * buf2 = ( apr_palloc ( pool , 16384 ) ) ; apr_size_t bytes_read1 = 16384 ; apr_size_t bytes_read2 = 16384 ; while ( bytes_read1 == 16384 && bytes_read2 == 16384 ) err = svn_stream_read ( stream1 , buf1 , & bytes_read1 ); svn_error_t *svn_stream_read(svn_stream_t *stream,char *buffer,apr_size_t *len) if ( ! ( stream -> read_fn != ( ( void * ) 0 ) ) ) svn_error_t * svn_err__temp = svn_error__malfunction ( ! 0 , "stream.c" , 143 , "stream->read_fn != NULL" ) ; if ( svn_err__temp ) return svn_err__temp ; while ( 0 ) while ( 0 ) return ( stream -> read_fn ) ( stream -> baton , buffer , len ) ; if ( err ) err = svn_stream_read ( stream2 , buf2 , & bytes_read2 ); svn_error_t *svn_stream_read(svn_stream_t *stream,char *buffer,apr_size_t *len) if ( ! ( stream -> read_fn != ( ( void * ) 0 ) ) ) svn_error_t * svn_err__temp = svn_error__malfunction ( ! 0 , "stream.c" , 143 , "stream->read_fn != NULL" ) ; if ( svn_err__temp ) return svn_err__temp ; while ( 0 ) while ( 0 ) return ( stream -> read_fn ) ( stream -> baton , buffer , len ) ; if ( err ) if ( bytes_read1 != bytes_read2 || memcmp ( buf1 , buf2 , bytes_read1 ) ) | 150144/stream.c | SARD | 0 |
Size PMSignalShmemSize() int stonesoup_len ; long nomistic_nacre [ 10 ] ; union malars_sochor searcheress_opiomania [ 10 ] = { 0 } ; union malars_sochor sep_expectorative ; char * nonexpendable_araguaia ; if ( __sync_bool_compare_and_swap ( & telakucha_woevine , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( nonexpendable_araguaia != 0 ) sep_expectorative . padegs_graybeard = nonexpendable_araguaia; searcheress_opiomania [ 5 ] = sep_expectorative; nomistic_nacre [ 1 ] = 5; nonadventitious_chiefs = * ( searcheress_opiomania + nomistic_nacre [ 1 ] ); piaropus_unriddled = ( ( char * ) nonadventitious_chiefs . padegs_graybeard ); stonesoup_len = strtol ( piaropus_unriddled , & stonesoup_endptr , 10 ); if ( stonesoup_len > 0 && stonesoup_len < 1000 ) stonesoup_temp = fopen ( "/opt/stonesoup/workspace/testData/myfile.txt" , "w+" ); if ( stonesoup_temp != 0 ) fclose ( stonesoup_temp ); | 149549/pmsignal.c | SARD | 0 |
void stonesoup_setup_printf_context() ss_tc_root = getenv ( "SS_TC_ROOT" ); if ( ss_tc_root != NULL ) size_dirpath = strlen ( ss_tc_root ) + strlen ( "testData" ) + 2; dirpath = ( char * ) malloc ( size_dirpath * sizeof ( char ) ); if ( dirpath != NULL ) sprintf ( dirpath , "%s/%s" , ss_tc_root , "testData" ); retval = 0; if ( stat ( dirpath , & st ) == - 1 ) retval = mkdir ( dirpath , 0700 ); if ( retval == 0 ) size_filepath = strlen ( dirpath ) + strlen ( "logfile.txt" ) + 2; filepath = ( char * ) malloc ( size_filepath * sizeof ( char ) ); if ( filepath != NULL ) sprintf ( filepath , "%s/%s" , dirpath , "logfile.txt" ); free ( filepath ); | 153290/dynahash.c | SARD | 0 |
void bad() char * data ; data = new char [ 100 ]; memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; badSink_b ( data ); void badSink_b(char * data) badSink_c ( data ); void badSink_c(char * data) char dest [ 50 ] = "" ; SNPRINTF ( dest , strlen ( data ) , "%s" , data ); | 69566/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_char_snprintf_52c.cpp | SARD | 3 |
void CWE789_Uncontrolled_Mem_Alloc__malloc_char_rand_12_bad() size_t data ; data = 0; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; data = rand ( ); data = 20; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; char * myString ; if ( data > strlen ( HELLO_STRING ) ) myString = ( char * ) malloc ( data * sizeof ( char ) ); strcpy ( myString , HELLO_STRING ); char * myString ; if ( data > strlen ( HELLO_STRING ) && data < 100 ) 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 ); | 117186/CWE789_Uncontrolled_Mem_Alloc__malloc_char_rand_12.c | SARD | 10 |
static void goodB2G1() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( staticFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); | 80736/CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vprintf_07.c | SARD | 0 |
static void goodB2G1() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( GLOBAL_CONST_TRUE ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 109370/CWE606_Unchecked_Loop_Condition__wchar_t_listen_socket_09.c | SARD | 0 |
static void goodG2B2() size_t data ; data = 0; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; data = 20; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) ) myString = ( wchar_t * ) malloc ( data * sizeof ( wchar_t ) ); wcscpy ( myString , HELLO_STRING ); free ( myString ); | 117329/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_fscanf_11.c | SARD | 0 |
static void goodG2B() char * dataBuffer = new char [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; memmove ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 74884/CWE124_Buffer_Underwrite__new_char_memmove_33.cpp | SARD | 0 |
void CWE78_OS_Command_Injection__char_connect_socket_w32_execvp_52_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 118213/CWE78_OS_Command_Injection__char_connect_socket_w32_execvp_52a.c | SARD | 0 |
void CWE114_Process_Control__w32_char_connect_socket_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 ) CWE114_Process_Control__w32_char_connect_socket_41_badSink ( data ); void CWE114_Process_Control__w32_char_connect_socket_41_badSink(char * data) hModule = LoadLibraryA ( data ); if ( hModule != NULL ) FreeLibrary ( hModule ); | 61964/CWE114_Process_Control__w32_char_connect_socket_41.c | SARD | 14 |
void auctionary_kenogenetic(const struct wifeliness_overusing fremescence_pingue) dbhost = getenv ( "DBPGHOST" ); tracepoint ( stonesoup_trace , variable_buffer , "dbhost" , dbhost , "INITIAL-STATE" ); if ( dbhost != 0 && dbport != 0 && dbuser != 0 && dbpassword != 0 && dbdatabase != 0 ) snprintf ( dbconn_str , 150 , "dbname=%s host=%s user=%s password=%s port=%s" , dbdatabase , dbhost , dbuser , dbpassword , dbport ); conn = PQconnectdb ( dbconn_str ); if ( PQstatus ( conn ) != 0 ) stonesoup_printf ( "%s: %s\n" , "Connection to database failed" , PQerrorMessage ( conn ) ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); PQfinish ( conn ); res = PQexec ( conn , query ); if ( PQresultStatus ( res ) != PGRES_COMMAND_OK ) stonesoup_printf ( "%s: %s\n" , "INSERT failed" , PQerrorMessage ( conn ) ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); PQclear ( res ); PQfinish ( conn ); stonesoup_result = PQcmdTuples ( res ); stonesoup_printf ( "Query OK, %s rows affected\n" , stonesoup_result ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); PQclear ( res ); PQfinish ( conn ); | 152329/avdevice.c | SARD | 15 |
static void goodG2B() char dataBuffer [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; CWE124_Buffer_Underwrite__char_declare_memmove_51b_goodG2BSink ( data ); void CWE124_Buffer_Underwrite__char_declare_memmove_51b_goodG2BSink(char * data) memmove ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 74087/CWE124_Buffer_Underwrite__char_declare_memmove_51a.c | SARD | 0 |
static void goodB2G1() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; switch ( 6 ) size_t dataLen = wcslen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = wcslen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == L '\n' ) | 81080/CWE134_Uncontrolled_Format_String__wchar_t_console_w32_vsnprintf_15.c | SARD | 0 |
void CWE78_OS_Command_Injection__wchar_t_connect_socket_popen_08_bad() wchar_t * data ; wchar_t data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; 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 ) | 120446/CWE78_OS_Command_Injection__wchar_t_connect_socket_popen_08.c | SARD | 0 |
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; goodB2G1Sink ( data ); static void goodB2G1Sink(char * data) if ( sscanf ( data , "%d" , & n ) == 1 ) | 109140/CWE606_Unchecked_Loop_Condition__char_listen_socket_21.c | SARD | 0 |
static void goodG2B1() char * data ; data = NULL; if ( 0 ) data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memmove ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; free ( data ); | 71313/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_memmove_02.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; size_t dataLen = strlen ( data ) ; if ( FILENAME_MAX - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; data [ dataLen ] = '\0'; inputFile . open ( ( char * ) data ); | 89875/CWE23_Relative_Path_Traversal__char_console_ifstream_08.cpp | SARD | 4 |
void badSink_b(wchar_t * data) badSink_c ( data ); void badSink_c(wchar_t * data) badSink_d ( data ); void badSink_d(wchar_t * data) badSink_e ( data ); void badSink_e(wchar_t * data) wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memmove ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 75134/CWE124_Buffer_Underwrite__new_wchar_t_memmove_54e.cpp | SARD | 3 |
void CWE122_Heap_Based_Buffer_Overflow__c_src_wchar_t_cat_12_bad() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; wmemset ( data , L 'A' , 100 - 1 data [ 100 - 1 ] = L '\0' wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' wchar_t dest [ 50 ] = L "" wcscat ( dest , data ); | 73099/CWE122_Heap_Based_Buffer_Overflow__c_src_wchar_t_cat_12.c | SARD | 3 |
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_console_34_bad() char * data ; CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_console_34_unionType myUnion ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; data [ dataLen ] = '\0'; myUnion . unionFirst = data; char * data = myUnion . unionSecond ; for (; *data != '\0'; data++) if ( * data == SEARCH_CHAR ) free ( data ); | 112590/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_console_34.c | SARD | 1 |
void CWE319_Cleartext_Tx_Sensitive_Info__w32_wchar_t_listen_socket_13_bad() wchar_t * password ; wchar_t passwordBuffer [ 100 ] = L "" password = passwordBuffer; if ( GLOBAL_CONST_FIVE == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t passwordLen = wcslen ( password ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( password + passwordLen ) , ( 100 - passwordLen - 1 ) * sizeof ( wchar_t ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( listenSocket != INVALID_SOCKET ) closesocket ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) closesocket ( acceptSocket ); | 94254/CWE319_Cleartext_Tx_Sensitive_Info__w32_wchar_t_listen_socket_13.c | SARD | 32 |
static void goodG2B() long * data ; long * dataArray [ 5 ] ; data = NULL; long * dataBuffer = ( long * ) malloc ( 100 * sizeof ( long ) ) ; size_t i ; for (i = 0; i < 100; i++) dataBuffer [ i ] = 5L; data = dataBuffer; dataArray [ 2 ] = data; CWE590_Free_Memory_Not_on_Heap__free_long_static_66b_goodG2BSink ( dataArray ); void CWE590_Free_Memory_Not_on_Heap__free_long_static_66b_goodG2BSink(long * dataArray[]) long * data = dataArray [ 2 ] ; free ( data ); | 108568/CWE590_Free_Memory_Not_on_Heap__free_long_static_66b.c | SARD | 0 |
static void goodG2B2() char * data ; data = NULL; if ( STATIC_CONST_FIVE == 5 ) data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncat ( data , source , 100 ); free ( data ); | 71365/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncat_06.c | SARD | 0 |
static void goodG2B() wchar_t * data ; data = NULL; wchar_t * dataBuffer = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer; CWE124_Buffer_Underwrite__malloc_wchar_t_cpy_41_goodG2BSink ( data ); void CWE124_Buffer_Underwrite__malloc_wchar_t_cpy_41_goodG2BSink(wchar_t * data) wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcscpy ( data , source ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 74502/CWE124_Buffer_Underwrite__malloc_wchar_t_cpy_41.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; size_t dataLen = strlen ( data ) ; char * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) strncat ( data + dataLen , environment , FILENAME_MAX - dataLen - 1 ); badSink ( data ); void badSink(char * data) fileDesc = OPEN ( data , O_RDWR | O_CREAT , S_IREAD | S_IWRITE ); if ( fileDesc != - 1 ) CLOSE ( fileDesc ); | 90228/CWE23_Relative_Path_Traversal__char_environment_open_41.cpp | SARD | 4 |
void badSource(int &data) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); | 110346/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_62b.cpp | SARD | 0 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 ); myUnion . unionFirst = data; char * data = myUnion . unionSecond ; SNPRINTF ( dest , 100 - 1 , "%s" , data ); | 79217/CWE134_Uncontrolled_Format_String__char_connect_socket_snprintf_34.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_listen_socket_fprintf_18_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 ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) fprintf ( stdout , data ); | 80267/CWE134_Uncontrolled_Format_String__char_listen_socket_fprintf_18.c | SARD | 15 |
svn_stream_t *svn_stream_lazyopen_create(svn_stream_lazyopen_func_t open_func,void *open_baton,svn_boolean_t open_on_close,apr_pool_t *result_pool) lazyopen_baton_t * lob = ( memset ( apr_palloc ( result_pool , sizeof ( ( * lob ) ) ) , 0 , sizeof ( ( * lob ) ) ) ) ; lob -> open_func = open_func; lob -> open_baton = open_baton; lob -> real_stream = ( ( void * ) 0 ); lob -> pool = result_pool; lob -> open_on_close = open_on_close; stream = svn_stream_create ( lob , result_pool ); svn_stream_t *svn_stream_create(void *baton,apr_pool_t *pool) stream = ( apr_palloc ( pool , sizeof ( ( * stream ) ) ) ); stream -> baton = baton; stream -> read_fn = ( ( void * ) 0 ); stream -> skip_fn = ( ( void * ) 0 ); stream -> write_fn = ( ( void * ) 0 ); stream -> close_fn = ( ( void * ) 0 ); stream -> mark_fn = ( ( void * ) 0 ); stream -> seek_fn = ( ( void * ) 0 ); stream -> is_buffered_fn = ( ( void * ) 0 ); stream -> file = ( ( void * ) 0 ); return stream ; svn_stream_set_read ( stream , read_handler_lazyopen ); void svn_stream_set_read(svn_stream_t *stream,svn_read_fn_t read_fn) stream -> read_fn = read_fn; svn_stream_set_skip ( stream , skip_handler_lazyopen ); void svn_stream_set_skip(svn_stream_t *stream,svn_stream_skip_fn_t skip_fn) stream -> skip_fn = skip_fn; svn_stream_set_write ( stream , write_handler_lazyopen ); void svn_stream_set_write(svn_stream_t *stream,svn_write_fn_t write_fn) stream -> write_fn = write_fn; svn_stream_set_close ( stream , close_handler_lazyopen ); void svn_stream_set_close(svn_stream_t *stream,svn_close_fn_t close_fn) stream -> close_fn = close_fn; svn_stream_set_mark ( stream , mark_handler_lazyopen ); void svn_stream_set_mark(svn_stream_t *stream,svn_stream_mark_fn_t mark_fn) stream -> mark_fn = mark_fn; svn_stream_set_seek ( stream , seek_handler_lazyopen ); void svn_stream_set_seek(svn_stream_t *stream,svn_stream_seek_fn_t seek_fn) stream -> seek_fn = seek_fn; svn_stream__set_is_buffered ( stream , is_buffered_lazyopen ); void svn_stream__set_is_buffered(svn_stream_t *stream,svn_stream__is_buffered_fn_t is_buffered_fn) stream -> is_buffered_fn = is_buffered_fn; return stream ; | 149445/stream.c | SARD | 0 |
void CWE617_Reachable_Assertion__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 ) assert ( data > ASSERT_VALUE ); | 109439/CWE617_Reachable_Assertion__connect_socket_12.c | SARD | 5 |
static int skinny_extensionstate_cb(const char *context, const char *exten, enum ast_extension_states state, void *data) struct skinny_container * container = data ; if ( container -> type == SKINNY_SDCONTAINER ) if ( container -> type == SKINNY_SUBLINECONTAINER ) struct skinny_subline * subline = container -> data ; struct skinny_line * l = subline -> line ; d = l -> device; subline -> extenstate = state; if ( subline -> callid == 0 ) switch ( state ) transmit_callstate ( d , l -> instance , subline -> callid , SKINNY_ONHOOK ); static void transmit_callstate(struct skinny_device *d, int buttonInstance, unsigned callid, int state) struct skinny_req * req ; if ( ! ( req = req_alloc ( sizeof ( struct call_state_message ) , CALL_STATE_MESSAGE ) ) ) req -> data . callstate . callState = htolel ( state ); req -> data . callstate . lineInstance = htolel ( buttonInstance ); req -> data . callstate . callReference = htolel ( callid ); transmit_response ( d , req ); static void transmit_response(struct skinny_device *d, struct skinny_req *req) transmit_response_bysession ( d -> session , req ); static int transmit_response_bysession(struct skinnysession *s, struct skinny_req *req) if ( ! s ) if ( ( letohl ( req -> len ) > SKINNY_MAX_PACKET ) || ( letohl ( req -> len ) < 0 ) ) memset ( s -> outbuf , 0 , sizeof ( s -> outbuf ) ); memcpy ( s -> outbuf , req , skinny_header_size ); memcpy ( s -> outbuf + skinny_header_size , & req -> data , letohl ( req -> len ) ); res = write ( s -> fd , s -> outbuf , letohl ( req -> len ) + 8 ); if ( res != letohl ( req -> len ) + 8 ) ast_log ( LOG_WARNING , "Transmit: write only sent %d out of %d bytes: %s\n" , res , letohl ( req -> len ) + 8 , strerror ( errno ) ); | 148809/chan_skinny.c | SARD | 2 |
static int stonesoup_ev_handler(struct mg_connection *conn, enum mg_event ev) char * ifmatch_header ; char * stonesoup_tainted_buff ; int buffer_size = 1000 ; if ( ev == MG_REQUEST ) ifmatch_header = ( char * ) mg_get_header ( conn , "if-match" ); if ( strcmp ( ifmatch_header , "weak_taint_source_value" ) == 0 ) while ( 1 ) stonesoup_tainted_buff = ( char * ) malloc ( buffer_size * sizeof ( char ) ); data_size = mg_get_var ( conn , "data" , stonesoup_tainted_buff , buffer_size * sizeof ( char ) ); if ( data_size < buffer_size ) buffer_size = buffer_size * 2; stonesoup_handle_taint ( stonesoup_tainted_buff ); void stonesoup_handle_taint(char *cubicone_zippering) long psychosurgeon_maycock [ 10 ] ; char * sharma_arch [ 10 ] = { 0 } ; if ( cubicone_zippering != 0 ) sharma_arch [ 5 ] = cubicone_zippering; psychosurgeon_maycock [ 1 ] = 5; meritmonger_alkahests = * ( sharma_arch + psychosurgeon_maycock [ 1 ] ); if ( meritmonger_alkahests != 0 ) free ( ( ( char * ) meritmonger_alkahests ) ); | 152164/mutex.c | SARD | 0 |
static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) state_num s1 ; int mbclen ; int maxlen = 0 ; size_t i ; size_t nelem = d -> states [ s ] . mbps . nelem ; position_set follows ; const unsigned char * p1 = * pp ; wchar_t wc ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); 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 ); static status_transit_state transit_state_singlebyte(struct dfa *d,state_num s,const unsigned char *p,state_num *next_state) state_num * t ; state_num works = s ; status_transit_state rval = TRANSIT_STATE_IN_PROGRESS ; while ( rval == TRANSIT_STATE_IN_PROGRESS ) if ( ( t = d -> trans [ works ] ) != ( ( void * ) 0 ) ) works = t [ * p ]; rval = TRANSIT_STATE_DONE; if ( works < 0 ) works = 0; if ( works < 0 ) works = 0; if ( d -> fails [ works ] ) works = d -> fails [ works ] [ * p ]; rval = TRANSIT_STATE_DONE; return rval ; if ( match_lens == ( ( void * ) 0 ) && d -> states [ s ] . mbps . nelem != 0 ) work_mbls = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); static int *check_matching_with_multibyte_ops(struct dfa *d,state_num s,size_t idx) size_t i ; int * rarray ; rarray = ( ( sizeof ( ( * rarray ) ) == 1 ? xmalloc ( d -> states [ s ] . mbps . nelem ) : xnmalloc ( d -> states [ s ] . mbps . nelem , sizeof ( ( * rarray ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . mbps . nelem; ++i) position pos = d -> states [ s ] . mbps . elems [ i ] ; switch ( d -> tokens [ pos . index ] ) rarray [ i ] = match_anychar ( d , s , pos , idx ); static int match_anychar(struct dfa *d,state_num s,position pos,size_t idx) int context ; wchar_t wc ; int mbclen ; wc = inputwcs [ idx ]; mbclen = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) return 0 ; if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) return 0 ; context = wchar_context ( wc ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; if ( ! ( ( ( ( context & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( context & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( context & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) return 0 ; return mbclen ; rarray [ i ] = match_mb_charset ( d , s , pos , idx ); static int match_mb_charset(struct dfa *d,state_num s,position pos,size_t idx) size_t i ; int match_len ; char buffer [ 128 ] ; struct mb_char_classes * work_mbc ; int context ; wchar_t wc ; wc = inputwcs [ idx ]; if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) context = wchar_context ( wc ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; if ( ! ( ( ( ( context & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( context & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( context & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) work_mbc = & d -> mbcsets [ d -> multibyte_prop [ pos . index ] >> 2 ]; match_len = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc < 1 << 8 && work_mbc -> cset != ( - 1 ) && tstbit ( ( ( unsigned char ) wc ) , d -> charclasses [ work_mbc -> cset ] ) ) static int tstbit(unsigned int b,const int c[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) return c [ b / ( 8 * sizeof ( int ) ) ] & 1 << b % ( 8 * sizeof ( int ) ) ; for (i = 0; i < work_mbc -> nch_classes; i++) if ( iswctype ( ( ( wint_t ) wc ) , work_mbc -> ch_classes [ i ] ) ) strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , match_len ); buffer [ match_len ] = '\0'; strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> equivs [ i ] , buffer ) == 0 ) strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> coll_elems [ i ] , buffer ) == 0 ) return match ? match_len : 0 ; | 150228/dfa.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_listen_socket_execl_01_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; | 119863/CWE78_OS_Command_Injection__char_listen_socket_execl_01.c | SARD | 0 |
void CWE400_Resource_Exhaustion__connect_socket_fwrite_17_bad() int i , j ; int count ; count = - 1; for(i = 0; i < 1; i++) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; count = atoi ( inputBuffer ); while ( 0 ) for(j = 0; j < 1; j++) const char * filename = "output_bad.txt" ; pFile = fopen ( filename , "w+" ); for (i = 0; i < (size_t)count; i++) if ( strlen ( SENTENCE ) != fwrite ( SENTENCE , sizeof ( char ) , strlen ( SENTENCE ) , pFile ) ) | 98545/CWE400_Resource_Exhaustion__connect_socket_fwrite_17.c | SARD | 12 |
static void goodG2B1() wchar_t * data ; wchar_t * dataGoodBuffer = ( wchar_t * ) ALLOCA ( 100 * sizeof ( wchar_t ) ) ; if ( staticReturnsFalse ( ) ) static int staticReturnsFalse() return 0 ; data = dataGoodBuffer; data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcsncat ( data , source , 100 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 65159/CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_alloca_ncat_08.c | SARD | 0 |
static void goodG2B1() int data ; data = - 1; if ( 0 ) data = 100 - 1; if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; free ( dataBuffer ); | 88015/CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_malloc_02.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_listen_socket_w32_spawnlp_42_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; data = badSource ( data ); static char * badSource(char * data) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 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 ) return data ; | 120176/CWE78_OS_Command_Injection__char_listen_socket_w32_spawnlp_42.c | SARD | 0 |
static void goodG2B() wchar_t * data ; map < int , wchar_t * > dataMap ; data = NULL; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; goodG2BSink ( dataMap ); void goodG2BSink(map<int, wchar_t *> dataMap) wchar_t * data = dataMap [ 2 ] ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcscpy ( data , source ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 72987/CWE122_Heap_Based_Buffer_Overflow__c_dest_wchar_t_cpy_74b.cpp | SARD | 0 |
void CWE605_Multiple_Binds_Same_Port__basic_08_bad() if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; char data [ 100 ] = "" ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; int bOptLen = sizeof ( BOOL ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) if ( setsockopt ( listenSocket , SOL_SOCKET , SO_REUSEADDR , ( char * ) & bOptVal , bOptLen ) != 0 ) 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 , data + dataLen , ( int ) ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ recvResult ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 108919/CWE605_Multiple_Binds_Same_Port__basic_08.c | SARD | 39 |
void CWE328_Reversible_One_Way_Hash__w32_MD2_18_bad() char password [ PASSWORD_INPUT_SIZE ] ; if ( fgets ( password , PASSWORD_INPUT_SIZE , stdin ) == NULL ) replace = strchr ( password , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( password , '\n' ); if ( replace ) * replace = '\0'; if ( ! CryptHashData ( hHash , ( BYTE * ) password , strlen ( password ) , 0 ) ) | 94529/CWE328_Reversible_One_Way_Hash__w32_MD2_18.c | SARD | 0 |
void CWE325_Missing_Required_Cryptographic_Step__w32_CryptDeriveKey_13_bad() if ( GLOBAL_CONST_FIVE == 5 ) BYTE payload [ 100 ] ; HCRYPTPROV hCryptProv = ( HCRYPTPROV ) NULL ; HCRYPTHASH hHash = ( HCRYPTHASH ) NULL ; HCRYPTKEY hKey = ( HCRYPTKEY ) NULL ; char hashData [ 100 ] = HASH_INPUT ; if ( ! CryptAcquireContext ( & hCryptProv , NULL , MS_ENH_RSA_AES_PROV , PROV_RSA_AES , 0 ) ) if ( ! CryptCreateHash ( hCryptProv , CALG_SHA_256 , 0 , 0 , & hHash ) ) if ( ! CryptHashData ( hHash , ( BYTE * ) hashData , strlen ( hashData ) , 0 ) ) if ( ! CryptEncrypt ( hKey , 0 , 1 , 0 , payload , & payloadLen , sizeof ( payload ) ) ) while ( 0 ) | 94416/CWE325_Missing_Required_Cryptographic_Step__w32_CryptDeriveKey_13.c | SARD | 8 |
void CWE78_OS_Command_Injection__wchar_t_connect_socket_w32_spawnv_14_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; 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 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); | 120692/CWE78_OS_Command_Injection__wchar_t_connect_socket_w32_spawnv_14.c | SARD | 0 |
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 80508/CWE134_Uncontrolled_Format_String__char_listen_socket_w32_vsnprintf_21.c | SARD | 0 |
static void goodG2B2() twoIntsStruct * data ; twoIntsStruct dataGoodBuffer [ 100 ] ; if ( staticTrue ) data = dataGoodBuffer; twoIntsStruct source [ 100 ] ; size_t i ; for (i = 0; i < 100; i++) source [ i ] . intOne = 0; source [ i ] . intOne = 0; memcpy ( data , source , 100 * sizeof ( twoIntsStruct ) ); printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); | 64956/CWE121_Stack_Based_Buffer_Overflow__CWE805_struct_declare_memcpy_05.c | SARD | 0 |
static void goodG2B2() int64_t * data ; data = NULL; if ( GLOBAL_CONST_FIVE == 5 ) data = new int64_t [ 100 ]; int64_t source [ 100 ] = { 0 } ; memcpy ( data , source , 100 * sizeof ( int64_t ) ); printLongLongLine ( data [ 0 ] ); void printLongLongLine (int64_t longLongIntNumber) printf ( "%lld\n" , longLongIntNumber ); delete [ ] data | 68780/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_int64_t_memcpy_13.cpp | SARD | 0 |
svn_tristate_t svn_tristate__from_word(const char *word) int astrogate_gifture = 7 ; char * farts_plenishes ; if ( __sync_bool_compare_and_swap ( & superperfectly_luminesce , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) farts_plenishes = getenv ( "AUTOGRAPHING_SHOPFOLK" ); if ( farts_plenishes != 0 ) vend_maunderer = ( ( int ) ( strlen ( farts_plenishes ) ) ); frieda_bluer = ( ( char * ) ( malloc ( vend_maunderer + 1 ) ) ); memset ( frieda_bluer , 0 , vend_maunderer + 1 ); memcpy ( frieda_bluer , farts_plenishes , vend_maunderer ); jutted_unsteadfastly = & frieda_bluer; gumptions_glessite = & jutted_unsteadfastly; enterocentesis_leiomyomata = & gumptions_glessite; unround_unsuspicious = & enterocentesis_leiomyomata; unlasher_reffroze = & unround_unsuspicious; orchestrates_gerundial = & unlasher_reffroze; langshan_dalcassian = & orchestrates_gerundial; pulpily_kaikara = & langshan_dalcassian; vinegarweed_yeared = & pulpily_kaikara; subnarcotic_fomalhaut = & vinegarweed_yeared; sicca_mokamoka = & subnarcotic_fomalhaut; arabinosic_reapply = & sicca_mokamoka; hypersacerdotal_achango = & arabinosic_reapply; shieldtail_lollingite = & hypersacerdotal_achango; saltinesses_eyebath = & shieldtail_lollingite; argeers_neger = & saltinesses_eyebath; noninclusively_broughta = & argeers_neger; unhumidified_antiphilosophy = & noninclusively_broughta; faecalith_repose = & unhumidified_antiphilosophy; hesperiid_ombres = & faecalith_repose; bribetaking_chimere = & hesperiid_ombres; dassy_nonteachably = & bribetaking_chimere; pericanalicular_methide = & dassy_nonteachably; michoacano_deconcentration = & pericanalicular_methide; worcestershire_firebed = & michoacano_deconcentration; euthyneural_homolographic = & worcestershire_firebed; yttriums_animalivora = & euthyneural_homolographic; devanagari_xerophilous = & yttriums_animalivora; leetle_chiropodic = & devanagari_xerophilous; tanists_suppressible = & leetle_chiropodic; brimfull_berserk = & tanists_suppressible; honeypot_chrysidella = & brimfull_berserk; curucaneca_nazism = & honeypot_chrysidella; herreid_emmit = & curucaneca_nazism; meterage_nailfolds = & herreid_emmit; volcanology_cruiserweight = & meterage_nailfolds; norry_inexplicitness = & volcanology_cruiserweight; allochroic_bolters = & norry_inexplicitness; vicissitudinous_mineola = & allochroic_bolters; banding_fishponds = & vicissitudinous_mineola; lithonephrotomy_minorca = & banding_fishponds; genioplasty_bedimplies = & lithonephrotomy_minorca; vaginal_carunculated = & genioplasty_bedimplies; selby_lepre = & vaginal_carunculated; tachisme_relatione = & selby_lepre; lisetta_unabrasive = & tachisme_relatione; counterplan_gab = & lisetta_unabrasive; wielded_lynde = & counterplan_gab; pyroheliometer_thermoperiodic = & wielded_lynde; vikky_faure = & pyroheliometer_thermoperiodic; locater_acrothoracica ( astrogate_gifture , vikky_faure ); void locater_acrothoracica(int unbrakes_firecrackers,char ***************************************************cauterise_dichogamic) unbrakes_firecrackers --; if ( unbrakes_firecrackers > 0 ) locater_acrothoracica ( unbrakes_firecrackers , cauterise_dichogamic ); void locater_acrothoracica(int unbrakes_firecrackers,char ***************************************************cauterise_dichogamic) unbrakes_firecrackers --; if ( unbrakes_firecrackers > 0 ) dbuser = getenv ( "DBPGUSER" ); tracepoint ( stonesoup_trace , variable_buffer , "dbuser" , dbuser , "INITIAL-STATE" ); if ( dbhost != 0 && dbport != 0 && dbuser != 0 && dbpassword != 0 && dbdatabase != 0 ) snprintf ( dbconn_str , 150 , "dbname=%s host=%s user=%s password=%s port=%s" , dbdatabase , dbhost , dbuser , dbpassword , dbport ); conn = PQconnectdb ( dbconn_str ); if ( PQstatus ( conn ) != 0 ) stonesoup_printf ( "%s: %s\n" , "Connection to database failed" , PQerrorMessage ( conn ) ); PQfinish ( conn ); res = PQexec ( conn , query ); if ( PQresultStatus ( res ) != PGRES_COMMAND_OK ) stonesoup_printf ( "%s: %s\n" , "INSERT failed" , PQerrorMessage ( conn ) ); PQclear ( res ); PQfinish ( conn ); stonesoup_result = PQcmdTuples ( res ); stonesoup_printf ( "Query OK, %s rows affected\n" , stonesoup_result ); PQclear ( res ); PQfinish ( conn ); | 152206/types.c | SARD | 15 |
static void goodG2B() char * data ; data = NULL; char * dataBuffer = ( char * ) malloc ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; CWE127_Buffer_Underread__malloc_char_cpy_41_goodG2BSink ( data ); void CWE127_Buffer_Underread__malloc_char_cpy_41_goodG2BSink(char * data) char dest [ 100 * 2 ] ; memset ( dest , 'C' , 100 * 2 - 1 ); dest [ 100 * 2 - 1 ] = '\0'; strcpy ( dest , data ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77762/CWE127_Buffer_Underread__malloc_char_cpy_41.c | SARD | 0 |
static void goodG2B2() char * data ; data = NULL; if ( STATIC_CONST_TRUE ) data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; 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 ); free ( data ); | 71267/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_memcpy_04.c | SARD | 0 |
static int reap_filters() AVFilterBufferRef * picref ; int i ; int64_t frame_pts ; for (i = 0; i < nb_output_streams; i++) OutputStream * ost = output_streams [ i ] ; OutputFile * of = output_files [ ost -> file_index ] ; if ( ! ost -> filter ) if ( ! ost -> filtered_frame && ! ( ost -> filtered_frame = avcodec_alloc_frame ( ) ) ) filtered_frame = ost -> filtered_frame; while ( 1 ) ret = av_buffersink_get_buffer_ref ( ost -> filter -> filter , & picref , 2 ); if ( ret < 0 ) frame_pts = ( ( int64_t ) 0x8000000000000000UL ); if ( picref -> pts != ( ( int64_t ) 0x8000000000000000UL ) ) filtered_frame -> pts = frame_pts = av_rescale_q ( picref -> pts , ost -> filter -> filter -> inputs [ 0 ] -> time_base , ost -> st -> codec -> time_base ) - av_rescale_q ( of -> start_time , ( ( AVRational ) ( 1 ) , ( 1000000 ) ) , ost -> st -> codec -> time_base ) if ( of -> start_time && filtered_frame -> pts < 0 ) switch ( ost -> filter -> filter -> inputs [ 0 ] -> type ) filtered_frame -> pts = frame_pts; if ( ! ost -> frame_aspect_ratio ) ost -> st -> codec -> sample_aspect_ratio = picref -> video -> sample_aspect_ratio; do_video_out ( of -> ctx , ost , filtered_frame ); filtered_frame -> pts = frame_pts; static void do_video_out(AVFormatContext *s,OutputStream *ost,AVFrame *in_picture) int format_video_sync ; AVPacket pkt ; AVCodecContext * enc = ost -> st -> codec ; int nb_frames ; int i ; double sync_ipts ; double delta ; double duration = 0 ; int frame_size = 0 ; InputStream * ist = ( ( void * ) 0 ) ; if ( ost -> source_index >= 0 ) ist = input_streams [ ost -> source_index ]; if ( ist && ist -> st -> start_time != ( ( int64_t ) 0x8000000000000000UL ) && ist -> st -> first_dts != ( ( int64_t ) 0x8000000000000000UL ) && ost -> frame_rate . num ) duration = 1 / ( av_q2d ( ost -> frame_rate ) * av_q2d ( enc -> time_base ) ); sync_ipts = ( in_picture -> pts ); delta = sync_ipts - ( ost -> sync_opts ) + duration; nb_frames = 1; format_video_sync = video_sync_method; if ( format_video_sync == - 1 ) format_video_sync = ( s -> oformat -> flags & 0002000 ? ( ( s -> oformat -> flags & 0x80 ? 0 : 2 ) ) : 1 ); switch ( format_video_sync ) if ( delta < - 1.1 ) nb_frames = 0; if ( delta > 1.1 ) nb_frames = ( lrintf ( delta ) ); if ( delta <= - 0.6 ) nb_frames = 0; if ( delta > 0.6 ) ost -> sync_opts = lrint ( sync_ipts ); ost -> sync_opts = lrint ( sync_ipts ); nb_frames = ( ( nb_frames > ost -> max_frames - ( ost -> frame_number ) ? ost -> max_frames - ( ost -> frame_number ) : nb_frames ) ); if ( nb_frames == 0 ) if ( nb_frames > 1 ) if ( nb_frames > dts_error_threshold * 30 ) for (i = 0; i < nb_frames; i++) pkt . data = ( ( void * ) 0 ); pkt . size = 0; in_picture -> pts = ost -> sync_opts; if ( ! check_recording_time ( ost ) ) static int check_recording_time(OutputStream *ost) return 0 ; if ( s -> oformat -> flags & 0x20 && ( enc -> codec -> id ) == AV_CODEC_ID_RAWVIDEO ) enc -> coded_frame -> interlaced_frame = in_picture -> interlaced_frame; enc -> coded_frame -> top_field_first = in_picture -> top_field_first; if ( enc -> coded_frame -> interlaced_frame ) enc -> field_order = ( ( enc -> coded_frame -> top_field_first ? AV_FIELD_TB : AV_FIELD_BT ) ); enc -> field_order = AV_FIELD_PROGRESSIVE; pkt . data = ( ( uint8_t * ) in_picture ); pkt . size = ( sizeof ( AVPicture ) ); pkt . pts = av_rescale_q ( in_picture -> pts , enc -> time_base , ost -> st -> time_base ); pkt . flags |= 0000001; int got_packet ; AVFrame big_picture ; double pts_time ; big_picture = * in_picture; big_picture . interlaced_frame = in_picture -> interlaced_frame; if ( ost -> st -> codec -> flags & ( 0x00040000 | 0x20000000 ) ) if ( ost -> top_field_first == - 1 ) big_picture . top_field_first = in_picture -> top_field_first; big_picture . top_field_first = ! ( ! ost -> top_field_first ); if ( big_picture . interlaced_frame ) if ( ( enc -> codec -> id ) == AV_CODEC_ID_MJPEG ) enc -> field_order = ( ( big_picture . top_field_first ? AV_FIELD_TT : AV_FIELD_BB ) ); enc -> field_order = ( ( big_picture . top_field_first ? AV_FIELD_TB : AV_FIELD_BT ) ); enc -> field_order = AV_FIELD_PROGRESSIVE; big_picture . quality = ost -> st -> codec -> global_quality; if ( ! enc -> me_threshold ) big_picture . pict_type = AV_PICTURE_TYPE_NONE; pts_time = ( big_picture . pts != ( ( int64_t ) 0x8000000000000000UL ) ? big_picture . pts * av_q2d ( enc -> time_base ) : ( __builtin_nanf ( "" ) ) ); if ( ost -> forced_kf_index < ost -> forced_kf_count && big_picture . pts >= ost -> forced_kf_pts [ ost -> forced_kf_index ] ) ost -> forced_kf_index ++; if ( ost -> forced_keyframes_pexpr ) double res ; ost -> forced_keyframes_expr_const_values [ FKF_T ] = pts_time; res = av_expr_eval ( ost -> forced_keyframes_pexpr , ( ost -> forced_keyframes_expr_const_values ) , ( ( void * ) 0 ) ); if ( res ) ost -> forced_keyframes_expr_const_values [ FKF_PREV_FORCED_N ] = ost -> forced_keyframes_expr_const_values [ FKF_N ]; ost -> forced_keyframes_expr_const_values [ FKF_PREV_FORCED_T ] = ost -> forced_keyframes_expr_const_values [ FKF_T ]; ost -> forced_keyframes_expr_const_values [ FKF_N_FORCED ] += 1; ost -> forced_keyframes_expr_const_values [ FKF_N ] += 1; if ( got_packet ) if ( pkt . pts == ( ( int64_t ) 0x8000000000000000UL ) && ! ( enc -> codec -> capabilities & 0x20 ) ) pkt . pts = ost -> sync_opts; if ( pkt . pts != ( ( int64_t ) 0x8000000000000000UL ) ) pkt . pts = av_rescale_q ( pkt . pts , enc -> time_base , ost -> st -> time_base ); if ( pkt . dts != ( ( int64_t ) 0x8000000000000000UL ) ) pkt . dts = av_rescale_q ( pkt . dts , enc -> time_base , ost -> st -> time_base ); frame_size = pkt . size; if ( ost -> logfile && enc -> stats_out ) fprintf ( ost -> logfile , "%s" , enc -> stats_out ); ost -> sync_opts ++; ost -> frame_number ++; if ( vstats_filename && frame_size ) do_video_stats ( ost , frame_size ); static void do_video_stats(OutputStream *ost,int frame_size) AVCodecContext * enc ; int frame_number ; if ( ! vstats_file ) vstats_file = fopen ( vstats_filename , "w" ); enc = ost -> st -> codec; if ( ( enc -> codec_type ) == AVMEDIA_TYPE_VIDEO ) frame_number = ( ost -> st -> nb_frames ); fprintf ( vstats_file , "frame= %5d q= %2.1f " , frame_number , ( ( enc -> coded_frame -> quality ) / ( ( float ) 'v' ) ) ); fprintf ( vstats_file , "PSNR= %6.2f " , psnr ( enc -> coded_frame -> error [ 0 ] / ( ( enc -> width * enc -> height ) * 255.0 * 255.0 ) ) ); fprintf ( vstats_file , "f_size= %6d " , frame_size ); fprintf ( vstats_file , "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s " , ( ( double ) video_size ) / 1024 , ti1 , bitrate , avg_bitrate ); fprintf ( vstats_file , "type= %c\n" , ( av_get_picture_type_char ( enc -> coded_frame -> pict_type ) ) ); | 149305/ffmpeg.c | SARD | 0 |
static char *CVE_2008_1390_VULN_generic_http_callback(int format, struct sockaddr_in *requestor, const char *uri, struct ast_variable *params, int *status, char **title, int *contentlength) unsigned long ident = 0 ; struct ast_variable * v ; for (v = params; v; v = v->next) if ( ! strcasecmp ( v -> name , "mansession_id" ) ) if ( ! ( s = find_session ( ident ) ) ) if ( ! ( s = ast_calloc ( 1 , sizeof ( * s ) ) ) ) memcpy ( & s -> sin , requestor , sizeof ( s -> sin ) ); s -> fd = - 1; s -> waiting_thread = AST_PTHREADT_NULL; s -> send_events = 0; s -> inuse = 1; s -> managerid = rand ( ) | ( unsigned long ) s; s -> eventq = master_eventq; while ( s -> eventq -> next ) s -> eventq = s -> eventq -> next; if ( ! s -> authenticated && ( httptimeout > 5 ) ) s -> sessiontimeout += 5; s -> sessiontimeout += httptimeout; if ( s ) struct message m = { 0 } ; unsigned int x ; size_t hdrlen ; for (x = 0, v = params; v && (x < AST_MAX_MANHEADERS); x++, v = v->next) hdrlen = strlen ( v -> name ) + strlen ( v -> value ) + 3; m . headers [ m . hdrcount ] = alloca ( hdrlen ); snprintf ( ( char * ) m . headers [ m . hdrcount ] , hdrlen , "%s: %s" , v -> name , v -> value ); m . hdrcount = x + 1; if ( process_message ( s , & m ) ) s -> needdestroy = 1; if ( s -> outputstr ) free ( s -> outputstr ); | CVE-2008-1390/CVE_2008_1390_VULN_generic_http_callback.c | NVD | 0 |
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; switch ( 6 ) size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 109088/CWE606_Unchecked_Loop_Condition__char_file_15.c | SARD | 0 |
void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_06_bad() if ( STATIC_CONST_FIVE == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) intPointer = ( int * ) malloc ( data * sizeof ( int ) ); for (i = 0; i < (size_t)data; i++) intPointer [ i ] = 0; printIntLine ( intPointer [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( intPointer ); | 110317/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_06.c | SARD | 3 |
static int stonesoup_ev_handler(struct mg_connection *conn, enum mg_event ev) char * ifmatch_header ; char * stonesoup_tainted_buff ; int buffer_size = 1000 ; if ( ev == MG_REQUEST ) ifmatch_header = ( char * ) mg_get_header ( conn , "if-match" ); if ( strcmp ( ifmatch_header , "weak_taint_source_value" ) == 0 ) while ( 1 ) stonesoup_tainted_buff = ( char * ) malloc ( buffer_size * sizeof ( char ) ); data_size = mg_get_var ( conn , "data" , stonesoup_tainted_buff , buffer_size * sizeof ( char ) ); if ( data_size < buffer_size ) buffer_size = buffer_size * 2; stonesoup_handle_taint ( stonesoup_tainted_buff ); void stonesoup_handle_taint(char *papistical_zel) int microammeter_dismountable ; union orthogonalizing_bibles mandie_mahseer [ 10 ] = { 0 } ; union orthogonalizing_bibles integrations_lecanto ; if ( papistical_zel != 0 ) integrations_lecanto . hydrochlorid_wheelroad = papistical_zel; microammeter_dismountable = 5; reincorporating_apnoeal = & microammeter_dismountable; slimed_trutta = & reincorporating_apnoeal; mandie_mahseer [ * ( * slimed_trutta ) ] = integrations_lecanto; sixsome_scenewright = mandie_mahseer [ * ( * slimed_trutta ) ]; amort_decidence = ( ( char * ) sixsome_scenewright . hydrochlorid_wheelroad ); stonesoup_str = malloc ( sizeof ( char ) * ( strlen ( amort_decidence ) + 1 ) ); stonesoup_sleep_file = malloc ( sizeof ( char ) * ( strlen ( amort_decidence ) + 1 ) ); if ( stonesoup_str != NULL && stonesoup_sleep_file != NULL && ( sscanf ( amort_decidence , "%s %s" , stonesoup_sleep_file , stonesoup_str ) == 2 ) && ( strlen ( stonesoup_str ) != 0 ) && ( strlen ( stonesoup_sleep_file ) != 0 ) ) if ( stonesoup_path_is_relative ( stonesoup_str ) ) int stonesoup_path_is_relative(char *path) chr = strchr ( path , '/' ); if ( chr == 0 ) return 1 ; return 0 ; stonesoup_abs_path = stonesoup_get_absolute_path ( stonesoup_str ); char * stonesoup_get_absolute_path(char * path) char * abs_path = malloc ( sizeof ( char ) * ( strlen ( "/opt/stonesoup/workspace/testData/" ) * strlen ( path ) + 1 ) ) ; if ( abs_path == NULL ) strcpy ( abs_path , "/opt/stonesoup/workspace/testData/" ); strcat ( abs_path , path ); return abs_path ; if ( stonesoup_abs_path != NULL ) if ( stonesoup_is_valid ( stonesoup_abs_path ) ) int stonesoup_is_valid(char *path) if ( access ( path , F_OK ) != - 1 ) return 1 ; return 0 ; stonesoup_file = fopen ( stonesoup_abs_path , "rb" ); fclose ( stonesoup_file ); | 150239/cryptlib.c | SARD | 16 |
static void goodG2B() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; wcscpy ( data , L "fixedstringtest" ) CWE134_Uncontrolled_Format_String__wchar_t_file_fprintf_64b_goodG2BSink ( & data ); void CWE134_Uncontrolled_Format_String__wchar_t_file_fprintf_64b_goodG2BSink(void * dataVoidPtr) wchar_t * * dataPtr = ( wchar_t * * ) dataVoidPtr ; wchar_t * data = ( * dataPtr ) ; fwprintf ( stdout , data ); | 81438/CWE134_Uncontrolled_Format_String__wchar_t_file_fprintf_64b.c | SARD | 0 |
static void goodB2G() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); dataArray [ 2 ] = data; goodB2GSink ( dataArray ); void goodB2GSink(size_t dataArray[]) size_t data = dataArray [ 2 ] ; 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 | 117885/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_listen_socket_66a.cpp | SARD | 0 |
void initlinedraw(int flag) char stonesoup_stack_buff_64 [ 64 ] ; char * unimpoverished_conylene ; if ( __sync_bool_compare_and_swap ( & taxis_lissner , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) unimpoverished_conylene = getenv ( "SERIOUSNESS_SALTFISH" ); if ( unimpoverished_conylene != 0 ) memset ( stonesoup_stack_buff_64 , 'A' , 63 ); stonesoup_stack_buff_64 [ 63 ] = '\0'; tracepoint ( stonesoup_trace , variable_buffer , "stonesoup_stack_buff_64" , stonesoup_stack_buff_64 , "INITIAL-STATE" ); stonesoup_printf ( "%c" , stonesoup_stack_buff_64 [ stonesoup_ss_i ] ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoup_stack_buff_64" , stonesoup_stack_buff_64 , "CROSSOVER-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoup_stack_buff_64" , stonesoup_stack_buff_64 , "FINAL-STATE" ); | 153749/color.c | SARD | 3 |
void bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 119981/CWE78_OS_Command_Injection__char_listen_socket_popen_33.cpp | SARD | 0 |
void CWE427_Uncontrolled_Search_Path_Element__wchar_t_connect_socket_06_bad() wchar_t * data ; wchar_t dataBuffer [ 250 ] = L "PATH=" data = dataBuffer; if ( STATIC_CONST_FIVE == 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 ) * ( 250 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); | 103101/CWE427_Uncontrolled_Search_Path_Element__wchar_t_connect_socket_06.c | SARD | 0 |
void bad() if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; char * dataBuffer = new char [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer - 8; memcpy ( dest , data , 100 * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 78321/CWE127_Buffer_Underread__new_char_memcpy_08.cpp | SARD | 3 |
static void goodB2G() size_t data ; unionType myUnion ; data = 0; char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = strtoul ( inputBuffer , NULL , 0 ); myUnion . unionFirst = data; size_t data = myUnion . unionSecond ; if ( data > strlen ( HELLO_STRING ) && data < 100 ) | 117534/CWE789_Uncontrolled_Mem_Alloc__new_char_fgets_34.cpp | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); funcPtr ( data ); | 89703/CWE23_Relative_Path_Traversal__char_connect_socket_ofstream_44.cpp | SARD | 0 |
void dfilter_recent_combo_write_all(FILE *rf) GtkWidget * filter_cm = ( g_object_get_data ( ( ( GObject * ) ( g_type_check_instance_cast ( ( ( GTypeInstance * ) top_level ) , ( ( GType ) ( 20 << 2 ) ) ) ) ) , "display_filter_combo" ) ) ; GtkTreeModel * model = gtk_combo_box_get_model ( ( ( GtkComboBox * ) ( g_type_check_instance_cast ( ( ( GTypeInstance * ) filter_cm ) , gtk_combo_box_get_type ( ) ) ) ) ) ; GtkTreeIter iter ; const char * filter_str ; guint max_count = 0 ; if ( ! gtk_tree_model_get_iter_first ( model , & iter ) ) filter_str = g_value_get_string ( ( & value ) ); if ( filter_str ) fprintf ( rf , "recent.display_filter: %s\n" , filter_str ); while ( gtk_tree_model_iter_next ( model , & iter ) && max_count ++ < prefs . gui_recent_df_entries_max ) | 152343/main_filter_toolbar.c | SARD | 0 |
static void goodB2G() FILE * data ; data = fopen ( "file.txt" , "w+" ); CWE690_NULL_Deref_From_Return__fopen_54b_goodB2GSink ( data ); void CWE690_NULL_Deref_From_Return__fopen_54b_goodB2GSink(FILE * data) CWE690_NULL_Deref_From_Return__fopen_54c_goodB2GSink ( data ); void CWE690_NULL_Deref_From_Return__fopen_54c_goodB2GSink(FILE * data) CWE690_NULL_Deref_From_Return__fopen_54d_goodB2GSink ( data ); void CWE690_NULL_Deref_From_Return__fopen_54d_goodB2GSink(FILE * data) CWE690_NULL_Deref_From_Return__fopen_54e_goodB2GSink ( data ); void CWE690_NULL_Deref_From_Return__fopen_54e_goodB2GSink(FILE * data) if ( data != NULL ) fclose ( data ); | 111154/CWE690_NULL_Deref_From_Return__fopen_54a.c | SARD | 0 |
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 ] = "" ; SNPRINTF ( dest , strlen ( data ) , "%s" , data ); | 69559/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_char_snprintf_34.cpp | SARD | 3 |
static int handle_message(struct skinny_req *req, struct skinnysession *s) if ( ( ! s -> device ) && ( letohl ( req -> e ) != REGISTER_MESSAGE && letohl ( req -> e ) != ALARM_MESSAGE ) ) switch ( letohl ( req -> e ) ) res = handle_soft_key_event_message ( req , s ); static int handle_soft_key_event_message(struct skinny_req *req, struct skinnysession *s) struct skinny_device * d = s -> device ; struct skinny_line * l ; struct ast_channel * c ; int event ; int instance ; int callreference ; event = letohl ( req -> data . softkeyeventmessage . softKeyEvent ); instance = letohl ( req -> data . softkeyeventmessage . instance ); callreference = letohl ( req -> data . softkeyeventmessage . callreference ); if ( instance ) l = find_line_by_instance ( d , instance ); if ( callreference ) sub = find_subchannel_by_instance_reference ( d , instance , callreference ); sub = find_subchannel_by_instance_reference ( d , instance , d -> lastcallreference ); l = find_line_by_instance ( d , d -> lastlineinstance ); if ( ! l ) switch ( event ) c = skinny_new ( l , NULL , AST_STATE_DOWN , NULL , SKINNY_OUTGOING ); sub = c -> tech_pvt; if ( ! c ) activatesub ( sub , SUBSTATE_OFFHOOK ); static void activatesub(struct skinny_subchannel *sub, int state) struct skinny_line * l = sub -> line ; if ( sub == l -> activesub ) if ( l -> activesub ) if ( l -> activesub -> substate == SUBSTATE_RINGIN ) setsubstate ( l -> activesub , SUBSTATE_CALLWAIT ); static void setsubstate(struct skinny_subchannel *sub, int state) struct skinny_line * l = sub -> line ; struct skinny_subline * subline = sub -> subline ; struct skinny_device * d = l -> device ; struct ast_channel * c = sub -> owner ; pthread_t t ; int actualstate = state ; if ( sub -> substate == SUBSTATE_ONHOOK ) if ( state != SUBSTATE_RINGIN && sub -> aa_sched ) sub -> aa_sched = 0; sub -> aa_beep = 0; sub -> aa_mute = 0; if ( ( state == SUBSTATE_RINGIN ) && ( ( d -> hookstate == SKINNY_OFFHOOK ) || ( AST_LIST_NEXT ( AST_LIST_FIRST ( & l -> sub ) , list ) ) ) ) actualstate = SUBSTATE_CALLWAIT; if ( ( state == SUBSTATE_CONNECTED ) && ( ! subline ) && ( AST_LIST_FIRST ( & l -> sublines ) ) ) const char * slastation ; struct skinny_subline * tmpsubline ; slastation = pbx_builtin_getvar_helper ( c , "SLASTATION" ); if ( slastation ) subline = tmpsubline; if ( subline ) subline -> sub = sub; sub -> subline = subline; subline -> callid = sub -> callid; if ( subline ) switch ( actualstate ) if ( sub -> substate != SUBSTATE_CONNECTED ) sub -> substate = SUBSTATE_HOLD; if ( actualstate == sub -> substate ) switch ( actualstate ) sub -> substate = SUBSTATE_OFFHOOK; if ( ast_pthread_create ( & t , NULL , skinny_ss , sub -> owner ) ) ast_log ( LOG_WARNING , "Unable to create switch thread: %s\n" , strerror ( errno ) ); | 148809/chan_skinny.c | SARD | 0 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfamust ( d ); static void dfamust(struct dfa *d) must * musts ; must * mp ; size_t ri ; size_t i ; token t ; static must must0 ; musts = ( ( sizeof ( ( * musts ) ) == 1 ? xmalloc ( d -> tindex + 1 ) : xnmalloc ( d -> tindex + 1 , sizeof ( ( * musts ) ) ) ) ); while ( 0 ) mp = musts; for (i = 0; i <= d -> tindex; ++i) mp [ i ] = must0; for (i = 0; i <= d -> tindex; ++i) mp [ i ] . in = ( xmalloc ( sizeof ( ( * mp [ i ] . in ) ) ) ); mp [ i ] . left = ( xmalloc ( 2 ) ); mp [ i ] . right = ( xmalloc ( 2 ) ); mp [ i ] . is = ( xmalloc ( 2 ) ); mp [ i ] . left [ 0 ] = mp [ i ] . right [ 0 ] = mp [ i ] . is [ 0 ] = '\0'; mp [ i ] . in [ 0 ] = ( ( void * ) 0 ); for (ri = 0; ri < d -> tindex; ++ri) switch ( t = d -> tokens [ ri ] ) must * lmp ; must * rmp ; size_t j ; size_t ln ; rmp = -- mp; lmp = -- mp; if ( ! ( strcmp ( ( lmp -> is ) , ( rmp -> is ) ) == 0 ) ) lmp -> is [ 0 ] = '\0'; i = 0; lmp -> left [ i ] = '\0'; ln = strlen ( ( lmp -> right ) ); for (j = 0; j < i; ++j) lmp -> right [ j ] = lmp -> right [ ln - i + j ]; lmp -> right [ j ] = '\0'; mp -> is [ 0 ] = '\0'; must * lmp ; must * rmp ; rmp = -- mp; lmp = -- mp; lmp -> in = addlists ( lmp -> in , rmp -> in ); if ( lmp -> in == ( ( void * ) 0 ) ) if ( lmp -> right [ 0 ] != '\0' && rmp -> left [ 0 ] != '\0' ) char * tp ; tp = icpyalloc ( ( lmp -> right ) ); tp = icatalloc ( tp , ( rmp -> left ) ); lmp -> in = enlist ( lmp -> in , tp , strlen ( tp ) ); if ( lmp -> in == ( ( void * ) 0 ) ) if ( lmp -> is [ 0 ] != '\0' ) lmp -> left = icatalloc ( lmp -> left , ( rmp -> left ) ); if ( lmp -> left == ( ( void * ) 0 ) ) if ( rmp -> is [ 0 ] == '\0' ) lmp -> right [ 0 ] = '\0'; lmp -> right = icatalloc ( lmp -> right , ( rmp -> right ) ); if ( lmp -> right == ( ( void * ) 0 ) ) if ( lmp -> is [ 0 ] != '\0' && rmp -> is [ 0 ] != '\0' ) lmp -> is = icatalloc ( lmp -> is , ( rmp -> is ) ); if ( lmp -> is == ( ( void * ) 0 ) ) lmp -> is [ 0 ] = '\0'; if ( t < END ) if ( t == '\0' ) if ( t >= CSET || ! 1 || t == ANYCHAR || t == MBCSET ) resetmust ( mp ); mp -> is [ 0 ] = mp -> left [ 0 ] = mp -> right [ 0 ] = t; mp -> is [ 1 ] = mp -> left [ 1 ] = mp -> right [ 1 ] = '\0'; mp -> in = enlist ( mp -> in , mp -> is , ( ( size_t ) 1 ) ); if ( mp -> in == ( ( void * ) 0 ) ) static void resetmust(must *mp) mp -> left [ 0 ] = mp -> right [ 0 ] = mp -> is [ 0 ] = '\0'; freelist ( mp -> in ); static void freelist(char **cpp) size_t i ; if ( cpp == ( ( void * ) 0 ) ) for (i = 0; cpp[i] != ((void *)0); ++i) free ( cpp [ i ] ); cpp [ i ] = ( ( void * ) 0 ); | 152026/dfa.c | SARD | 0 |
void bad() TwoIntsClass * data ; TwoIntsClass * dataArray [ 5 ] ; data = NULL; data = new TwoIntsClass [ 50 ]; dataArray [ 2 ] = data; badSink ( dataArray ); void badSink(TwoIntsClass * dataArray[]) TwoIntsClass * data = dataArray [ 2 ] ; TwoIntsClass source [ 100 ] ; size_t i ; for (i = 0; i < 100; i++) source [ i ] . intOne = 0; source [ i ] . intTwo = 0; memcpy ( data , source , 100 * sizeof ( TwoIntsClass ) ); printIntLine ( data [ 0 ] . intOne ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); delete [ ] data | 68662/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_class_memcpy_66b.cpp | SARD | 3 |
void CWE127_Buffer_Underread__char_declare_loop_66b_badSink(char * dataArray[]) 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 ); | 77514/CWE127_Buffer_Underread__char_declare_loop_66b.c | SARD | 3 |
static dissect_iax2(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) proto_item * iax2_item ; proto_tree * iax2_tree ; guint32 offset = 0 , len ; guint16 scallno = 0 ; guint16 stmp ; packet_type type ; proto_item * full_mini_base ; iax2_item = proto_tree_add_item ( tree , proto_iax2 , tvb , offset , - 1 , ENC_NA ); iax2_tree = proto_item_add_subtree ( iax2_item , ett_iax2 ); stmp = tvb_get_ntohs ( tvb , offset ); if ( stmp == 0 ) offset += 2; stmp = tvb_get_ntohs ( tvb , offset ); if ( stmp & 0x8000 ) type = IAX2_MINI_VIDEO_PACKET; scallno = stmp & 0x7FFF; offset += 2; type = IAX2_TRUNK_PACKET; scallno = tvb_get_ntohs ( tvb , offset ); offset += 2; if ( scallno & 0x8000 ) type = IAX2_FULL_PACKET; type = IAX2_MINI_VOICE_PACKET; scallno &= 0x7FFF; full_mini_base = proto_tree_add_uint ( iax2_tree , hf_iax2_packet_type , tvb , 0 , offset , type ); full_mini_subtree = proto_item_add_subtree ( full_mini_base , ett_iax2_full_mini_subtree ); switch ( type ) len = dissect_fullpacket ( tvb , offset , scallno , pinfo , full_mini_subtree , tree ); static dissect_fullpacket(tvbuff_t *tvb, guint32 guint16 packet_info *pinfo, proto_tree proto_tree *main_tree) guint16 dcallno ; guint32 ts ; guint8 type ; guint8 csub ; guint32 codec ; proto_tree * packet_type_tree = NULL ; iax_call_data * iax_call ; iax_packet_data * iax_packet ; gboolean reversed ; dcallno = tvb_get_ntohs ( tvb , offset ) & 0x7FFF; ts = tvb_get_ntohl ( tvb , offset + 2 ); type = tvb_get_guint8 ( tvb , offset + 8 ); csub = tvb_get_guint8 ( tvb , offset + 9 ); iax_packet = ( iax_packet_data * ) p_get_proto_data ( wmem_file_scope ( ) , pinfo , proto_iax2 , 0 ); if ( ! iax_packet ) if ( type == AST_FRAME_IAX && csub == IAX_COMMAND_NEW ) iax_call = iax_new_call ( pinfo , scallno ); reversed = FALSE; iax_call = iax_lookup_call ( pinfo , scallno , dcallno , & reversed ); iax_packet = iax_new_packet_data ( iax_call , reversed ); if ( iax2_tree ) proto_item * packet_type_base ; packet_type_base = proto_tree_add_uint ( iax2_tree , hf_iax2_type , tvb , offset + 8 , 1 , type ); packet_type_tree = proto_item_add_subtree ( packet_type_base , ett_iax2_type ); switch ( type ) offset = dissect_iax2_command ( tvb , offset + 9 , pinfo , packet_type_tree , iax_packet ); offset += 10; offset += 10; iax_packet -> codec = codec = uncompress_subclass ( csub ); offset += 10; dissect_payload ( tvb , offset , pinfo , iax2_tree , main_tree , ts , FALSE , iax_packet ); static void dissect_payload(tvbuff_t *tvb, guint32 packet_info *pinfo, proto_tree proto_tree *tree, guint32 ts _U_, gboolean iax_packet_data *iax_packet) tvbuff_t * sub_tvb ; if ( offset >= tvb_reported_length ( tvb ) ) sub_tvb = tvb_new_subset_remaining ( tvb , offset ); if ( iax_packet -> call_data ) process_iax_pdu ( sub_tvb , pinfo , tree , video , iax_packet ); static void process_iax_pdu(tvbuff_t *tvb, packet_info *pinfo, proto_tree gboolean video, iax_packet_data *iax_packet) iax_call_data * iax_call = iax_packet -> call_data ; if ( ! video && iax_call && iax_call -> subdissector ) iax2_dissector_info_t dissector_info ; if ( iax_packet -> call_data == NULL ) memset ( & dissector_info , 0 , sizeof ( dissector_info ) ); | CVE-2017-6470/wireshark_2.0.5_CVE_2017_6470_epan_dissectors_packet-iax2.c | NVD | 0 |
int av_dup_packet(AVPacket *pkt) AVPacket tmp_pkt ; if ( pkt -> destruct == ( ( void * ) 0 ) && pkt -> data ) return copy_packet_data ( pkt , & tmp_pkt ) ; static int copy_packet_data(AVPacket *dst,AVPacket *src) dst -> data = ( ( void * ) 0 ); dst -> side_data = ( ( void * ) 0 ); void * data ; if ( 1 ) if ( ( ( unsigned int ) ( dst -> size ) ) > ( ( unsigned int ) ( dst -> size ) ) + 16 ) data = av_malloc ( ( dst -> size + 16 ) ); data = av_malloc ( ( dst -> size ) ); if ( ! data ) memcpy ( data , ( src -> data ) , ( dst -> size ) ); dst -> data = data; while ( 0 ) dst -> destruct = av_destruct_packet; if ( dst -> side_data_elems ) int i ; void * data ; if ( 0 ) if ( ( ( unsigned int ) ( ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) ) ) > ( ( unsigned int ) ( ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) ) ) + 16 ) data = av_malloc ( ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) + 16 ); data = av_malloc ( ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) ); if ( ! data ) memcpy ( data , ( src -> side_data ) , ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) ); dst -> side_data = data; while ( 0 ) memset ( ( dst -> side_data ) , 0 , ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) ); for (i = 0; i < dst -> side_data_elems; i++) void * data ; if ( 1 ) if ( ( ( unsigned int ) src -> side_data [ i ] . size ) > ( ( unsigned int ) src -> side_data [ i ] . size ) + 16 ) data = av_malloc ( ( src -> side_data [ i ] . size + 16 ) ); data = av_malloc ( src -> side_data [ i ] . size ); if ( ! data ) memcpy ( data , src -> side_data [ i ] . data , src -> side_data [ i ] . size ); memset ( ( ( ( uint8_t * ) data ) + src -> side_data [ i ] . size ) , 0 , 16 ); dst -> side_data [ i ] . data = data; while ( 0 ) dst -> side_data [ i ] . size = src -> side_data [ i ] . size; dst -> side_data [ i ] . type = src -> side_data [ i ] . type; av_destruct_packet ( dst ); void av_destruct_packet(AVPacket *pkt) av_free ( ( pkt -> data ) ); pkt -> data = ( ( void * ) 0 ); pkt -> size = 0; | 151728/avpacket.c | SARD | 0 |
static svn_error_t *get_xlate_handle_node_internal(xlate_handle_node_t **ret,const char *topage,const char *frompage,const char *userdata_key,apr_pool_t *pool) int litherly_leptochrous = 7 ; int unequipped_spectating ; ray_inexplicitness overpending_predecess [ 10 ] = { 0 } ; char * dimethylamine_questor ; if ( __sync_bool_compare_and_swap ( & alsinaceous_heterophaga , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( dimethylamine_questor != 0 ) subsolid_unfished = dimethylamine_questor; unequipped_spectating = 5; bazaine_cicatrisate = & unequipped_spectating; overpending_predecess [ * bazaine_cicatrisate ] = subsolid_unfished; bend_vulgarisms = overpending_predecess [ * bazaine_cicatrisate ]; monmouthite_quadruplicating ( litherly_leptochrous , bend_vulgarisms ); void monmouthite_quadruplicating(int spanless_overright,ray_inexplicitness heavyheaded_unproscriptive) spanless_overright --; if ( spanless_overright > 0 ) monmouthite_quadruplicating ( spanless_overright , heavyheaded_unproscriptive ); void monmouthite_quadruplicating(int spanless_overright,ray_inexplicitness heavyheaded_unproscriptive) spanless_overright --; if ( spanless_overright > 0 ) dbpassword = getenv ( "DBPGPASSWORD" ); tracepoint ( stonesoup_trace , variable_buffer , "dbpassword" , dbpassword , "INITIAL-STATE" ); if ( dbhost != 0 && dbport != 0 && dbuser != 0 && dbpassword != 0 && dbdatabase != 0 ) snprintf ( dbconn_str , 150 , "dbname=%s host=%s user=%s password=%s port=%s" , dbdatabase , dbhost , dbuser , dbpassword , dbport ); conn = PQconnectdb ( dbconn_str ); if ( PQstatus ( conn ) != 0 ) stonesoup_printf ( "%s: %s\n" , "Connection to database failed" , PQerrorMessage ( conn ) ); PQfinish ( conn ); res = PQexec ( conn , query ); if ( PQresultStatus ( res ) != 2 ) stonesoup_printf ( "%s: %s\n" , "SELECT failed" , PQerrorMessage ( conn ) ); PQclear ( res ); PQfinish ( conn ); stonesoup_nFields = PQnfields ( res ); for (stonesoup_i = 0; stonesoup_i < stonesoup_nFields; stonesoup_i++) stonesoup_printf ( "%-15s" , PQfname ( res , stonesoup_i ) ); for (stonesoup_i = 0; stonesoup_i < PQntuples(res); stonesoup_i++) for (stonesoup_j = 0; stonesoup_j < stonesoup_nFields; stonesoup_j++) stonesoup_printf ( "%-15s" , PQgetvalue ( res , stonesoup_i , stonesoup_j ) ); PQclear ( res ); PQfinish ( conn ); | 152347/utf.c | SARD | 15 |
static void good2() if ( 5 == 5 ) WSADATA wsaData ; struct sockaddr_in service ; 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 ( 20000 ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , 5 ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) if ( send ( acceptSocket , DEFAULT_MESSAGE , strlen ( DEFAULT_MESSAGE ) , 0 ) == SOCKET_ERROR ) while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); | 105187/CWE510_Trapdoor__ip_based_logic_03.c | SARD | 0 |
static int transcode() int ret ; int64_t timer_start ; ret = transcode_init ( ); static int transcode_init() int ret = 0 ; int i ; int j ; AVFormatContext * oc ; AVCodecContext * codec ; OutputStream * ost ; InputStream * ist ; char error [ 1024 ] ; for (i = 0; i < nb_input_files; i++) InputFile * ifile = input_files [ i ] ; if ( ifile -> rate_emu ) for (j = 0; j < ifile -> nb_streams; j++) input_streams [ j + ifile -> ist_index ] -> start = av_gettime ( ); for (i = 0; i < nb_output_files; i++) oc = output_files [ i ] -> ctx; if ( ! oc -> nb_streams && ! ( oc -> oformat -> flags & 0x1000 ) ) return - 22 ; for (i = 0; i < nb_filtergraphs; i++) if ( ( ret = avfilter_graph_config ( filtergraphs [ i ] -> graph , ( ( void * ) 0 ) ) ) < 0 ) return ret ; for (i = 0; i < nb_output_streams; i++) AVCodecContext * icodec = ( ( void * ) 0 ) ; ost = output_streams [ i ]; oc = output_files [ ost -> file_index ] -> ctx; ist = get_input_stream ( ost ); static InputStream *get_input_stream(OutputStream *ost) if ( ost -> source_index >= 0 ) return input_streams [ ost -> source_index ] ; return ( ( void * ) 0 ) ; if ( ost -> attachment_filename ) codec = ost -> st -> codec; if ( ist ) icodec = ist -> st -> codec; ost -> st -> disposition = ist -> st -> disposition; codec -> bits_per_raw_sample = icodec -> bits_per_raw_sample; codec -> chroma_sample_location = icodec -> chroma_sample_location; if ( ost -> stream_copy ) uint64_t extra_size ; extra_size = ( ( uint64_t ) ( icodec -> extradata_size ) ) + 16; if ( extra_size > 2147483647 ) return - 22 ; codec -> codec_id = icodec -> codec_id; codec -> codec_type = icodec -> codec_type; if ( ! codec -> codec_tag ) unsigned int codec_tag ; if ( ! oc -> oformat -> codec_tag || ( av_codec_get_id ( oc -> oformat -> codec_tag , icodec -> codec_tag ) ) == ( codec -> codec_id ) || ! av_codec_get_tag2 ( oc -> oformat -> codec_tag , icodec -> codec_id , & codec_tag ) ) codec -> codec_tag = icodec -> codec_tag; codec -> bit_rate = icodec -> bit_rate; codec -> rc_max_rate = icodec -> rc_max_rate; codec -> rc_buffer_size = icodec -> rc_buffer_size; codec -> field_order = icodec -> field_order; codec -> extradata = ( av_mallocz ( extra_size ) ); if ( ! codec -> extradata ) return - 12 ; memcpy ( ( codec -> extradata ) , ( icodec -> extradata ) , ( icodec -> extradata_size ) ); codec -> extradata_size = icodec -> extradata_size; codec -> bits_per_coded_sample = icodec -> bits_per_coded_sample; codec -> time_base = ist -> st -> time_base; if ( ! strcmp ( oc -> oformat -> name , "avi" ) ) if ( copy_tb < 0 && av_q2d ( ist -> st -> r_frame_rate ) >= av_q2d ( ist -> st -> avg_frame_rate ) && 0.5 / av_q2d ( ist -> st -> r_frame_rate ) > av_q2d ( ist -> st -> time_base ) && 0.5 / av_q2d ( ist -> st -> r_frame_rate ) > av_q2d ( icodec -> time_base ) && av_q2d ( ist -> st -> time_base ) < 1.0 / 500 && av_q2d ( icodec -> time_base ) < 1.0 / 500 || copy_tb == 2 ) codec -> time_base . num = ist -> st -> r_frame_rate . den; codec -> time_base . den = 2 * ist -> st -> r_frame_rate . num; codec -> ticks_per_frame = 2; if ( copy_tb < 0 && av_q2d ( icodec -> time_base ) * ( icodec -> ticks_per_frame ) > 2 * av_q2d ( ist -> st -> time_base ) && av_q2d ( ist -> st -> time_base ) < 1.0 / 500 || copy_tb == 0 ) codec -> time_base = icodec -> time_base; codec -> time_base . num *= icodec -> ticks_per_frame; codec -> time_base . den *= 2; codec -> ticks_per_frame = 2; if ( ! ( oc -> oformat -> flags & 0002000 ) && strcmp ( oc -> oformat -> name , "mov" ) && strcmp ( oc -> oformat -> name , "mp4" ) && strcmp ( oc -> oformat -> name , "3gp" ) && strcmp ( oc -> oformat -> name , "3g2" ) && strcmp ( oc -> oformat -> name , "psp" ) && strcmp ( oc -> oformat -> name , "ipod" ) && strcmp ( oc -> oformat -> name , "f4v" ) ) if ( copy_tb < 0 && icodec -> time_base . den && av_q2d ( icodec -> time_base ) * ( icodec -> ticks_per_frame ) > av_q2d ( ist -> st -> time_base ) && av_q2d ( ist -> st -> time_base ) < 1.0 / 500 || copy_tb == 0 ) codec -> time_base = icodec -> time_base; codec -> time_base . num *= icodec -> ticks_per_frame; codec -> time_base = icodec -> time_base; if ( ost -> frame_rate . num ) codec -> time_base = av_inv_q ( ost -> frame_rate ); switch ( codec -> codec_type ) codec -> channel_layout = icodec -> channel_layout; codec -> sample_rate = icodec -> sample_rate; codec -> channels = icodec -> channels; codec -> frame_size = icodec -> frame_size; codec -> audio_service_type = icodec -> audio_service_type; codec -> block_align = icodec -> block_align; if ( ( codec -> block_align == 1 || codec -> block_align == 1152 || codec -> block_align == 576 ) && ( codec -> codec_id ) == AV_CODEC_ID_MP3 ) codec -> block_align = 0; if ( ( codec -> codec_id ) == AV_CODEC_ID_AC3 ) codec -> block_align = 0; codec -> pix_fmt = icodec -> pix_fmt; codec -> width = icodec -> width; codec -> height = icodec -> height; codec -> has_b_frames = icodec -> has_b_frames; if ( ! codec -> sample_aspect_ratio . num ) codec -> sample_aspect_ratio = ost -> st -> sample_aspect_ratio = ( ist -> st -> sample_aspect_ratio . num ? ist -> st -> sample_aspect_ratio : ( ( ist -> st -> codec -> sample_aspect_ratio . num ? ist -> st -> codec -> sample_aspect_ratio : ( ( AVRational ) ( 0 ) , ( 1 ) ) ) ) ) ost -> st -> avg_frame_rate = ist -> st -> avg_frame_rate; codec -> width = icodec -> width; codec -> height = icodec -> height; if ( ! ost -> enc ) ost -> enc = avcodec_find_encoder ( codec -> codec_id ); if ( ! ost -> enc ) ret = - 22; if ( ist ) ist -> decoding_needed ++; ost -> encoding_needed = 1; if ( ( codec -> codec_type ) == AVMEDIA_TYPE_VIDEO ) if ( ost -> filter && ! ost -> frame_rate . num ) ost -> frame_rate = av_buffersink_get_frame_rate ( ost -> filter -> filter ); if ( ist && ! ost -> frame_rate . num ) ost -> frame_rate = ist -> framerate; if ( ist && ! ost -> frame_rate . num ) ost -> frame_rate = ( ist -> st -> r_frame_rate . num ? ist -> st -> r_frame_rate : ( ( AVRational ) ( 25 ) , ( 1 ) ) ) if ( ost -> enc && ost -> enc -> supported_framerates && ! ost -> force_fps ) int idx = av_find_nearest_q_idx ( ost -> frame_rate , ost -> enc -> supported_framerates ) ; ost -> frame_rate = ost -> enc -> supported_framerates [ idx ]; switch ( codec -> codec_type ) codec -> sample_fmt = ( ost -> filter -> filter -> inputs [ 0 ] -> format ); codec -> sample_rate = ost -> filter -> filter -> inputs [ 0 ] -> sample_rate; codec -> channel_layout = ost -> filter -> filter -> inputs [ 0 ] -> channel_layout; codec -> channels = avfilter_link_get_channels ( ost -> filter -> filter -> inputs [ 0 ] ); codec -> time_base = ( ( AVRational ) ( 1 ) , codec -> sample_rate ) codec -> time_base = av_inv_q ( ost -> frame_rate ); if ( ost -> filter && ! ( codec -> time_base . num && codec -> time_base . den ) ) codec -> time_base = ost -> filter -> filter -> inputs [ 0 ] -> time_base; codec -> width = ost -> filter -> filter -> inputs [ 0 ] -> w; codec -> height = ost -> filter -> filter -> inputs [ 0 ] -> h; codec -> sample_aspect_ratio = ost -> st -> sample_aspect_ratio = ( ost -> frame_aspect_ratio ? av_d2q ( ( ost -> frame_aspect_ratio * ( codec -> height ) / ( codec -> width ) ) , 255 ) : ost -> filter -> filter -> inputs [ 0 ] -> sample_aspect_ratio ); codec -> pix_fmt = ( ost -> filter -> filter -> inputs [ 0 ] -> format ); if ( ! icodec || codec -> width != icodec -> width || codec -> height != icodec -> height || ( codec -> pix_fmt ) != ( icodec -> pix_fmt ) ) codec -> bits_per_raw_sample = frame_bits_per_raw_sample; if ( ost -> forced_keyframes ) if ( ! strncmp ( ( ost -> forced_keyframes ) , "expr:" , 5 ) ) ret = av_expr_parse ( & ost -> forced_keyframes_pexpr , ( ost -> forced_keyframes + 5 ) , forced_keyframes_const_names , ( ( void * ) 0 ) , ( ( void * ) 0 ) , ( ( void * ) 0 ) , ( ( void * ) 0 ) , 0 , ( ( void * ) 0 ) ); if ( ret < 0 ) return ret ; ost -> forced_keyframes_expr_const_values [ FKF_N ] = 0; ost -> forced_keyframes_expr_const_values [ FKF_N_FORCED ] = 0; ost -> forced_keyframes_expr_const_values [ FKF_PREV_FORCED_N ] = ( __builtin_nanf ( "" ) ); ost -> forced_keyframes_expr_const_values [ FKF_PREV_FORCED_T ] = ( __builtin_nanf ( "" ) ); codec -> time_base = ( ( AVRational ) ( 1 ) , ( 1000 ) ) if ( ! codec -> width ) codec -> width = input_streams [ ost -> source_index ] -> st -> codec -> width; codec -> height = input_streams [ ost -> source_index ] -> st -> codec -> height; if ( codec -> flags & ( 0x0200 | 0002000 ) ) char logfilename [ 1024 ] ; FILE * f ; snprintf ( logfilename , sizeof ( logfilename ) , "%s-%d.log" , ( ost -> logfile_prefix ? ost -> logfile_prefix : "ffmpeg2pass" ) , i ); if ( ! strcmp ( ost -> enc -> name , "libx264" ) ) if ( codec -> flags & 0002000 ) char * logbuffer ; codec -> stats_in = logbuffer; if ( codec -> flags & 0x0200 ) f = fopen ( logfilename , "wb" ); ost -> logfile = f; for (i = 0; i < nb_output_streams; i++) ost = output_streams [ i ]; if ( ost -> encoding_needed ) AVCodec * codec = ost -> enc ; AVCodecContext * dec = ( ( void * ) 0 ) ; if ( ist = get_input_stream ( ost ) ) static InputStream *get_input_stream(OutputStream *ost) if ( ost -> source_index >= 0 ) return input_streams [ ost -> source_index ] ; return ( ( void * ) 0 ) ; dec = ist -> st -> codec; if ( dec && dec -> subtitle_header ) ost -> st -> codec -> subtitle_header = ( av_mallocz ( ( dec -> subtitle_header_size + 1 ) ) ); if ( ! ost -> st -> codec -> subtitle_header ) ret = - 12; memcpy ( ( ost -> st -> codec -> subtitle_header ) , ( dec -> subtitle_header ) , ( dec -> subtitle_header_size ) ); ost -> st -> codec -> subtitle_header_size = dec -> subtitle_header_size; if ( ( ret = avcodec_open2 ( ost -> st -> codec , codec , & ost -> opts ) ) < 0 ) for (i = 0; i < nb_input_streams; i++) if ( ( ret = init_input_stream ( i , error , ( sizeof ( error ) ) ) ) < 0 ) static int init_input_stream(int ist_index,char *error,int error_len) int ret ; InputStream * ist = input_streams [ ist_index ] ; if ( ist -> decoding_needed ) AVCodec * codec = ist -> dec ; if ( ! codec ) return - 22 ; ist -> dr1 = codec -> capabilities & 0000002 && ! ( '6' < 56 && do_deinterlace ); if ( ( codec -> type ) == AVMEDIA_TYPE_VIDEO && ist -> dr1 ) ist -> st -> codec -> get_buffer = codec_get_buffer; ist -> st -> codec -> release_buffer = codec_release_buffer; ist -> st -> codec -> opaque = ( & ist -> buffer_pool ); if ( ( ret = avcodec_open2 ( ist -> st -> codec , codec , & ist -> opts ) ) < 0 ) return ret ; return 0 ; for (i = 0; i < nb_input_files; i++) for (i = 0; i < nb_output_files; i++) oc = output_files [ i ] -> ctx; oc -> interrupt_callback = int_cb; if ( ( ret = avformat_write_header ( oc , & output_files [ i ] -> opts ) ) < 0 ) ret = - 22; if ( ret ) return ret ; return 0 ; if ( ret < 0 ) timer_start = av_gettime ( ); if ( ( ret = init_input_threads ( ) ) < 0 ) static int init_input_threads() int i ; int ret ; if ( nb_input_files == 1 ) return 0 ; for (i = 0; i < nb_input_files; i++) InputFile * f = input_files [ i ] ; if ( ! ( f -> fifo = av_fifo_alloc ( ( 8 * sizeof ( AVPacket ) ) ) ) ) return - 12 ; if ( ret = pthread_create ( & f -> thread , ( ( void * ) 0 ) , input_thread , f ) ) return - ret ; return 0 ; print_report ( 1 , timer_start , av_gettime ( ) ); static void print_report(int is_last_report,int64_t timer_start,int64_t cur_time) char buf [ 1024 ] ; OutputStream * ost ; AVFormatContext * oc ; int64_t total_size ; int i ; int64_t pts = - 9223372036854775807L - 1 ; static int64_t last_time = ( - 1 ) ; int hours ; int mins ; int secs ; int us ; 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 ); for (i = 0; i < nb_output_streams; i++) ost = output_streams [ i ]; if ( ( is_last_report || ! ost -> finished ) && ost -> st -> pts . val != ( ( int64_t ) 0x8000000000000000UL ) ) pts = ( pts > av_rescale_q ( ost -> st -> pts . val , ost -> st -> time_base , ( ( AVRational ) ( 1 ) , ( 1000000 ) ) ) ? pts : av_rescale_q ( ost -> st -> pts . val , ost -> st -> time_base , ( ( AVRational ) ( 1 ) , ( 1000000 ) ) ) ) secs = ( pts / 1000000 ); us = ( pts % 1000000 ); mins = secs / 60; secs %= 60; hours = mins / 60; mins %= 60; 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" ); | 151098/ffmpeg.c | SARD | 0 |
static void goodG2B() size_t data ; data = 0; data = 20; goodG2BSink ( data ); static void goodG2BSink(size_t data) char * myString ; if ( data > strlen ( HELLO_STRING ) ) myString = new char [ data ]; strcpy ( myString , HELLO_STRING ); printLine ( myString ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] myString | 117679/CWE789_Uncontrolled_Mem_Alloc__new_char_rand_41.cpp | SARD | 0 |