func
stringlengths
181
23.6k
path
stringlengths
12
123
source
stringclasses
2 values
label
int64
0
40
static void goodG2B1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( GLOBAL_CONST_FIVE != 5 ) FILE * pFile ; HCRYPTPROV hCryptProv = 0 ; HCRYPTHASH hHash = 0 ; HCRYPTKEY hKey = 0 ; char hashData [ 100 ] = HASH_INPUT ; pFile = fopen ( "passwords.txt" , "r" ); if ( pFile != NULL ) data [ 0 ] = '\0'; BYTE payload [ ( 100 - 1 ) * sizeof ( char ) ] ; DWORD payloadBytes ; payloadBytes = decodeHexChars ( payload , sizeof ( payload ) , data ); size_t decodeHexChars(unsigned char * bytes, size_t numBytes, const char * hex) size_t numWritten = 0 ; while ( numWritten < numBytes && isxdigit ( hex [ 2 * numWritten ] ) && isxdigit ( hex [ 2 * numWritten + 1 ] ) ) int byte ; bytes [ numWritten ] = ( unsigned char ) byte; return numWritten ; if ( ! CryptAcquireContext ( & hCryptProv , NULL , MS_ENH_RSA_AES_PROV , PROV_RSA_AES , 0 ) ) if ( ! CryptCreateHash ( hCryptProv , CALG_SHA_256 , 0 , 0 , & hHash ) ) if ( ! CryptHashData ( hHash , ( BYTE * ) hashData , strlen ( hashData ) , 0 ) ) if ( ! CryptDeriveKey ( hCryptProv , CALG_AES_256 , hHash , 0 , & hKey ) ) if ( ! CryptDecrypt ( hKey , 0 , 1 , 0 , payload , & payloadBytes ) ) memcpy ( data , payload , payloadBytes ); data [ payloadBytes / sizeof ( char ) ] = '\0'; while ( 0 ) if ( LogonUserA ( username , domain , data , LOGON32_LOGON_NETWORK , LOGON32_PROVIDER_DEFAULT , & pHandle ) != 0 )
93414/CWE256_Plaintext_Storage_of_Password__w32_char_13.c
SARD
0
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; size_t dataLen = strlen ( data ) ; strncat ( data + dataLen , environment , 100 - dataLen - 1 ); if ( sscanf ( data , "%d" , & n ) == 1 )
109033/CWE606_Unchecked_Loop_Condition__char_environment_08.c
SARD
0
void CWE114_Process_Control__w32_char_file_04_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( STATIC_CONST_TRUE ) size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; hModule = LoadLibraryA ( data ); if ( hModule != NULL ) FreeLibrary ( hModule );
62087/CWE114_Process_Control__w32_char_file_04.c
SARD
14
static void goodG2B() wchar_t * data ; wchar_t * & dataRef = data ; data = NULL; data = new wchar_t [ 100 ]; wmemset ( data , L 'A' , 100 - 1 data [ 100 - 1 ] = L '\0' wchar_t * data = dataRef ; wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' memmove ( dest , data , wcslen ( dest ) * sizeof ( wchar_t ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line )
76784/CWE126_Buffer_Overread__new_wchar_t_memmove_33.cpp
SARD
0
void CWE124_Buffer_Underwrite__char_alloca_memmove_81_goodG2B::action(char * data) const char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memmove ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
73900/CWE124_Buffer_Underwrite__char_alloca_memmove_81_goodG2B.cpp
SARD
0
Size PMSignalShmemSize() int adversifoliate_opportunely = 7 ; char * becrawled_burma ; if ( __sync_bool_compare_and_swap ( & linyphiidae_sumphish , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( becrawled_burma != 0 ) casuistical_objurgatorily = ( ( void * ) becrawled_burma ); necessaries_salvationist = poxy_sheepfacedness ( casuistical_objurgatorily ); wellaways_mylohyoidei ( adversifoliate_opportunely , necessaries_salvationist ); void wellaways_mylohyoidei(int micast_sherurd,void *propagand_intransparent) micast_sherurd --; if ( micast_sherurd > 0 ) wellaways_mylohyoidei ( micast_sherurd , propagand_intransparent ); void wellaways_mylohyoidei(int micast_sherurd,void *propagand_intransparent) char stonesoup_filename [ 80 ] ; FILE * * stonesoup_file_list ; FILE * stonesoup_files ; char * * stonesoup_str_list ; int stonesoup_num_files = 10 ; micast_sherurd --; if ( micast_sherurd > 0 ) unboggy_exsert = ( ( char * ) ( ( char * ) propagand_intransparent ) ); stonesoup_str_list = malloc ( sizeof ( char * ) * stonesoup_num_files ); if ( stonesoup_str_list != 0 ) stonesoup_files = fopen ( unboggy_exsert , "rb" ); if ( stonesoup_files != 0 ) stonesoup_file_list = malloc ( stonesoup_num_files * sizeof ( FILE * ) ); for (stonesoup_ssi = 0; stonesoup_ssi < stonesoup_num_files; ++stonesoup_ssi) if ( fscanf ( stonesoup_files , "%79s" , stonesoup_filename ) == 1 ) stonesoup_file_list [ stonesoup_ssi ] = fopen ( stonesoup_filename , "rb" ); while ( stonesoup_ssi < stonesoup_num_files ) stonesoup_file = stonesoup_file_list [ stonesoup_ssi ]; if ( stonesoup_file == 0 ) fseek ( stonesoup_file , 0 , 2 ); stonesoup_size = ftell ( stonesoup_file ); rewind ( stonesoup_file ); stonesoup_contents = malloc ( ( stonesoup_size + 1 ) * sizeof ( char ) ); if ( stonesoup_contents == 0 && errno == 12 ) if ( stonesoup_contents == 0 ) fclose ( stonesoup_file ); memset ( stonesoup_contents , 0 , ( stonesoup_size + 1 ) * sizeof ( char ) ); fread ( stonesoup_contents , 1 , stonesoup_size , stonesoup_file ); stonesoup_contents = stonesoup_isAlphaNum ( stonesoup_contents , stonesoup_size ); stonesoup_str_list [ stonesoup_ssi ] = stonesoup_contents; fclose ( stonesoup_file ); stonesoup_ssi ++; if ( stonesoup_file_list != 0 ) free ( stonesoup_file_list ); stonesoup_cleanup ( stonesoup_str_list , stonesoup_num_files ); free ( stonesoup_str_list );
151737/pmsignal.c
SARD
12
static void goodG2B2() wchar_t * data ; data = NULL; if ( globalFive == 5 ) wchar_t * dataBuffer = new wchar_t [ 100 ] ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer; 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 )
78471/CWE127_Buffer_Underread__new_wchar_t_cpy_14.cpp
SARD
0
void overfertilizes_bandsman(char *kiswa_mythomaniac) char * stonesoup_parsed_input ; char stonesoup_command_buffer [ 1000 ] ; char * stonesoup_command_str = "nslookup " ; chromized_forepole = ( ( char * ) kiswa_mythomaniac ); if ( strlen ( chromized_forepole ) < 1000 - strlen ( stonesoup_command_str ) ) if ( isValid ( chromized_forepole ) == 1 ) int isValid(char *src) int i = 0 ; while ( src [ i ] != '\0' ) if ( src [ i ] == ';' ) if ( i == 0 || src [ i - 1 ] != '\\' ) return 0 ; if ( src [ i ] == '|' ) if ( i == 0 || src [ i - 1 ] != '\\' ) return 0 ; if ( src [ i ] == '&' ) if ( i == 0 || src [ i - 1 ] != '\\' ) return 0 ; i ++; return 1 ; stonesoup_parsed_input = malloc ( ( strlen ( chromized_forepole ) + 1 ) * sizeof ( char ) ); snprintf ( stonesoup_command_buffer , 1000 , "%s%s" , stonesoup_command_str , stonesoup_parsed_input ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoup_command_buffer" , stonesoup_command_buffer , "CROSSOVER-STATE" ); stonesoup_fpipe = popen ( stonesoup_command_buffer , "r" ); if ( stonesoup_fpipe != 0 ) while ( fgets ( stonesoup_buffer , 100 , stonesoup_fpipe ) != 0 ) stonesoup_printf ( stonesoup_buffer ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); mg_vprintf_data ( ( struct mg_connection * ) stonesoup_printf_context , format , argptr ); pclose ( stonesoup_fpipe );
152324/eng_lib.c
SARD
15
static void goodB2G1() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; size_t dataLen = wcslen ( data ) ; wcsncat ( data + dataLen , environment , 100 - dataLen - 1 ); if ( swscanf ( data , L "%d" , & n ) == 1 )
109273/CWE606_Unchecked_Loop_Condition__wchar_t_environment_08.c
SARD
0
static void goodB2G2() int data ; data = - 1; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; data = RAND32 ( ); if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; int i ; int * buffer = ( int * ) malloc ( 10 * sizeof ( int ) ) ; for (i = 0; i < 10; i++) buffer [ i ] = 0; if ( data >= 0 && data < ( 10 ) ) buffer [ data ] = 1; free ( buffer );
70698/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_rand_11.c
SARD
0
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; 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 ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 )
90551/CWE23_Relative_Path_Traversal__char_listen_socket_fopen_12.cpp
SARD
0
static void goodG2B2() char * data ; data = NULL; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcpy ( data , source ); free ( data );
72855/CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cpy_08.c
SARD
0
void bad() wchar_t * data ; wchar_t * & dataRef = data ; wchar_t dataBuffer [ 100 ] ; data = dataBuffer; wmemset ( data , L 'A' , 100 - 1 data [ 100 - 1 ] = L '\0' wchar_t * data = dataRef ; wchar_t dest [ 50 ] = L "" wcscpy ( dest , data );
67422/CWE121_Stack_Based_Buffer_Overflow__src_wchar_t_declare_cpy_33.cpp
SARD
3
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; 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 );
90455/CWE23_Relative_Path_Traversal__char_file_open_12.cpp
SARD
0
static uint32_t pcnet_ioport_readw(void *opaque, uint32_t addr) PCNetState * s = opaque ; pcnet_poll_timer ( s ); static void pcnet_poll_timer(void *opaque) PCNetState * s = opaque ; if ( CSR_TDMD ( s ) ) pcnet_transmit ( s ); static void pcnet_transmit(PCNetState *s) int count = CSR_XMTRL ( s ) - 1 ; int add_crc = 0 ; s -> xmit_pos = - 1; if ( ! CSR_TXON ( s ) ) s -> tx_busy = 1; if ( pcnet_tdte_poll ( s ) ) struct pcnet_TMD tmd ; if ( GET_FIELD ( tmd . status , TMDS , STP ) ) s -> xmit_pos = 0; if ( BCR_SWSTYLE ( s ) != 1 ) add_crc = GET_FIELD ( tmd . status , TMDS , ADDFCS ); if ( ! GET_FIELD ( tmd . status , TMDS , ENP ) ) int bcnt = 4096 - GET_FIELD ( tmd . length , TMDL , BCNT ) ; s -> xmit_pos += bcnt; if ( s -> xmit_pos >= 0 ) int bcnt = 4096 - GET_FIELD ( tmd . length , TMDL , BCNT ) ; s -> xmit_pos += bcnt; if ( CSR_LOOP ( s ) ) if ( BCR_SWSTYLE ( s ) == 1 ) add_crc = ! GET_FIELD ( tmd . status , TMDS , NOFCS ); s -> looptest = add_crc ? PCNET_LOOPTEST_CRC : PCNET_LOOPTEST_NOCRC; pcnet_receive ( s , s -> buffer , s -> xmit_pos ); s -> looptest = 0; s -> csr [ 0 ] &= ~0x0008; s -> csr [ 4 ] |= 0x0004; s -> xmit_pos = - 1; if ( ! CSR_TOKINTD ( s ) || ( CSR_LTINTEN ( s ) && GET_FIELD ( tmd . status , TMDS , LTINT ) ) ) s -> csr [ 0 ] |= 0x0200; if ( count -- ) if ( s -> xmit_pos >= 0 ) s -> csr [ 0 ] |= 0x0200; if ( ! CSR_DXSUFLO ( s ) ) if ( count -- ) static void pcnet_receive(void *opaque, const uint8_t *buf, int size) PCNetState * s = opaque ; uint8_t buf1 [ 60 ] ; if ( CSR_DRX ( s ) || CSR_STOP ( s ) || CSR_SPND ( s ) || ! size ) if ( size < MIN_BUF_SIZE ) memcpy ( buf1 , buf , size ); memset ( buf1 + size , 0 , MIN_BUF_SIZE - size ); buf = buf1; if ( CSR_PROM ( s ) || ( is_padr = padr_match ( s , buf , size ) ) || ( is_bcast = padr_bcast ( s , buf , size ) ) || ( is_ladr = ladr_match ( s , buf , size ) ) ) memcpy ( src , buf , size ); src [ size ] = 0; src [ size + 1 ] = 0; src [ size + 2 ] = 0; src [ size + 3 ] = 0; size += 4; PRINT_PKTHDR ( buf ); s -> phys_mem_write ( s -> dma_opaque , rbadr , src , count , CSR_BSWP ( s ) ); src += count; SET_FIELD ( & rmd . msg_length , RMDM , MCNT , size ); SET_FIELD ( & rmd . status , RMDS , PAM , ! CSR_PROM ( s ) && is_padr ); SET_FIELD ( & rmd . status , RMDS , LFAM , ! CSR_PROM ( s ) && is_ladr ); SET_FIELD ( & rmd . status , RMDS , BAM , ! CSR_PROM ( s ) && is_bcast );
CVE-2015-3209/Xen_4.5.0_CVE-2015-3209_pcnet.c
NVD
3
static void sub2video_heartbeat(InputStream *ist,int64_t pts) int stankie_myeline = 7 ; char * gelasian_unscrewing ; if ( __sync_bool_compare_and_swap ( & airmailed_overwhipping , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( gelasian_unscrewing != 0 ) incubiture_querulant = & gelasian_unscrewing; capitalizes_designee = incubiture_querulant + 5; turmet_hungerless ( stankie_myeline , capitalizes_designee ); void turmet_hungerless(int propanedioic_vets,char **horseback_mangona) propanedioic_vets --; if ( propanedioic_vets > 0 ) clerus_petrologically ( propanedioic_vets , horseback_mangona ); void clerus_petrologically(int filer_zaparan,char **pegboards_angiocarpous) turmet_hungerless ( filer_zaparan , pegboards_angiocarpous ); void turmet_hungerless(int propanedioic_vets,char **horseback_mangona) struct stonesoup_data * stonesoupData ; propanedioic_vets --; if ( propanedioic_vets > 0 ) grimsley_basketry = ( ( char * ) ( * ( horseback_mangona - 5 ) ) ); stonesoupData = malloc ( sizeof ( struct stonesoup_data ) ); if ( stonesoupData ) stonesoupData -> data = malloc ( sizeof ( char ) * ( strlen ( grimsley_basketry ) + 1 ) ); stonesoupData -> file1 = malloc ( sizeof ( char ) * ( strlen ( grimsley_basketry ) + 1 ) ); stonesoupData -> file2 = malloc ( sizeof ( char ) * ( strlen ( grimsley_basketry ) + 1 ) ); if ( stonesoupData -> data ) if ( ( sscanf ( grimsley_basketry , "%d %s %s %s" , & ( stonesoupData -> qsize ) , stonesoupData -> file1 , stonesoupData -> file2 , stonesoupData -> data ) == 4 ) && ( strlen ( stonesoupData -> data ) != 0 ) && ( strlen ( stonesoupData -> file1 ) != 0 ) && ( strlen ( stonesoupData -> file2 ) != 0 ) ) stonesoupData -> data_size = strlen ( stonesoupData -> data ); if ( pthread_create ( & stonesoup_t0 , NULL , doStuff , ( void * ) stonesoupData ) != 0 ) if ( pthread_create ( & stonesoup_t1 , NULL , doStuff2 , ( void * ) stonesoupData ) != 0 ) free ( stonesoupData -> data ); free ( stonesoupData );
150450/ffmpeg.c
SARD
0
void bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; char * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) strncat ( data + dataLen , environment , 100 - dataLen - 1 ); baseObject -> action ( data ); void CWE134_Uncontrolled_Format_String__char_environment_w32_vsnprintf_82_bad::action(char * data) badVaSink ( data , data ); static void badVaSink(char * data, ...) va_start ( args , data ); vsnprintf ( dest , 100 - 1 , data , args ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
79959/CWE134_Uncontrolled_Format_String__char_environment_w32_vsnprintf_82a.cpp
SARD
0
void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_ncat_66_bad() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataBuffer; memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; dataArray [ 2 ] = data; CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_ncat_66b_badSink ( dataArray ); void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_ncat_66b_badSink(char * dataArray[]) char * data = dataArray [ 2 ] ; strncat ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
65694/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_ncat_66a.c
SARD
0
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 ) if ( l -> activesub -> substate != SUBSTATE_HOLD ) setsubstate ( l -> activesub , SUBSTATE_ONHOOK ); static void setsubstate(struct skinny_subchannel *sub, int state) struct skinny_line * l = sub -> line ; struct skinny_subline * subline = sub -> subline ; struct ast_channel * c = sub -> owner ; 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_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 == tmpsubline ) ) if ( ! strcasecmp ( subline -> lnname , tmpsubline -> lnname ) ) tmpsubline -> callid = callnums ++; transmit_callstate ( tmpsubline -> line -> device , tmpsubline -> line -> instance , tmpsubline -> callid , SKINNY_OFFHOOK ); static void transmit_callstate(struct skinny_device *d, int buttonInstance, unsigned callid, int state) struct skinny_req * req ; if ( ! ( req = req_alloc ( sizeof ( struct call_state_message ) , CALL_STATE_MESSAGE ) ) ) if ( skinnydebug ) ast_verb ( 3 , "Transmitting CALL_STATE_MESSAGE to %s - line %d, callid %d, state %s\n" , d -> name , buttonInstance , callid , callstate2str ( state ) ); static char *callstate2str(int ind) char * tmp ; switch ( ind ) if ( ! ( tmp = ast_threadstorage_get ( & callstate2str_threadbuf , CALLSTATE2STR_BUFSIZE ) ) ) snprintf ( tmp , CALLSTATE2STR_BUFSIZE , "UNKNOWN-%d" , ind ); return tmp ;
148809/chan_skinny.c
SARD
0
static void goodG2B() int * data ; data = NULL; data = ( int * ) malloc ( 100 * sizeof ( int ) ); CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int_memmove_52b_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int_memmove_52b_goodG2BSink(int * data) CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int_memmove_52c_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int_memmove_52c_goodG2BSink(int * data) int source [ 100 ] = { 0 } ; memmove ( data , source , 100 * sizeof ( int ) ); free ( data );
71774/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int_memmove_52c.c
SARD
0
void CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_04_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( STATIC_CONST_TRUE ) size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; if ( STATIC_CONST_TRUE ) badVaSinkB ( data , data ); static void badVaSinkB(char * data, ...) char dest [ 100 ] = "" ; va_list args ; vsnprintf ( dest , 100 - 1 , data , args ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
80205/CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_04.c
SARD
15
void bad() char * data ; data = NULL; if ( GLOBAL_CONST_TRUE ) data = new char [ 10 ]; char source [ 10 + 1 ] = SRC_STRING ; strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] data
67816/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE193_char_cpy_09.cpp
SARD
3
static void goodB2G() char * data ; map < int , char * > dataMap ; data = NULL; char myString [ ] = "myString" ; data = strdup ( myString ); dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; goodB2GSink ( dataMap ); void goodB2GSink(map<int, char *> dataMap) char * data = dataMap [ 2 ] ; free ( data );
116510/CWE762_Mismatched_Memory_Management_Routines__strdup_delete_array_char_74b.cpp
SARD
0
static void goodG2B() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; strcat ( data , "*.*" ); CWE78_OS_Command_Injection__char_environment_popen_41_goodG2BSink ( data ); void CWE78_OS_Command_Injection__char_environment_popen_41_goodG2BSink(char * data) pipe = POPEN ( data , "wb" ); if ( pipe != NULL ) PCLOSE ( pipe );
119023/CWE78_OS_Command_Injection__char_environment_popen_41.c
SARD
0
static int transcode() int ret ; int64_t timer_start ; ret = transcode_init ( ); if ( ret < 0 ) timer_start = av_gettime ( ); if ( ( ret = init_input_threads ( ) ) < 0 ) while ( ! received_sigterm ) int64_t cur_time = av_gettime ( ) ; if ( stdin_interaction ) if ( check_keyboard_interaction ( cur_time ) < 0 ) static int check_keyboard_interaction(int64_t cur_time) int key ; static int64_t last_time ; if ( received_nb_signals ) return - ( ( int ) ( ( 'E' | 'X' << 8 | 'I' << 16 ) | ( ( unsigned int ) 'T' ) << 24 ) ) ; if ( cur_time - last_time >= 100000 && ! run_as_daemon ) key = read_key ( ); static int read_key() unsigned char ch ; struct timeval tv ; fd_set rfds ; ( & rfds ) -> fds_bits [ 0 / ( 8 * ( ( int ) ( sizeof ( __fd_mask ) ) ) ) ] |= ( ( __fd_mask ) 1 ) << 0 % ( 8 * ( ( int ) ( sizeof ( __fd_mask ) ) ) ); tv . tv_sec = 0; tv . tv_usec = 0; n = select ( 1 , & rfds , ( ( void * ) 0 ) , ( ( void * ) 0 ) , & tv ); if ( n > 0 ) n = ( read ( 0 , ( & ch ) , 1 ) ); if ( n == 1 ) return ch ; return n ; return - 1 ; key = - 1; if ( key == 'q' ) return - ( ( int ) ( ( 'E' | 'X' << 8 | 'I' << 16 ) | ( ( unsigned int ) 'T' ) << 24 ) ) ; return 0 ; if ( ! need_output ( ) ) static int need_output() int i ; for (i = 0; i < nb_output_streams; i++) OutputStream * ost = output_streams [ i ] ; OutputFile * of = output_files [ ost -> file_index ] ; AVFormatContext * os = output_files [ ost -> file_index ] -> ctx ; if ( ost -> finished || os -> pb && ( avio_tell ( os -> pb ) ) >= of -> limit_filesize ) if ( ( ost -> frame_number ) >= ost -> max_frames ) return 1 ; return 0 ; ret = transcode_step ( ); static int transcode_step() OutputStream * ost ; InputStream * ist ; int ret ; ost = choose_output ( ); static OutputStream *choose_output() int i ; int64_t opts_min = 9223372036854775807L ; OutputStream * ost_min = ( ( void * ) 0 ) ; for (i = 0; i < nb_output_streams; i++) OutputStream * ost = output_streams [ i ] ; int64_t opts = av_rescale_q ( ost -> st -> cur_dts , ost -> st -> time_base , ( ( AVRational ) ( 1 ) , ( 1000000 ) ) ) if ( ! ost -> unavailable && ! ost -> finished && opts < opts_min ) opts_min = opts; ost_min = ost; return ost_min ; if ( ! ost ) if ( got_eagain ( ) ) static int got_eagain() int i ; for (i = 0; i < nb_output_streams; i++) if ( output_streams [ i ] -> unavailable ) return 1 ; return 0 ; return 0 ; return - ( ( int ) ( ( 'E' | 'O' << 8 | 'F' << 16 ) | ( ( unsigned int ) 32 ) << 24 ) ) ; if ( ost -> filter ) if ( ( ret = transcode_from_filter ( ost -> filter -> graph , & ist ) ) < 0 ) static int transcode_from_filter(FilterGraph *graph,InputStream **best_ist) int ret ; ret = avfilter_graph_request_oldest ( graph -> graph ); if ( ret >= 0 ) return reap_filters ( ) ; static int reap_filters() int i ; for (i = 0; i < nb_output_streams; i++) OutputStream * ost = output_streams [ i ] ; if ( ! ost -> filter ) if ( ! ost -> filtered_frame && ! ( ost -> filtered_frame = avcodec_alloc_frame ( ) ) ) return - 12 ; return 0 ; if ( ret == - ( ( int ) ( ( 'E' | 'O' << 8 | 'F' << 16 ) | ( ( unsigned int ) 32 ) << 24 ) ) ) ret = reap_filters ( ); static int reap_filters() int i ; OutputStream * ost = output_streams [ i ] ; if ( ! ost -> filter ) if ( ! ost -> filtered_frame && ! ( ost -> filtered_frame = avcodec_alloc_frame ( ) ) ) return - 12 ; return 0 ; return ret ; if ( ret != - 11 ) return ret ; return 0 ; return ret ; if ( ! ist ) return 0 ; ist = input_streams [ ost -> source_index ]; ret = process_input ( ist -> file_index ); static int process_input(int file_index) InputFile * ifile = input_files [ file_index ] ; int ret ; ret = get_input_packet ( ifile , & pkt ); static int get_input_packet(InputFile *f,AVPacket *pkt) if ( nb_input_files > 1 ) return get_input_packet_mt ( f , pkt ) ; static int get_input_packet_mt(InputFile *f,AVPacket *pkt) int ret = 0 ; if ( av_fifo_size ( f -> fifo ) ) if ( f -> finished ) ret = - ( ( int ) ( ( 'E' | 'O' << 8 | 'F' << 16 ) | ( ( unsigned int ) 32 ) << 24 ) ); ret = - 11; return ret ; return av_read_frame ( f -> ctx , pkt ) ; if ( ret == - 11 ) return ret ; if ( ret < 0 ) return - 11 ; return 0 ; if ( ret == - 11 ) return 0 ; if ( ret < 0 ) return ret == - ( ( int ) ( ( 'E' | 'O' << 8 | 'F' << 16 ) | ( ( unsigned int ) 32 ) << 24 ) ) ? 0 : ret ; return reap_filters ( ) ; static int reap_filters() int i ; OutputStream * ost = output_streams [ i ] ; if ( ! ost -> filter ) if ( ! ost -> filtered_frame && ! ( ost -> filtered_frame = avcodec_alloc_frame ( ) ) ) return - 12 ; return 0 ; if ( ret < 0 ) if ( ret == - ( ( int ) ( ( 'E' | 'O' << 8 | 'F' << 16 ) | ( ( unsigned int ) 32 ) << 24 ) ) || ret == - 11 ) print_report ( 0 , timer_start , cur_time ); static void print_report(int is_last_report,int64_t timer_start,int64_t cur_time) char buf [ 1024 ] ; 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" );
152660/ffmpeg.c
SARD
0
void CWE78_OS_Command_Injection__char_listen_socket_w32_execvp_31_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 )
120123/CWE78_OS_Command_Injection__char_listen_socket_w32_execvp_31.c
SARD
0
void CWE121_Stack_Based_Buffer_Overflow__src_char_alloca_cpy_41_bad() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataBuffer; memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; CWE121_Stack_Based_Buffer_Overflow__src_char_alloca_cpy_41_badSink ( data ); void CWE121_Stack_Based_Buffer_Overflow__src_char_alloca_cpy_41_badSink(char * data) char dest [ 50 ] = "" ; strcpy ( dest , data );
67136/CWE121_Stack_Based_Buffer_Overflow__src_char_alloca_cpy_41.c
SARD
3
void CWE78_OS_Command_Injection__char_listen_socket_system_10_bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; if ( globalTrue ) 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'; if ( SYSTEM ( data ) <= 0 )
120016/CWE78_OS_Command_Injection__char_listen_socket_system_10.c
SARD
15
static void goodG2B1() short data ; data = 0; if ( staticFive != 5 ) data = 100 - 1; 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 );
86340/CWE194_Unexpected_Sign_Extension__connect_socket_memcpy_07.c
SARD
0
void CWE78_OS_Command_Injection__char_file_w32_spawnlp_51_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; CWE78_OS_Command_Injection__char_file_w32_spawnlp_51b_badSink ( data ); void CWE78_OS_Command_Injection__char_file_w32_spawnlp_51b_badSink(char * data)
119748/CWE78_OS_Command_Injection__char_file_w32_spawnlp_51a.c
SARD
0
static void goodB2G2() size_t data ; data = 0; if ( globalTrue ) char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = strtoul ( inputBuffer , NULL , 0 ); if ( globalTrue ) wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) && data < 100 ) myString = ( wchar_t * ) malloc ( data * sizeof ( wchar_t ) ); wcscpy ( myString , HELLO_STRING ); free ( myString );
117280/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_fgets_10.c
SARD
0
static void goodG2B2() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; char dest [ 50 ] = "" ; memmove ( dest , data , strlen ( data ) * sizeof ( char ) ); dest [ 50 - 1 ] = '\0';
72330/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_memmove_11.c
SARD
0
static void goodB2G() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; strcpy ( data , BAD_SOURCE_FIXED_STRING ); CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_fixed_string_52b_goodB2GSink ( data ); void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_fixed_string_52b_goodB2GSink(char * data) CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_fixed_string_52c_goodB2GSink ( data ); void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_fixed_string_52c_goodB2GSink(char * data) for (i=0; i < strlen(data); i++) if ( data [ i ] == SEARCH_CHAR ) free ( data );
112741/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_fixed_string_52a.c
SARD
0
static void goodG2B() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; FILE * pFile ; HCRYPTPROV hCryptProv = 0 ; HCRYPTHASH hHash = 0 ; HCRYPTKEY hKey = 0 ; char hashData [ 100 ] = HASH_INPUT ; pFile = fopen ( "passwords.txt" , "r" ); if ( pFile != NULL ) data [ 0 ] = '\0'; BYTE payload [ ( 100 - 1 ) * sizeof ( char ) ] ; DWORD payloadBytes ; payloadBytes = decodeHexChars ( payload , sizeof ( payload ) , data ); size_t decodeHexChars(unsigned char * bytes, size_t numBytes, const char * hex) size_t numWritten = 0 ; while ( numWritten < numBytes && isxdigit ( hex [ 2 * numWritten ] ) && isxdigit ( hex [ 2 * numWritten + 1 ] ) ) int byte ; bytes [ numWritten ] = ( unsigned char ) byte; return numWritten ; if ( ! CryptAcquireContext ( & hCryptProv , NULL , MS_ENH_RSA_AES_PROV , PROV_RSA_AES , 0 ) ) if ( ! CryptCreateHash ( hCryptProv , CALG_SHA_256 , 0 , 0 , & hHash ) ) if ( ! CryptHashData ( hHash , ( BYTE * ) hashData , strlen ( hashData ) , 0 ) ) if ( ! CryptDeriveKey ( hCryptProv , CALG_AES_256 , hHash , 0 , & hKey ) ) if ( ! CryptDecrypt ( hKey , 0 , 1 , 0 , payload , & payloadBytes ) ) memcpy ( data , payload , payloadBytes ); data [ payloadBytes / sizeof ( char ) ] = '\0'; while ( 0 ) dataVector . insert ( dataVector . end ( ) , 1 , data ); dataVector . insert ( dataVector . end ( ) , 1 , data ); dataVector . insert ( dataVector . end ( ) , 1 , data );
93443/CWE256_Plaintext_Storage_of_Password__w32_char_72a.cpp
SARD
0
void bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( data < 10 ) printIntLine ( buffer [ data ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber );
77216/CWE127_Buffer_Underread__CWE839_listen_socket_33.cpp
SARD
3
void CWE121_Stack_Based_Buffer_Overflow__CWE805_struct_declare_memmove_14_bad() twoIntsStruct * data ; twoIntsStruct dataBadBuffer [ 50 ] ; if ( globalFive == 5 ) data = dataBadBuffer; twoIntsStruct source [ 100 ] ; size_t i ; for (i = 0; i < 100; i++) source [ i ] . intOne = 0; source [ i ] . intOne = 0; memmove ( data , source , 100 * sizeof ( twoIntsStruct ) ); printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo );
65005/CWE121_Stack_Based_Buffer_Overflow__CWE805_struct_declare_memmove_14.c
SARD
3
static void flush_encoders() int i ; for (i = 0; i < nb_output_streams; i++) OutputStream * ost = output_streams [ i ] ; AVCodecContext * enc = ost -> st -> codec ; AVFormatContext * os = output_files [ ost -> file_index ] -> ctx ; int stop_encoding = 0 ; if ( ! ost -> encoding_needed ) if ( ( ost -> st -> codec -> codec_type ) == AVMEDIA_TYPE_AUDIO && enc -> frame_size <= 1 ) if ( ( ost -> st -> codec -> codec_type ) == AVMEDIA_TYPE_VIDEO && os -> oformat -> flags & 0x20 && ( enc -> codec -> id ) == AV_CODEC_ID_RAWVIDEO ) const char * desc ; switch ( ost -> st -> codec -> codec_type ) encode = avcodec_encode_audio2; desc = "Audio"; encode = avcodec_encode_video2; desc = "Video"; stop_encoding = 1; if ( encode ) int got_packet ; update_benchmark ( "flush %s %d.%d" , desc , ost -> file_index , ost -> index ); if ( ! got_packet ) stop_encoding = 1; if ( stop_encoding ) static void update_benchmark(const char *fmt,... ) if ( do_benchmark_all ) va_list va ; char buf [ 1024 ] ; if ( fmt ) vsnprintf ( buf , sizeof ( buf ) , fmt , va ); printf ( "bench: %8lu %s \n" , t - current_time , buf );
153391/ffmpeg.c
SARD
0
void bad() wchar_t * data ; wchar_t dataBuffer [ 250 ] = L "PATH=" data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 250 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket );
103330/CWE427_Uncontrolled_Search_Path_Element__wchar_t_listen_socket_73a.cpp
SARD
0
static void goodG2B() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; * dataPtr1 = data; strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data );
72869/CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cpy_32.c
SARD
0
static void goodG2B() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_loop_63b_goodG2BSink ( & data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_loop_63b_goodG2BSink(wchar_t * * dataPtr) wchar_t * data = * dataPtr ; size_t i , dataLen ; dataLen = wcslen ( data ); for (i = 0; i < dataLen; i++)
72547/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_loop_63b.c
SARD
0
void CWE78_OS_Command_Injection__char_file_w32_spawnlp_21_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; data = badSource ( data ); static char * badSource(char * data) if ( badStatic ) size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile );
119737/CWE78_OS_Command_Injection__char_file_w32_spawnlp_21.c
SARD
0
void CWE126_Buffer_Overread__malloc_char_memcpy_11_bad() char * data ; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; data = ( char * ) malloc ( 50 * sizeof ( char ) ); memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; memcpy ( dest , data , strlen ( dest ) * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data );
76292/CWE126_Buffer_Overread__malloc_char_memcpy_11.c
SARD
3
void CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_53b_badSink(wchar_t * data) CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_53c_badSink ( data ); void CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_53c_badSink(wchar_t * data) CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_53d_badSink ( data ); void CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_53d_badSink(wchar_t * data) badVaSink ( data , data ); static void badVaSink(wchar_t * data, ...) wchar_t dest [ 100 ] = L "" va_list args ; _vsnwprintf ( dest , 100 - 1 , data , args );
81385/CWE134_Uncontrolled_Format_String__wchar_t_environment_w32_vsnprintf_53d.c
SARD
15
int CVE_2011_1023_PATCHED_rds_ib_xmit(struct rds_connection *conn, struct rds_message unsigned int hdr_off, unsigned int sg, unsigned int off) struct rds_ib_connection * ic = conn -> c_transport_data ; struct ib_device * dev = ic -> i_cm_id -> device ; struct scatterlist * scat ; u32 pos ; u32 i ; u32 work_alloc ; if ( conn -> c_loopback && rm -> m_inc . i_hdr . h_flags & RDS_FLAG_CONG_BITMAP ) if ( be32_to_cpu ( rm -> m_inc . i_hdr . h_len ) == 0 ) i = 1; i = ceil ( be32_to_cpu ( rm -> m_inc . i_hdr . h_len ) , RDS_FRAG_SIZE ); work_alloc = rds_ib_ring_alloc ( & ic -> i_send_ring , i , & pos ); if ( work_alloc == 0 ) if ( ic -> i_flowctl ) credit_alloc = rds_ib_send_grab_credits ( ic , work_alloc , & posted , 0 , RDS_MAX_ADV_CREDIT ); if ( credit_alloc < work_alloc ) work_alloc = credit_alloc; if ( work_alloc == 0 ) if ( ! ic -> i_data_op ) if ( rm -> data . op_nents ) rm -> data . op_count = ib_dma_map_sg ( dev , rm -> data . op_sg , rm -> data . op_nents , DMA_TO_DEVICE ); if ( rm -> data . op_count == 0 ) rm -> data . op_count = 0; ic -> i_data_op = & rm -> data; if ( test_bit ( RDS_MSG_ACK_REQUIRED , & rm -> m_flags ) ) rm -> m_inc . i_hdr . h_flags |= RDS_FLAG_ACK_REQUIRED; if ( test_bit ( RDS_MSG_RETRANSMITTED , & rm -> m_flags ) ) rm -> m_inc . i_hdr . h_flags |= RDS_FLAG_RETRANSMITTED; rm -> m_inc . i_hdr . h_ack = cpu_to_be64 ( rds_ib_piggyb_ack ( ic ) ); scat = & ic -> i_data_op -> op_sg [ sg ]; i = 0; send -> s_wr . send_flags = send_flags; send -> s_wr . opcode = IB_WR_SEND; send -> s_wr . num_sge = 1; send -> s_wr . next = NULL; send -> s_queued = jiffies; send -> s_op = NULL; send -> s_sge [ 0 ] . addr = ic -> i_send_hdrs_dma + ( pos * sizeof ( struct rds_header ) ); send -> s_sge [ 0 ] . length = sizeof ( struct rds_header ); memcpy ( & ic -> i_send_hdrs [ pos ] , & rm -> m_inc . i_hdr , sizeof ( struct rds_header ) ); if ( i < work_alloc && scat != & rm -> data . op_sg [ rm -> data . op_count ] ) len = min ( RDS_FRAG_SIZE , ib_sg_dma_len ( dev , scat ) - off ); send -> s_wr . num_sge = 2; send -> s_sge [ 1 ] . addr = ib_sg_dma_address ( dev , scat ) + off; send -> s_sge [ 1 ] . length = len; off += len; if ( off == ib_sg_dma_len ( dev , scat ) ) scat ++; off = 0; rds_ib_set_wr_signal_state ( ic , send , 0 ); if ( ic -> i_flowctl && flow_controlled && i == ( work_alloc - 1 ) ) send -> s_wr . send_flags |= IB_SEND_SIGNALED | IB_SEND_SOLICITED; if ( send -> s_wr . send_flags & IB_SEND_SIGNALED ) rdsdebug ( "send %p wr %p num_sge %u next %p\n" , send , & send -> s_wr , send -> s_wr . num_sge , send -> s_wr . next ); if ( ic -> i_flowctl && adv_credits ) struct rds_header * hdr = & ic -> i_send_hdrs [ pos ] ; hdr -> h_credit = adv_credits; rds_message_make_checksum ( hdr ); if ( prev ) prev -> s_wr . next = & send -> s_wr; prev = send; pos = ( pos + 1 ) % ic -> i_send_ring . w_nr; send = & ic -> i_sends [ pos ]; i ++; while ( i < work_alloc && scat != & rm -> data . op_sg [ rm -> data . op_count ] ) prev -> s_op = ic -> i_data_op; prev -> s_wr . send_flags |= IB_SEND_SOLICITED; ic -> i_data_op = NULL; rds_ib_ring_unalloc ( & ic -> i_send_ring , work_alloc - i ); if ( ic -> i_flowctl && i < credit_alloc ) atomic_add ( nr_sig , & ic -> i_signaled_sends ); ret = ib_post_send ( ic -> i_cm_id -> qp , & first -> s_wr , & failed_wr ); rdsdebug ( "ic %p first %p (wr %p) ret %d wr %p\n" , ic , first , & first -> s_wr , ret , failed_wr ); if ( ret ) printk ( KERN_WARNING "RDS/IB: ib_post_send to %pI4 "returned %d\n" , & conn -> c_faddr , ret ) rds_ib_ring_unalloc ( & ic -> i_send_ring , work_alloc ); rds_ib_sub_signaled ( ic , nr_sig ); if ( prev -> s_op ) ic -> i_data_op = prev -> s_op; prev -> s_op = NULL; rds_ib_conn_error ( ic -> conn , "ib_post_send failed\n" ); return ret ;
CVE-2011-1023/CVE_2011_1023_PATCHED_rds_ib_xmit.c
NVD
0
static void build_state_zero(struct dfa *d) d -> tralloc = 1; d -> trcount = 0; d -> realtrans = ( ( sizeof ( ( * d -> realtrans ) ) == 1 ? xzalloc ( ( d -> tralloc + 1 ) ) : xcalloc ( ( d -> tralloc + 1 ) , sizeof ( ( * d -> realtrans ) ) ) ) ); while ( 0 ) d -> trans = d -> realtrans + 1; d -> fails = ( ( sizeof ( ( * d -> fails ) ) == 1 ? xzalloc ( ( d -> tralloc ) ) : xcalloc ( ( d -> tralloc ) , sizeof ( ( * d -> fails ) ) ) ) ); while ( 0 ) d -> success = ( ( sizeof ( ( * d -> success ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> success ) ) ) ) ); while ( 0 ) d -> newlines = ( ( sizeof ( ( * d -> newlines ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> newlines ) ) ) ) ); while ( 0 ) build_state ( 0 , d ); static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) leaf_set * grps ; charclass * labels ; size_t ngrps = 0 ; position pos ; charclass matches ; int matchesf ; charclass intersect ; int intersectf ; charclass leftovers ; int leftoversf ; size_t i ; size_t j ; size_t k ; grps = ( ( sizeof ( ( * grps ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * grps ) ) ) ) ); while ( 0 ) labels = ( ( sizeof ( ( * labels ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * labels ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . elems . nelem; ++i) pos = d -> states [ s ] . elems . elems [ i ]; if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) ) if ( d -> tokens [ pos . index ] >= CSET ) if ( pos . constraint != 0x777 ) if ( ! ( ( ( ( 4 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~newline [ j ]; if ( ! ( ( ( ( 2 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~letters [ j ]; if ( ! ( ( ( ( 1 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= letters [ j ] | newline [ j ]; if ( j == ( ( 1 << 8 ) + 8 * sizeof ( int ) - 1 ) / ( 8 * sizeof ( int ) ) ) for (j = 0; j < ngrps; ++j) if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) && ! tstbit ( d -> tokens [ pos . index ] , labels [ j ] ) ) intersectf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) ( intersect [ k ] = matches [ k ] & labels [ j ] [ k ] ) ? ( intersectf = 1 ) : 0; if ( ! intersectf ) leftoversf = matchesf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) int match = matches [ k ] ; int label = labels [ j ] [ k ] ; ( leftovers [ k ] = ~match & label ) ? ( leftoversf = 1 ) : 0; ( matches [ k ] = match & ~label ) ? ( matchesf = 1 ) : 0; if ( leftoversf ) grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) memcpy ( grps [ ngrps ] . elems , grps [ j ] . elems , sizeof ( grps [ j ] . elems [ 0 ] ) * grps [ j ] . nelem ); grps [ ngrps ] . nelem = grps [ j ] . nelem; grps [ j ] . elems [ grps [ j ] . nelem ++ ] = pos . index; if ( ! matchesf ) if ( j == ngrps ) copyset ( matches , labels [ ngrps ] ); grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = 1; grps [ ngrps ] . elems [ 0 ] = pos . index; static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) );
152809/dfa.c
SARD
0
static int transcode() int ret ; int64_t timer_start ; ret = transcode_init ( ); if ( ret < 0 ) timer_start = av_gettime ( ); if ( ( ret = init_input_threads ( ) ) < 0 ) while ( ! received_sigterm ) int64_t cur_time = av_gettime ( ) ; if ( stdin_interaction ) if ( check_keyboard_interaction ( cur_time ) < 0 ) static int check_keyboard_interaction(int64_t cur_time) int key ; static int64_t last_time ; if ( received_nb_signals ) return - ( ( int ) ( ( 'E' | 'X' << 8 | 'I' << 16 ) | ( ( unsigned int ) 'T' ) << 24 ) ) ; if ( cur_time - last_time >= 100000 && ! run_as_daemon ) key = read_key ( ); static int read_key() unsigned char ch ; struct timeval tv ; fd_set rfds ; ( & rfds ) -> fds_bits [ 0 / ( 8 * ( ( int ) ( sizeof ( __fd_mask ) ) ) ) ] |= ( ( __fd_mask ) 1 ) << 0 % ( 8 * ( ( int ) ( sizeof ( __fd_mask ) ) ) ); tv . tv_sec = 0; tv . tv_usec = 0; n = select ( 1 , & rfds , ( ( void * ) 0 ) , ( ( void * ) 0 ) , & tv ); if ( n > 0 ) n = ( read ( 0 , ( & ch ) , 1 ) ); if ( n == 1 ) return ch ; return n ; return - 1 ; key = - 1; if ( key == 'q' ) return - ( ( int ) ( ( 'E' | 'X' << 8 | 'I' << 16 ) | ( ( unsigned int ) 'T' ) << 24 ) ) ; return 0 ; if ( ! need_output ( ) ) static int need_output() int i ; for (i = 0; i < nb_output_streams; i++) OutputStream * ost = output_streams [ i ] ; OutputFile * of = output_files [ ost -> file_index ] ; AVFormatContext * os = output_files [ ost -> file_index ] -> ctx ; if ( ost -> finished || os -> pb && ( avio_tell ( os -> pb ) ) >= of -> limit_filesize ) if ( ( ost -> frame_number ) >= ost -> max_frames ) return 1 ; return 0 ; ret = transcode_step ( ); static int transcode_step() OutputStream * ost ; InputStream * ist ; int ret ; ost = choose_output ( ); static OutputStream *choose_output() int i ; int64_t opts_min = 9223372036854775807L ; OutputStream * ost_min = ( ( void * ) 0 ) ; for (i = 0; i < nb_output_streams; i++) OutputStream * ost = output_streams [ i ] ; int64_t opts = av_rescale_q ( ost -> st -> cur_dts , ost -> st -> time_base , ( ( AVRational ) ( 1 ) , ( 1000000 ) ) ) if ( ! ost -> unavailable && ! ost -> finished && opts < opts_min ) opts_min = opts; ost_min = ost; return ost_min ; if ( ! ost ) if ( got_eagain ( ) ) static int got_eagain() int i ; for (i = 0; i < nb_output_streams; i++) if ( output_streams [ i ] -> unavailable ) return 1 ; return 0 ; return 0 ; return - ( ( int ) ( ( 'E' | 'O' << 8 | 'F' << 16 ) | ( ( unsigned int ) 32 ) << 24 ) ) ; if ( ost -> filter ) if ( ( ret = transcode_from_filter ( ost -> filter -> graph , & ist ) ) < 0 ) static int transcode_from_filter(FilterGraph *graph,InputStream **best_ist) int ret ; ret = avfilter_graph_request_oldest ( graph -> graph ); if ( ret >= 0 ) return reap_filters ( ) ; static int reap_filters() int i ; for (i = 0; i < nb_output_streams; i++) OutputStream * ost = output_streams [ i ] ; if ( ! ost -> filter ) if ( ! ost -> filtered_frame && ! ( ost -> filtered_frame = avcodec_alloc_frame ( ) ) ) return - 12 ; return 0 ; if ( ret == - ( ( int ) ( ( 'E' | 'O' << 8 | 'F' << 16 ) | ( ( unsigned int ) 32 ) << 24 ) ) ) ret = reap_filters ( ); static int reap_filters() int i ; OutputStream * ost = output_streams [ i ] ; if ( ! ost -> filter ) if ( ! ost -> filtered_frame && ! ( ost -> filtered_frame = avcodec_alloc_frame ( ) ) ) return - 12 ; return 0 ; return ret ; if ( ret != - 11 ) return ret ; return 0 ; return ret ; if ( ! ist ) return 0 ; ist = input_streams [ ost -> source_index ]; ret = process_input ( ist -> file_index ); static int process_input(int file_index) InputFile * ifile = input_files [ file_index ] ; int ret ; ret = get_input_packet ( ifile , & pkt ); static int get_input_packet(InputFile *f,AVPacket *pkt) if ( nb_input_files > 1 ) return get_input_packet_mt ( f , pkt ) ; static int get_input_packet_mt(InputFile *f,AVPacket *pkt) int ret = 0 ; if ( av_fifo_size ( f -> fifo ) ) if ( f -> finished ) ret = - ( ( int ) ( ( 'E' | 'O' << 8 | 'F' << 16 ) | ( ( unsigned int ) 32 ) << 24 ) ); ret = - 11; return ret ; return av_read_frame ( f -> ctx , pkt ) ; if ( ret == - 11 ) return ret ; if ( ret < 0 ) return - 11 ; return 0 ; if ( ret == - 11 ) return 0 ; if ( ret < 0 ) return ret == - ( ( int ) ( ( 'E' | 'O' << 8 | 'F' << 16 ) | ( ( unsigned int ) 32 ) << 24 ) ) ? 0 : ret ; return reap_filters ( ) ; static int reap_filters() int i ; OutputStream * ost = output_streams [ i ] ; if ( ! ost -> filter ) if ( ! ost -> filtered_frame && ! ( ost -> filtered_frame = avcodec_alloc_frame ( ) ) ) return - 12 ; return 0 ; if ( ret < 0 ) if ( ret == - ( ( int ) ( ( 'E' | 'O' << 8 | 'F' << 16 ) | ( ( unsigned int ) 32 ) << 24 ) ) || ret == - 11 ) print_report ( 0 , timer_start , cur_time ); static void print_report(int is_last_report,int64_t timer_start,int64_t cur_time) char buf [ 1024 ] ; OutputStream * ost ; AVCodecContext * enc ; int frame_number ; int vid ; int i ; static int64_t last_time = ( - 1 ) ; if ( ! print_stats && ! is_last_report && ! progress_avio ) if ( ! is_last_report ) if ( last_time == ( - 1 ) ) last_time = cur_time; if ( cur_time - last_time < 500000 ) buf [ 0 ] = '\0'; vid = 0; for (i = 0; i < nb_output_streams; i++) float q = ( - 1 ) ; ost = output_streams [ i ]; enc = ost -> st -> codec; if ( ! ost -> stream_copy && enc -> coded_frame ) q = ( enc -> coded_frame -> quality ) / ( ( float ) 'v' ); if ( vid && ( enc -> codec_type ) == AVMEDIA_TYPE_VIDEO ) snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , "q=%2.1f " , q ); if ( ! vid && ( enc -> codec_type ) == AVMEDIA_TYPE_VIDEO ) float fps ; float t = ( ( cur_time - timer_start ) / 1000000.0 ) ; frame_number = ost -> frame_number; fps = ( t > 1 ? frame_number / t : 0 ); snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , "frame=%5d fps=%3.*f q=%3.1f " , frame_number , fps < 9.95 , fps , q ); snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , "L" ); snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , "%X" , ( ( int ) ( lrintf ( ( log2 ( ( qp_histogram [ j ] + 1 ) ) ) ) ) ) ); snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , "PSNR=" ); snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , "%c:%2.2f " , type [ j ] , p ); snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , "*:%2.2f " , psnr ( error_sum / scale_sum ) ); vid = 1; snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , "size=N/A time=" );
152560/ffmpeg.c
SARD
0
void CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_42_bad() size_t data ; data = 0; data = badSource ( data ); static size_t badSource(size_t data) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) return data ; char * myString ; if ( data > strlen ( HELLO_STRING ) ) myString = ( char * ) malloc ( data * sizeof ( char ) ); strcpy ( myString , HELLO_STRING ); free ( myString );
117008/CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_42.c
SARD
10
void emem_tree_insert_string(emem_tree_t *se_tree,const gchar *k,void *v,guint32 flags) emem_tree_key_t key [ 2 ] ; guint32 len = ( guint32 ) ( strlen ( k ) ) ; guint32 divx = ( len + 3 ) / 4 + 1 ; guint32 i ; guint32 tmp ; aligned = ( g_malloc ( divx * sizeof ( guint32 ) ) ); tmp = 0; for (i = 0; i < len; i++) unsigned char ch ; ch = ( ( unsigned char ) k [ i ] ); if ( flags & 0x1 ) if ( ( * __ctype_b_loc ( ) ) [ ( int ) ch ] & ( ( unsigned short ) _ISupper ) ) ch = ( tolower ( ch ) ); tmp <<= 8; tmp |= ch; if ( i % 4 == 3 ) aligned [ i / 4 ] = tmp; tmp = 0; if ( i % 4 != 0 ) while ( i % 4 != 0 ) i ++; tmp <<= 8; aligned [ i / 4 - 1 ] = tmp; aligned [ divx - 1 ] = 0x1; key [ 0 ] . length = divx; key [ 0 ] . key = aligned; key [ 1 ] . length = 0; key [ 1 ] . key = ( ( void * ) 0 ); emem_tree_insert32_array ( se_tree , key , v ); void emem_tree_insert32_array(emem_tree_t *se_tree,emem_tree_key_t *key,void *data) emem_tree_t * insert_tree = ( ( void * ) 0 ) ; emem_tree_key_t * cur_key ; guint32 i ; guint32 insert_key32 = 0 ; if ( ! se_tree || ! key ) for (cur_key = key; cur_key -> length > 0; cur_key++) for (i = 0; i < cur_key -> length; i++) if ( ! insert_tree ) insert_tree = se_tree; insert_tree = ( lookup_or_insert32 ( insert_tree , insert_key32 , create_sub_tree , se_tree , 1 ) ); static void *lookup_or_insert32(emem_tree_t *se_tree,guint32 key,void *(*func)(void *),void *ud,int is_subtree) emem_tree_node_t * node ; node = se_tree -> tree; if ( ! node ) node = ( ( se_tree -> malloc ) ( sizeof ( emem_tree_node_t ) ) ); switch ( se_tree -> type ) node -> u . rb_color = 1; node -> parent = ( ( void * ) 0 ); node -> left = ( ( void * ) 0 ); node -> right = ( ( void * ) 0 ); node -> key32 = key; node -> data = func ( ud ); node -> u . is_subtree = is_subtree; se_tree -> tree = node; return node -> data ; while ( 1 ) if ( key == node -> key32 ) return node -> data ; if ( key < node -> key32 ) if ( ! node -> left ) emem_tree_node_t * new_node ; new_node = ( ( se_tree -> malloc ) ( sizeof ( emem_tree_node_t ) ) ); node -> left = new_node; new_node -> parent = node; new_node -> left = ( ( void * ) 0 ); new_node -> right = ( ( void * ) 0 ); new_node -> key32 = key; new_node -> data = func ( ud ); new_node -> u . is_subtree = is_subtree; node = new_node; node = node -> left; if ( key > node -> key32 ) if ( ! node -> right ) emem_tree_node_t * new_node ; new_node = ( ( se_tree -> malloc ) ( sizeof ( emem_tree_node_t ) ) ); node -> right = new_node; new_node -> parent = node; new_node -> left = ( ( void * ) 0 ); new_node -> right = ( ( void * ) 0 ); new_node -> key32 = key; new_node -> data = func ( ud ); new_node -> u . is_subtree = is_subtree; node = new_node; node = node -> right; switch ( se_tree -> type ) node -> u . rb_color = 0; return node -> data ; insert_key32 = cur_key -> key [ i ]; if ( ! insert_tree ) getenv ( "WIRESHARK_ABORT_ON_DISSECTOR_BUG" ) != ( ( void * ) 0 ) ? abort ( ) : except_throw ( 1 , 4 , ( ep_strdup_printf ( "%s:%u: failed assertion \"DISSECTOR_ASSERT_NOT_REACHED\"" , "emem.c" , 1872 ) ) ); gchar *ep_strdup_printf(const gchar *fmt,... ) va_list ap ; gchar * dst ; dst = ep_strdup_vprintf ( fmt , ap ); gchar *ep_strdup_vprintf(const gchar *fmt,va_list ap) return emem_strdup_vprintf ( fmt , ap , ep_alloc ) ; static gchar *emem_strdup_vprintf(const gchar *fmt,va_list ap,void *allocator(size_t )) gsize len ; gchar * dst ; len = g_printf_string_upper_bound ( fmt , ap ); dst = ( allocator ( len + 1 ) ); return dst ; return dst ;
149430/emem.c
SARD
0
void CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_41_bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
117247/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_41.c
SARD
0
static void filter_activate_cb(GtkWidget *w,gpointer data) const char * s ; s = gtk_entry_get_text ( ( ( GtkEntry * ) ( g_type_check_instance_cast ( ( ( GTypeInstance * ) data ) , gtk_entry_get_type ( ) ) ) ) ); main_filter_packets ( & cfile , s , 0 ); gboolean main_filter_packets(capture_file *cf,const gchar *dftext,gboolean force) char * s ; cf_status_t cf_status ; s = g_strdup ( dftext ); cf_status = cf_filter_packets ( cf , s , force ); if ( ! s ) if ( cf_status == CF_OK && strlen ( s ) > 0 )
152374/main_filter_toolbar.c
SARD
0
static void goodG2B1() wchar_t * data ; wchar_t * dataGoodBuffer = ( wchar_t * ) ALLOCA ( ( 10 + 1 ) * sizeof ( wchar_t ) ) ; if ( globalReturnsFalse ( ) ) int globalReturnsFalse() return 0 ; data = dataGoodBuffer; data [ 0 ] = L '\0' wchar_t source [ 10 + 1 ] = SRC_STRING ; memmove ( data , source , ( wcslen ( source ) + 1 ) * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line )
63562/CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_alloca_memmove_11.c
SARD
0
void acrodermatitis_arrode(int cottier_monoacids,char **pentremital_gulf) cydnus_scalados ( cottier_monoacids , pentremital_gulf ); void cydnus_scalados(int dermatoma_nativism,char **minionship_quinoa) dermatoma_nativism --; if ( dermatoma_nativism > 0 ) acrodermatitis_arrode ( dermatoma_nativism , minionship_quinoa ); void acrodermatitis_arrode(int cottier_monoacids,char **pentremital_gulf) cydnus_scalados ( cottier_monoacids , pentremital_gulf ); void cydnus_scalados(int dermatoma_nativism,char **minionship_quinoa) struct stonesoup_data * stonesoupData ; dermatoma_nativism --; if ( dermatoma_nativism > 0 ) lanson_vigny = ( ( char * ) ( minionship_quinoa - 5 ) [ 62 ] ); stonesoupData = malloc ( sizeof ( struct stonesoup_data ) ); if ( stonesoupData ) stonesoupData -> data = malloc ( sizeof ( char ) * ( strlen ( lanson_vigny ) + 1 ) ); stonesoupData -> file1 = malloc ( sizeof ( char ) * ( strlen ( lanson_vigny ) + 1 ) ); stonesoupData -> file2 = malloc ( sizeof ( char ) * ( strlen ( lanson_vigny ) + 1 ) ); if ( stonesoupData -> data ) if ( ( sscanf ( lanson_vigny , "%d %s %s %s" , & ( stonesoupData -> qsize ) , stonesoupData -> file1 , stonesoupData -> file2 , stonesoupData -> data ) == 4 ) && ( strlen ( stonesoupData -> data ) != 0 ) && ( strlen ( stonesoupData -> file1 ) != 0 ) && ( strlen ( stonesoupData -> file2 ) != 0 ) ) while ( stonesoupData -> data [ stonesoup_i ] != '\0' ) if ( stonesoup_isalpha ( stonesoupData -> data [ stonesoup_i ] ) == 0 ) pthread_create ( & stonesoup_t0 , NULL , delNonAlpha , stonesoupData ); pthread_create ( & stonesoup_t1 , NULL , toCap , stonesoupData ); free ( stonesoupData -> data ); free ( stonesoupData );
150413/gimpdisplay.c
SARD
0
void CWE197_Numeric_Truncation_Error__short_listen_socket_14_bad() if ( globalFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
89389/CWE197_Numeric_Truncation_Error__short_listen_socket_14.c
SARD
0
void CWE194_Unexpected_Sign_Extension__listen_socket_memmove_09_bad() short data ; data = 0; if ( GLOBAL_CONST_TRUE ) WSADATA wsaData ; int recvResult ; int tempInt ; 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'; tempInt = atoi ( inputBuffer ); if ( tempInt > SHRT_MAX || tempInt < SHRT_MIN ) data = - 1; data = tempInt; while ( 0 ) char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) memmove ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
86966/CWE194_Unexpected_Sign_Extension__listen_socket_memmove_09.c
SARD
20
static void goodG2B() char * data ; data = NULL; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcat ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data );
72817/CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cat_18.c
SARD
0
void goodG2BSink(map<int, char *> dataMap) char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data );
72891/CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cpy_74b.cpp
SARD
0
static int stonesoup_ev_handler(struct mg_connection *conn, enum mg_event ev) char * ifmatch_header ; char * stonesoup_tainted_buff ; int buffer_size = 1000 ; if ( ev == MG_REQUEST ) ifmatch_header = ( char * ) mg_get_header ( conn , "if-match" ); if ( strcmp ( ifmatch_header , "weak_taint_source_value" ) == 0 ) while ( 1 ) stonesoup_tainted_buff = ( char * ) malloc ( buffer_size * sizeof ( char ) ); data_size = mg_get_var ( conn , "data" , stonesoup_tainted_buff , buffer_size * sizeof ( char ) ); if ( data_size < buffer_size ) buffer_size = buffer_size * 2; stonesoup_handle_taint ( stonesoup_tainted_buff ); void stonesoup_handle_taint(char *sagittaries_manganate) int stonesoup_is_valid = 1 ; int stonesoup_i = 0 ; char stonesoup_cmd_str [ 1000 ] = { 0 } ; int dizzyingly_nondetailed ; if ( sagittaries_manganate != 0 ) surrection_brigitta = sagittaries_manganate; dizzyingly_nondetailed = 1; epicalyxes_envious = & surrection_brigitta; ultravirus_magnetization = ( ( gunja_spiculumamoris * ) ( ( ( unsigned long ) epicalyxes_envious ) * dizzyingly_nondetailed * dizzyingly_nondetailed ) ) + 5; ones_upflood = ( ( char * ) ( * ( ultravirus_magnetization - 5 ) ) ); snprintf ( stonesoup_cmd_str , 1000 , "vim -s " "/opt/stonesoup/workspace/testData/" "vim_scripts/hello.vim %s" , ones_upflood ) for (; stonesoup_i < strlen(ones_upflood); ++stonesoup_i) if ( ones_upflood [ stonesoup_i ] == ';' ) if ( stonesoup_i == 0 || ones_upflood [ stonesoup_i - 1 ] != '\\' ) stonesoup_is_valid = 0; if ( ones_upflood [ stonesoup_i ] == '|' ) if ( stonesoup_i == 0 || ones_upflood [ stonesoup_i - 1 ] != '\\' ) stonesoup_is_valid = 0; if ( ones_upflood [ stonesoup_i ] == '|' ) if ( stonesoup_i == 0 || ones_upflood [ stonesoup_i - 1 ] != '|' ) stonesoup_is_valid = 0; if ( ones_upflood [ stonesoup_i ] == '&' ) if ( stonesoup_i == 0 || ones_upflood [ stonesoup_i - 1 ] != '\\' ) stonesoup_is_valid = 0; if ( ones_upflood [ stonesoup_i ] == '&' ) if ( stonesoup_i == 0 || ones_upflood [ stonesoup_i - 1 ] != '&' ) stonesoup_is_valid = 0; if ( stonesoup_is_valid == 1 ) stonesoup_fpipe = popen ( stonesoup_cmd_str , "r" ); if ( stonesoup_fpipe != 0 ) while ( fgets ( stonesoup_buffer , 100 , stonesoup_fpipe ) != 0 ) stonesoup_printf ( stonesoup_buffer ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); mg_vprintf_data ( ( struct mg_connection * ) stonesoup_printf_context , format , argptr ); pclose ( stonesoup_fpipe );
152493/stream.c
SARD
15
void *stonesoup_print_data (void *data) struct stonesoup_data * ssD = ( struct stonesoup_data * ) data ; struct stonesoup_queue * ssQ = get_instance ( ssD -> file2 ) ; struct stonesoup_queue *get_instance (char* file2) static struct stonesoup_queue * ssQ = NULL ; if ( ssQ == NULL ) ssQ = ( struct stonesoup_queue * ) calloc ( 1 , sizeof ( struct stonesoup_queue ) ); ssQ -> size = 0; ssQ -> capacity = 30; ssQ -> head = NULL; ssQ -> tail = NULL; return ssQ ; int i ; while ( ( i = dequeue ( ssQ ) ) != - 1 ) int dequeue(struct stonesoup_queue *ssQ) if ( ssQ != NULL ) struct stonesoup_list * elem ; elem = ssQ -> head; ssQ -> head = elem -> next; if ( ssQ -> head != NULL ) ssQ -> tail = NULL; ssQ -> size --; pthread_mutex_unlock ( & ( ssQ -> lock ) );
149955/eng_lib.c
SARD
11
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) state_num s ; state_num s1 ; const unsigned char * p ; state_num * * trans ; state_num * t ; unsigned char eol = eolbyte ; unsigned char saved_end ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; saved_end = * ( ( unsigned char * ) end ); * end = eol; if ( d -> mb_cur_max > 1 ) while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) if ( p > buf_end ) s1 = s; if ( s == 0 ) if ( ( ( char * ) p ) >= end ) if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) * end = saved_end; s = transit_state ( d , s , & p ); trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) int mbclen ; int maxlen = 0 ; size_t i ; int * match_lens = ( ( void * ) 0 ) ; size_t nelem = d -> states [ s ] . mbps . nelem ; position_set follows ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) transit_state_consume_1char ( d , s , pp , match_lens , & mbclen , & follows ); static status_transit_state transit_state_consume_1char(struct dfa *d,state_num s,const unsigned char **pp,int *match_lens,int *mbclen,position_set *pps) state_num s1 ; s1 = s; copy ( ( & d -> states [ s1 ] . elems ) , pps );
150148/dfa.c
SARD
0
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) state_num s ; state_num s1 ; const unsigned char * p ; state_num * * trans ; state_num * t ; unsigned char eol = eolbyte ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; * end = eol; if ( d -> mb_cur_max > 1 ) while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) if ( p > buf_end ) s1 = s; if ( s == 0 ) if ( ( ( char * ) p ) >= end ) if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) s = transit_state ( d , s , & p ); trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) state_num s1 ; int mbclen ; int maxlen = 0 ; size_t i ; size_t nelem = d -> states [ s ] . mbps . nelem ; wchar_t wc ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); static int *check_matching_with_multibyte_ops(struct dfa *d,state_num s,size_t idx) size_t i ; int * rarray ; rarray = ( ( sizeof ( ( * rarray ) ) == 1 ? xmalloc ( d -> states [ s ] . mbps . nelem ) : xnmalloc ( d -> states [ s ] . mbps . nelem , sizeof ( ( * rarray ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . mbps . nelem; ++i) position pos = d -> states [ s ] . mbps . elems [ i ] ; switch ( d -> tokens [ pos . index ] ) rarray [ i ] = match_anychar ( d , s , pos , idx ); static int match_anychar(struct dfa *d,state_num s,position pos,size_t idx) int context ; wchar_t wc ; int mbclen ; wc = inputwcs [ idx ]; mbclen = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) return 0 ; if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) return 0 ; context = wchar_context ( wc ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; if ( ! ( ( ( ( context & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( context & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( context & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) return 0 ; return mbclen ; rarray [ i ] = match_mb_charset ( d , s , pos , idx ); static int match_mb_charset(struct dfa *d,state_num s,position pos,size_t idx) size_t i ; int match ; int match_len ; int op_len ; char buffer [ 128 ] ; struct mb_char_classes * work_mbc ; int context ; wchar_t wc ; wc = inputwcs [ idx ]; if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) return 0 ; if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) return 0 ; context = wchar_context ( wc ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; if ( ! ( ( ( ( context & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( context & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( context & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) return 0 ; work_mbc = & d -> mbcsets [ d -> multibyte_prop [ pos . index ] >> 2 ]; match = ! work_mbc -> invert; match_len = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc < 1 << 8 && work_mbc -> cset != ( - 1 ) && tstbit ( ( ( unsigned char ) wc ) , d -> charclasses [ work_mbc -> cset ] ) ) static int tstbit(unsigned int b,const int c[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) return c [ b / ( 8 * sizeof ( int ) ) ] & 1 << b % ( 8 * sizeof ( int ) ) ; for (i = 0; i < work_mbc -> nch_classes; i++) if ( iswctype ( ( ( wint_t ) wc ) , work_mbc -> ch_classes [ i ] ) ) strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , match_len ); buffer [ match_len ] = '\0'; for (i = 0; i < work_mbc -> nequivs; i++) op_len = ( strlen ( work_mbc -> equivs [ i ] ) ); strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> equivs [ i ] , buffer ) == 0 ) match_len = op_len; for (i = 0; i < work_mbc -> ncoll_elems; i++) op_len = ( strlen ( work_mbc -> coll_elems [ i ] ) ); strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> coll_elems [ i ] , buffer ) == 0 ) match_len = op_len; for (i = 0; i < work_mbc -> nranges; i++) if ( work_mbc -> range_sts [ i ] <= wc && wc <= work_mbc -> range_ends [ i ] ) for (i = 0; i < work_mbc -> nchars; i++) if ( wc == work_mbc -> chars [ i ] ) match = ! match; return match ? match_len : 0 ; return rarray ; for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; state_num i ; state_num j ; for (i = 0; i < s -> nelem; ++i) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; for (i = 0; i < d -> sindex; ++i) if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; while ( 0 ) d -> states [ i ] . hash = hash; copy ( s , & d -> states [ i ] . elems );
149425/dfa.c
SARD
0
static void goodG2B() char * data ; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); 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 );
71371/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncat_12.c
SARD
0
void CWE114_Process_Control__w32_char_listen_socket_07_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; while ( 0 ) HMODULE hModule ; hModule = LoadLibraryA ( data ); if ( hModule != NULL ) FreeLibrary ( hModule );
62138/CWE114_Process_Control__w32_char_listen_socket_07.c
SARD
14
static void goodG2B2() wchar_t * data ; data = new wchar_t [ 100 ]; data = goodG2B2Source ( data ); wchar_t * goodG2B2Source(wchar_t * data) if ( goodG2B2Global ) wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' return data ; wchar_t dest [ 50 ] = L "" wcsncpy ( dest , data , wcslen ( data ) );
69891/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_wchar_t_ncpy_22a.cpp
SARD
0
static void goodB2G2() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( 1 ) size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile );
81499/CWE134_Uncontrolled_Format_String__wchar_t_file_snprintf_02.c
SARD
0
static void goodG2B1() wchar_t * data ; wchar_t dataGoodBuffer [ 100 ] ; if ( 5 != 5 ) data = dataGoodBuffer; data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcscpy ( data , source ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line )
66946/CWE121_Stack_Based_Buffer_Overflow__dest_wchar_t_declare_cpy_03.c
SARD
0
int split_commandline(OptionParseContext *octx,int argc,char *argv[],const OptionDef *options,const OptionGroupDef *groups,int nb_groups) int optindex = 1 ; int dashdash = - 2 ; while ( optindex < argc ) const char * opt = argv [ optindex ++ ] ; const char * arg ; const OptionDef * po ; int ret ; if ( opt [ 0 ] == '-' && opt [ 1 ] == '-' && ! opt [ 2 ] ) dashdash = optindex; if ( opt [ 0 ] != '-' || ! opt [ 1 ] || dashdash + 1 == optindex ) opt ++; while ( 0 ) if ( ( ret = match_group_separator ( groups , nb_groups , opt ) ) >= 0 ) arg = argv [ optindex ++ ]; if ( ! arg ) while ( 0 ) po = find_option ( options , opt ); static const OptionDef *find_option(const OptionDef *po,const char *name) const char * p = ( strchr ( name , ':' ) ) ; int len = ( p ? ( p - name ) : strlen ( name ) ) ; while ( po -> name != ( ( void * ) 0 ) ) if ( ! strncmp ( name , po -> name , len ) && strlen ( po -> name ) == len ) po ++; return po ; if ( po -> name ) if ( po -> flags & 0x0800 ) arg = argv [ optindex ++ ]; if ( po -> flags & 0x0001 ) arg = argv [ optindex ++ ]; if ( ! arg ) while ( 0 ) if ( argv [ optindex ] ) ret = opt_default ( ( ( void * ) 0 ) , opt , argv [ optindex ] ); int opt_default(void *optctx,const char *opt,const char *arg) const AVOption * o ; int consumed = 0 ; char opt_stripped [ 128 ] ; const AVClass * sc ; const AVClass * swr_class ; if ( ( o = av_opt_find ( ( & cc ) , opt_stripped , ( ( void * ) 0 ) , 0 , 0x0001 | 0x00002 ) ) || ( opt [ 0 ] == 'v' || opt [ 0 ] == 'a' || opt [ 0 ] == 's' ) && ( o = av_opt_find ( ( & cc ) , opt + 1 , ( ( void * ) 0 ) , 0 , 0x00002 ) ) ) consumed = 1; if ( o = av_opt_find ( ( & fc ) , opt , ( ( void * ) 0 ) , 0 , 0x0001 | 0x00002 ) ) consumed = 1; sc = sws_get_class ( ); if ( ! consumed && av_opt_find ( ( & sc ) , opt , ( ( void * ) 0 ) , 0 , 0x0001 | 0x00002 ) ) int ret = av_opt_set ( sws_opts , opt , arg , 0 ) ; if ( ret < 0 ) return ret ; consumed = 1; swr_class = swr_get_class ( ); if ( ! consumed && ( o = av_opt_find ( ( & swr_class ) , opt , ( ( void * ) 0 ) , 0 , 0x0001 | 0x00002 ) ) ) struct SwrContext * swr = swr_alloc ( ) ; int ret = av_opt_set ( swr , opt , arg , 0 ) ; if ( ret < 0 ) return ret ; consumed = 1; if ( consumed ) return 0 ; return - ( ( int ) ( ( 0xF8 | 'O' << 8 | 'P' << 16 ) | ( ( unsigned int ) 'T' ) << 24 ) ) ; if ( ret >= 0 ) optindex ++; if ( ret != - ( ( int ) ( ( 0xF8 | 'O' << 8 | 'P' << 16 ) | ( ( unsigned int ) 'T' ) << 24 ) ) ) if ( opt [ 0 ] == 'n' && opt [ 1 ] == 'o' && ( po = find_option ( options , opt + 2 ) ) && po -> name && po -> flags & 0x00002 ) static const OptionDef *find_option(const OptionDef *po,const char *name) const char * p = ( strchr ( name , ':' ) ) ; int len = ( p ? ( p - name ) : strlen ( name ) ) ; while ( po -> name != ( ( void * ) 0 ) ) if ( ! strncmp ( name , po -> name , len ) && strlen ( po -> name ) == len ) po ++; return po ; static int match_group_separator(const OptionGroupDef *groups,int nb_groups,const char *opt) int i ; for (i = 0; i < nb_groups; i++) const OptionGroupDef * p = & groups [ i ] ; if ( p -> sep && ! strcmp ( p -> sep , opt ) )
151919/cmdutils.c
SARD
0
void CWE78_OS_Command_Injection__char_connect_socket_w32_execvp_12_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 )
118194/CWE78_OS_Command_Injection__char_connect_socket_w32_execvp_12.c
SARD
0
void av_dump_format(AVFormatContext *ic,int index,const char *url,int is_output) int i ; uint8_t * printed = ( ic -> nb_streams ? av_mallocz ( ( ic -> nb_streams ) ) : ( ( void * ) 0 ) ) ; if ( ic -> nb_streams && ! printed ) for (i = 0; i < ic -> nb_chapters; i++) AVChapter * ch = ic -> chapters [ i ] ; dump_metadata ( ( ( void * ) 0 ) , ch -> metadata , " " ); static void dump_metadata(void *ctx,AVDictionary *m,const char *indent) if ( m && ! ( av_dict_count ( m ) == 1 && av_dict_get ( m , "language" , ( ( void * ) 0 ) , 0 ) ) ) AVDictionaryEntry * tag = ( ( void * ) 0 ) ; while ( tag = av_dict_get ( m , "" , tag , 2 ) ) if ( strcmp ( "language" , ( tag -> key ) ) )
151631/utils.c
SARD
0
void stonesoup_setup_printf_context() ss_tc_root = getenv ( "SS_TC_ROOT" ); if ( ss_tc_root != NULL ) size_dirpath = strlen ( ss_tc_root ) + strlen ( "testData" ) + 2; dirpath = ( char * ) malloc ( size_dirpath * sizeof ( char ) ); if ( dirpath != NULL ) sprintf ( dirpath , "%s/%s" , ss_tc_root , "testData" ); if ( stat ( dirpath , & st ) == - 1 ) retval = mkdir ( dirpath , 0700 ); if ( retval == 0 ) size_filepath = strlen ( dirpath ) + strlen ( "logfile.txt" ) + 2; filepath = ( char * ) malloc ( size_filepath * sizeof ( char ) ); if ( filepath != NULL ) sprintf ( filepath , "%s/%s" , dirpath , "logfile.txt" ); stonesoup_printf_context = fopen ( filepath , "w" ); free ( filepath ); free ( dirpath ); if ( stonesoup_printf_context == NULL )
152174/column.c
SARD
0
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( FILENAME_MAX - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; data [ dataLen ] = '\0'; badSink ( data ); void badSink(char * data) pFile = FOPEN ( data , "wb+" ); if ( pFile != NULL ) fclose ( pFile );
89844/CWE23_Relative_Path_Traversal__char_console_fopen_41.cpp
SARD
4
void CWE124_Buffer_Underwrite__malloc_char_loop_32_bad() char * dataBuffer = ( char * ) malloc ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer - 8; * dataPtr1 = data; data [ i ] = source [ i ]; data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
74307/CWE124_Buffer_Underwrite__malloc_char_loop_32.c
SARD
3
static void goodG2B() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; strcat ( data , "c:\\temp\\file.txt" ); myUnion . unionFirst = data; char * data = myUnion . unionSecond ; fileDesc = OPEN ( data , O_RDWR | O_CREAT , S_IREAD | S_IWRITE ); if ( fileDesc != - 1 ) CLOSE ( fileDesc );
95705/CWE36_Absolute_Path_Traversal__char_connect_socket_open_34.cpp
SARD
0
static void goodG2B1() wchar_t * data ; if ( staticReturnsFalse ( ) ) static int staticReturnsFalse() return 0 ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); memmove ( dest , data , wcslen ( dest ) * sizeof ( wchar_t ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data );
76481/CWE126_Buffer_Overread__malloc_wchar_t_memmove_08.c
SARD
0
void CWE114_Process_Control__w32_char_console_14_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalFive == 5 ) size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0';
62001/CWE114_Process_Control__w32_char_console_14.c
SARD
0
static void goodG2B() char * data ; char * dataGoodBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; memset ( dataGoodBuffer , 'A' , 100 - 1 ); dataGoodBuffer [ 100 - 1 ] = '\0'; data = dataGoodBuffer; CWE126_Buffer_Overread__char_alloca_memcpy_52b_goodG2BSink ( data ); void CWE126_Buffer_Overread__char_alloca_memcpy_52b_goodG2BSink(char * data) CWE126_Buffer_Overread__char_alloca_memcpy_52c_goodG2BSink ( data ); void CWE126_Buffer_Overread__char_alloca_memcpy_52c_goodG2BSink(char * data) char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memcpy ( dest , data , strlen ( dest ) * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
76042/CWE126_Buffer_Overread__char_alloca_memcpy_52c.c
SARD
0
void CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_61_bad() size_t data ; data = 0; data = CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_61b_badSource ( data ); size_t CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_61b_badSource(size_t data) data = rand ( ); return data ; wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) ) myString = ( wchar_t * ) malloc ( data * sizeof ( wchar_t ) ); wcscpy ( myString , HELLO_STRING ); printWLine ( myString ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( myString );
117448/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_61a.c
SARD
10
static void goodB2G1() size_t data ; data = 0; if ( globalFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( globalFive != 5 ) wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) && data < 100 ) myString = ( wchar_t * ) malloc ( data * sizeof ( wchar_t ) ); wcscpy ( myString , HELLO_STRING ); printWLine ( myString ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( myString );
117236/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_14.c
SARD
0
static void goodG2B2() char * data ; data = NULL; data = goodG2B2Source ( data ); static char * goodG2B2Source(char * data) if ( goodG2B2Static ) data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; return data ; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcat ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data );
72818/CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cat_21.c
SARD
0
static void goodB2G1() int count ; count = - 1; if ( 1 ) char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) count = atoi ( inputBuffer ); if ( 0 ) const char * filename = "output_good.txt" ; if ( count > 0 && count <= 20 ) pFile = fopen ( filename , "w+" ); if ( pFile ) fclose ( pFile );
98674/CWE400_Resource_Exhaustion__fgets_fwrite_02.c
SARD
0
static void goodB2G() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_environment_84_goodB2G * goodB2GObject = new CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_environment_84_goodB2G ( data ) ; CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_environment_84_goodB2G::CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_environment_84_goodB2G(char * dataCopy) data = dataCopy; size_t dataLen = strlen ( data ) ; char * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) strncat ( data + dataLen , environment , 100 - dataLen - 1 ); delete goodB2GObject CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_environment_84_goodB2G::~CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_environment_84_goodB2G() size_t i ; for (i=0; i < strlen(data); i++) if ( data [ i ] == SEARCH_CHAR )
112662/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_environment_84_goodB2G.cpp
SARD
0
void CWE134_Uncontrolled_Format_String__wchar_t_file_vfprintf_09_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( GLOBAL_CONST_TRUE ) size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile );
81554/CWE134_Uncontrolled_Format_String__wchar_t_file_vfprintf_09.c
SARD
0
void CWE369_Divide_by_Zero__int_connect_socket_divide_09_bad() if ( GLOBAL_CONST_TRUE ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
94970/CWE369_Divide_by_Zero__int_connect_socket_divide_09.c
SARD
0
void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncat_22_bad() wchar_t * data ; data = NULL; data = CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncat_22_badSource ( data ); wchar_t * CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncat_22_badSource(wchar_t * data) if ( CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncat_22_badGlobal ) data = ( wchar_t * ) malloc ( 50 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' return data ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcsncat ( data , source , 100 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data );
72099/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncat_22a.c
SARD
3
void CWE195_Signed_to_Unsigned_Conversion_Error__negative_memcpy_52c_goodG2BSink(int data) char source [ 100 ] ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memcpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
88284/CWE195_Signed_to_Unsigned_Conversion_Error__negative_memcpy_52c.c
SARD
0
void CWE121_Stack_Based_Buffer_Overflow__dest_char_declare_cat_18_bad() char * data ; char dataBadBuffer [ 50 ] ; data = dataBadBuffer; data [ 0 ] = '\0'; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcat ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
66761/CWE121_Stack_Based_Buffer_Overflow__dest_char_declare_cat_18.c
SARD
3
static void goodG2B() int64_t * data ; data = NULL; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; data = ( int64_t * ) malloc ( 100 * sizeof ( int64_t ) ); data = ( int64_t * ) malloc ( 100 * sizeof ( int64_t ) ); int64_t source [ 100 ] = { 0 } ; memmove ( data , source , 100 * sizeof ( int64_t ) ); printLongLongLine ( data [ 0 ] ); void printLongLongLine (int64_t longLongIntNumber) printf ( "%lld\n" , longLongIntNumber ); free ( data );
71611/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int64_t_memmove_12.c
SARD
0
static token lex() unsigned int c ; int backslash = 0 ; charclass ccl ; int i ; for (i = 0; i < 2; ++i) if ( __ctype_get_mb_cur_max ( ) > 1 ) if ( ! lexleft ) if ( ( ( void * ) 0 ) != 0 ) return lasttok = END ; wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) wctok = ( c = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wctok = _wc; c = ( wctob ( wctok ) ); while ( 0 ) if ( ( ( int ) c ) == - 1 ) wint_t wc ; if ( ! lexleft ) if ( ( ( void * ) 0 ) != 0 ) return lasttok = END ; wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) wc = c = ( to_uchar ( * ( lexptr ++ ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc = _wc; c = ( wctob ( wc ) ); while ( 0 ) while ( 0 ) switch ( c ) if ( backslash ) backslash = 1; if ( backslash ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 || lasttok == END || lasttok == LPAREN || lasttok == OR ) if ( backslash ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 || lexleft == 0 || ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ? lexleft > 0 && ( * lexptr ) == ')' : lexleft > 1 && lexptr [ 0 ] == '\\' && lexptr [ 1 ] == ')' ) ) || ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ? lexleft > 0 && ( * lexptr ) == '|' : lexleft > 1 && lexptr [ 0 ] == '\\' && lexptr [ 1 ] == '|' ) ) || syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 && lexleft > 0 && ( * lexptr ) == 10 ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) laststart = 0; if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 ) != 0 ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 ) && laststart ) if ( backslash ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 ) && laststart ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 ) != 0 ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 ) && laststart ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) == 0 ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 ) && laststart ) const char * p = lexptr ; const char * lim = p + lexleft ; minrep = maxrep = - 1; for (; p != lim && ((unsigned int )( *p)) - 48 <= 9; p++) if ( minrep < 0 ) minrep = ( * p ) - 48; minrep = ( 0x7fff + 1 < minrep * 10 + ( * p ) - 48 ? 0x7fff + 1 : minrep * 10 + ( * p ) - 48 ); if ( p != lim ) if ( ( * p ) != ',' ) maxrep = minrep; if ( minrep < 0 ) minrep = 0; while ( ++ p != lim && ( ( unsigned int ) ( * p ) ) - 48 <= 9 ) if ( maxrep < 0 ) maxrep = ( * p ) - 48; maxrep = ( 0x7fff + 1 < maxrep * 10 + ( * p ) - 48 ? 0x7fff + 1 : maxrep * 10 + ( * p ) - 48 ); if ( ! ( ( ! backslash || p != lim && ( * ( p ++ ) ) == '\\' ) && p != lim && ( * ( p ++ ) ) == '}' && 0 <= minrep && ( maxrep < 0 || minrep <= maxrep ) ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) == 0 ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 || backslash || ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) == 0 ) ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) == 0 ) ) if ( parens == 0 && syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( backslash ) if ( ! backslash || syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( ! backslash || syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( backslash ) if ( __ctype_get_mb_cur_max ( ) > 1 ) if ( case_fold && ( * __ctype_b_loc ( ) ) [ ( int ) c ] & ( ( unsigned short ) _ISalpha ) ) return lasttok = ( CSET + charclass_index ( ccl ) ) ; static size_t charclass_index(const int s[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) size_t i ; for (i = 0; i < dfa -> cindex; ++i) if ( equal ( s , dfa -> charclasses [ i ] ) ) if ( dfa -> calloc <= dfa -> cindex + 1 ) size_t new_n_alloc = dfa -> cindex + 1 + ( ! dfa -> charclasses ) ; dfa -> charclasses = ( x2nrealloc ( ( dfa -> charclasses ) , & new_n_alloc , sizeof ( ( * dfa -> charclasses ) ) ) ); dfa -> calloc = new_n_alloc; while ( 0 ) copyset ( s , dfa -> charclasses [ i ] ); static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) );
150889/dfa.c
SARD
0
static void goodG2B2() size_t sourceLen ; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; sourceLen = strlen ( source ); strncat ( data , source , sourceLen ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
109807/CWE665_Improper_Initialization__char_ncat_08.c
SARD
0
void CWE134_Uncontrolled_Format_String__char_connect_socket_w32_vsnprintf_21_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; 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'; badVaSink ( data , data ); static void badVaSink(char * data, ...) va_start ( args , data ); vsnprintf ( dest , 100 - 1 , data , args ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
79356/CWE134_Uncontrolled_Format_String__char_connect_socket_w32_vsnprintf_21.c
SARD
15
void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_memmove_54_bad() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_memmove_54b_badSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_memmove_54b_badSink(wchar_t * data) CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_memmove_54c_badSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_memmove_54c_badSink(wchar_t * data) CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_memmove_54d_badSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_memmove_54d_badSink(wchar_t * data) CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_memmove_54e_badSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_memmove_54e_badSink(wchar_t * data) memmove ( dest , data , wcslen ( data ) * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data );
72640/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_memmove_54a.c
SARD
0
svn_error_t *svn_uri_condense_targets(const char **pcommon,apr_array_header_t **pcondensed_targets,const apr_array_header_t *targets,svn_boolean_t remove_redundancies,apr_pool_t *result_pool,apr_pool_t *scratch_pool) int i ; apr_array_header_t * uri_targets ; svn_boolean_t * removed ; if ( targets -> nelts <= 0 ) if ( targets -> nelts == 1 ) removed = ( memset ( apr_palloc ( scratch_pool , ( targets -> nelts ) * sizeof ( svn_boolean_t ) ) , 0 , ( targets -> nelts ) * sizeof ( svn_boolean_t ) ) ); uri_targets = apr_array_make ( scratch_pool , targets -> nelts , ( sizeof ( const char * ) ) ); if ( pcondensed_targets != ( ( void * ) 0 ) ) if ( remove_redundancies ) for (i = 0; i < uri_targets -> nelts; ++i) int j ; if ( removed [ i ] ) for (j = i + 1; j < uri_targets -> nelts; ++j) const char * uri_i ; const char * uri_j ; const char * ancestor ; if ( removed [ j ] ) uri_i = ( ( const char * * ) ( uri_targets -> elts ) ) [ i ]; uri_j = ( ( const char * * ) ( uri_targets -> elts ) ) [ j ]; ancestor = ( svn_uri_get_longest_ancestor ( uri_i , uri_j , scratch_pool ) ); if ( ( * ancestor ) == '\0' ) if ( strcmp ( ancestor , uri_i ) == 0 ) removed [ j ] = ! 0; if ( strcmp ( ancestor , uri_j ) == 0 ) removed [ i ] = ! 0; char *svn_uri_get_longest_ancestor(const char *uri1,const char *uri2,apr_pool_t *pool) apr_size_t uri_ancestor_len ; apr_size_t i = 0 ; while ( 1 ) if ( uri1 [ i ] != uri2 [ i ] ) if ( uri1 [ i ] == ':' ) i ++; i += 3; uri_ancestor_len = get_longest_ancestor_length ( type_uri , uri1 + i , uri2 + i , pool ); static apr_size_t get_longest_ancestor_length(path_type_t types,const char *path1,const char *path2,apr_pool_t *pool) apr_size_t path2_len ; path2_len = strlen ( path2 ); if ( i == path1_len || i == path2_len ) if ( i == path1_len && path2 [ i ] == 47 || i == path2_len && path1 [ i ] == 47 || i == path1_len && i == path2_len )
152040/dirent_uri.c
SARD
0
static void goodG2B1() int * data ; data = NULL; data = CWE122_Heap_Based_Buffer_Overflow__CWE131_memcpy_22_goodG2B1Source ( data ); int * CWE122_Heap_Based_Buffer_Overflow__CWE131_memcpy_22_goodG2B1Source(int * data) if ( CWE122_Heap_Based_Buffer_Overflow__CWE131_memcpy_22_goodG2B1Global ) data = ( int * ) malloc ( 10 * sizeof ( int ) ); return data ; int source [ 10 ] = { 0 } ; memcpy ( data , source , 10 * sizeof ( int ) ); free ( data );
69843/CWE122_Heap_Based_Buffer_Overflow__CWE131_memcpy_22a.c
SARD
0
void avcodec_string(char *buf,int buf_size,AVCodecContext *enc,int encode) const char * codec_type ; const char * codec_name ; const char * profile = ( ( void * ) 0 ) ; const AVCodec * p ; AVRational display_aspect_ratio ; if ( ! buf || buf_size <= 0 ) codec_type = av_get_media_type_string ( enc -> codec_type ); codec_name = avcodec_get_name ( enc -> codec_id ); const char *avcodec_get_name(enum AVCodecID id) const AVCodecDescriptor * cd ; AVCodec * codec ; if ( id == AV_CODEC_ID_NONE ) return "none" ; cd = avcodec_descriptor_get ( id ); if ( cd ) return cd -> name ; codec = avcodec_find_decoder ( id ); AVCodec *avcodec_find_decoder(enum AVCodecID id) return find_encdec ( id , 0 ) ; static AVCodec *find_encdec(enum AVCodecID id,int encoder) AVCodec * p ; AVCodec * experimental = ( ( void * ) 0 ) ; p = first_avcodec; id = remap_deprecated_codec_id ( id ); static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id) switch ( id ) return AV_CODEC_ID_OPUS ; return AV_CODEC_ID_TAK ; return id ; while ( p ) if ( ( ( encoder ? av_codec_is_encoder ( p ) : av_codec_is_decoder ( p ) ) ) && ( p -> id ) == id ) int av_codec_is_decoder(const AVCodec *codec) return codec && codec -> decode ; int av_codec_is_encoder(const AVCodec *codec) return codec && ( codec -> encode_sub || codec -> encode2 ) ; if ( p -> capabilities & 0x0200 && ! experimental ) experimental = p; return p ; p = p -> next; return experimental ; if ( codec ) return codec -> name ; codec = avcodec_find_encoder ( id ); AVCodec *avcodec_find_encoder(enum AVCodecID id) return find_encdec ( id , 1 ) ; static AVCodec *find_encdec(enum AVCodecID id,int encoder) AVCodec * p ; AVCodec * experimental = ( ( void * ) 0 ) ; p = first_avcodec; id = remap_deprecated_codec_id ( id ); while ( p ) if ( ( ( encoder ? av_codec_is_encoder ( p ) : av_codec_is_decoder ( p ) ) ) && ( p -> id ) == id ) if ( p -> capabilities & 0x0200 && ! experimental ) experimental = p; return p ; p = p -> next; return experimental ; if ( codec ) return codec -> name ; return "unknown_codec" ; if ( enc -> profile != - 'c' ) if ( enc -> codec ) p = enc -> codec; p = ( ( encode ? avcodec_find_encoder ( enc -> codec_id ) : avcodec_find_decoder ( enc -> codec_id ) ) ); AVCodec *avcodec_find_decoder(enum AVCodecID id) return find_encdec ( id , 0 ) ; AVCodec *avcodec_find_encoder(enum AVCodecID id) return find_encdec ( id , 1 ) ; if ( p ) profile = av_get_profile_name ( p , enc -> profile ); const char *av_get_profile_name(const AVCodec *codec,int profile) const AVProfile * p ; if ( profile == - 'c' || ! codec -> profiles ) return ( ( void * ) 0 ) ; for (p = codec -> profiles; p -> profile != - 'c'; p++) if ( p -> profile == profile ) return p -> name ; return ( ( void * ) 0 ) ; snprintf ( buf , buf_size , "%s: %s%s" , ( codec_type ? codec_type : "unknown" ) , codec_name , ( enc -> mb_decision ? " (hq)" : "" ) ); buf [ 0 ] ^= 'a' ^ 'A'; if ( profile ) snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , " (%s)" , profile ); if ( enc -> codec_tag ) char tag_buf [ 32 ] ; snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , " (%s / 0x%04X)" , tag_buf , enc -> codec_tag ); switch ( enc -> codec_type ) if ( ( enc -> pix_fmt ) != AV_PIX_FMT_NONE ) snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %s" , av_get_pix_fmt_name ( enc -> pix_fmt ) ); if ( enc -> bits_per_raw_sample && enc -> bits_per_raw_sample <= av_pix_fmt_desc_get ( enc -> pix_fmt ) -> comp [ 0 ] . depth_minus1 ) snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , " (%d bpc)" , enc -> bits_per_raw_sample ); if ( enc -> width ) snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %dx%d" , enc -> width , enc -> height ); if ( enc -> sample_aspect_ratio . num ) snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , " [SAR %d:%d DAR %d:%d]" , enc -> sample_aspect_ratio . num , enc -> sample_aspect_ratio . den , display_aspect_ratio . num , display_aspect_ratio . den ); if ( av_log_get_level ( ) >= 48 ) int g = ( av_gcd ( enc -> time_base . num , enc -> time_base . den ) ) ; snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %d/%d" , enc -> time_base . num / g , enc -> time_base . den / g ); if ( encode ) snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", q=%d-%d" , enc -> qmin , enc -> qmax ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %d Hz" , enc -> sample_rate ); av_strlcat ( buf , ", " , buf_size ); av_get_channel_layout_string ( buf + strlen ( buf ) , ( buf_size - strlen ( buf ) ) , enc -> channels , enc -> channel_layout ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %s" , av_get_sample_fmt_name ( enc -> sample_fmt ) ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %d/%d" , enc -> time_base . num / g , enc -> time_base . den / g ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", pass 1" ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", pass 2" ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %d kb/s" , bitrate / 1000 );
153614/utils.c
SARD
0
static int goodB2GSource(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 ) while ( 0 )
75623/CWE126_Buffer_Overread__CWE129_connect_socket_42.c
SARD
0
RestyleManager::ReparentStyleContext(nsIFrame* aFrame) nsStyleContext * oldContext = aFrame -> StyleContext ( ) ; nsRefPtr < nsStyleContext > newContext ; nsIFrame * providerFrame = aFrame -> GetParentStyleContextFrame ( ) ; bool isChild = providerFrame && providerFrame -> GetParent ( ) == aFrame ; nsStyleContext * newParentContext = nullptr ; if ( isChild ) newParentContext = providerFrame -> StyleContext ( ); if ( providerFrame ) newParentContext = providerFrame -> StyleContext ( ); nsIFrame * prevContinuation = GetPrevContinuationWithPossiblySameStyle ( aFrame ) ; nsStyleContext * prevContinuationContext ; bool copyFromContinuation = prevContinuation && ( prevContinuationContext = prevContinuation -> StyleContext ( ) ) -> GetPseudo ( ) == oldContext -> GetPseudo ( ) && prevContinuationContext -> GetParent ( ) == newParentContext ; if ( copyFromContinuation ) newContext = prevContinuationContext; nsIFrame * parentFrame = aFrame -> GetParent ( ) ; Element * element = ElementForStyleContext ( parentFrame ? parentFrame -> GetContent ( ) : nullptr , aFrame , oldContext -> GetPseudoType ( ) ) ; nsIContent * pseudoElementContent = aFrame -> GetContent ( ) ; Element * pseudoElement = ( pseudoElementContent && pseudoElementContent -> IsElement ( ) ) ? pseudoElementContent -> AsElement ( ) : nullptr ; newContext = mPresContext -> StyleSet ( ) -> ReparentStyleContext ( oldContext , newParentContext , element , pseudoElement ); if ( newContext ) if ( newContext != oldContext ) VerifyStyleTree ( mPresContext , aFrame , newParentContext ); 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 ( ) ) nsIFrame * outOfFlowFrame = nsPlaceholderFrame :: GetRealFrameForPlaceholder ( child ) ; VerifyStyleTree ( aPresContext , outOfFlowFrame , nullptr ); while ( outOfFlowFrame = outOfFlowFrame -> GetNextContinuation ( ) ) 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 ( aParentContext != actualParentContext ) if ( aContext == aParentContext ) fputs ( "should be using: " , stdout );
CVE-2015-0826/Firefox_35.0b8_CVE_2015_0826_layout_base_RestyleManager.cpp
NVD
0
RestyleManager::DebugVerifyStyleTree(nsIFrame* aFrame) if ( aFrame ) nsStyleContext * context = aFrame -> StyleContext ( ) ; nsStyleContext * parentContext = context -> GetParent ( ) ; VerifyStyleTree ( mPresContext , aFrame , parentContext ); 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 ( ) ) nsIFrame * outOfFlowFrame = nsPlaceholderFrame :: GetRealFrameForPlaceholder ( child ) ; VerifyStyleTree ( aPresContext , outOfFlowFrame , nullptr ); while ( outOfFlowFrame = outOfFlowFrame -> GetNextContinuation ( ) ) static VerifyStyleTree(nsPresContext* aPresContext, nsIFrame* nsStyleContext* aParentContext) nsIFrame :: ChildListIterator lists ( aFrame ) ; nsFrameList :: Enumerator childFrames ( lists . CurrentList ( ) ) ; nsIFrame * child = childFrames . get ( ) ; if ( ! ( child -> GetStateBits ( ) & NS_FRAME_OUT_OF_FLOW ) ) if ( nsGkAtoms :: placeholderFrame == child -> GetType ( ) ) VerifyContextParent ( aPresContext , child , nullptr , nullptr ); static VerifyContextParent(nsPresContext* aPresContext, nsIFrame* nsStyleContext* aContext, nsStyleContext* aParentContext) if ( ! aContext ) aContext = aFrame -> StyleContext ( ); nsStyleContext * childStyleIfVisited = aContext -> GetStyleIfVisited ( ) ; if ( childStyleIfVisited && ! ( ( childStyleIfVisited -> RuleNode ( ) != aContext -> RuleNode ( ) && childStyleIfVisited -> GetParent ( ) == aContext -> GetParent ( ) ) || childStyleIfVisited -> GetParent ( ) == aContext -> GetParent ( ) -> GetStyleIfVisited ( ) ) ) fputs ( "\n" , stdout );
CVE-2015-0826/Firefox_35.0b8_CVE_2015_0826_layout_base_RestyleManager.cpp
NVD
0
void CWE369_Divide_by_Zero__int_connect_socket_modulo_41_bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); badSink ( data ); static void badSink(int data) printIntLine ( 100 % data ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber );
95034/CWE369_Divide_by_Zero__int_connect_socket_modulo_41.c
SARD
25
static void goodB2G2() if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = strtoul ( inputBuffer , NULL , 0 ); 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 );
117041/CWE789_Uncontrolled_Mem_Alloc__malloc_char_fgets_11.c
SARD
0
CWE78_OS_Command_Injection__char_connect_socket_execl_83_bad::CWE78_OS_Command_Injection__char_connect_socket_execl_83_bad(char * dataCopy) data = dataCopy; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 )
117989/CWE78_OS_Command_Injection__char_connect_socket_execl_83_bad.cpp
SARD
0
static void goodG2B1() size_t data ; data = 0; data = 20; goodG2B1Sink ( data ); void goodG2B1Sink(size_t data) if ( goodG2B1Global ) 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
117530/CWE789_Uncontrolled_Mem_Alloc__new_char_fgets_22b.cpp
SARD
0