func
stringlengths 181
23.6k
| path
stringlengths 12
123
| source
stringclasses 2
values | label
int64 0
40
|
---|---|---|---|
void CWE122_Heap_Based_Buffer_Overflow__CWE131_memcpy_34_bad() int * data ; CWE122_Heap_Based_Buffer_Overflow__CWE131_memcpy_34_unionType myUnion ; data = NULL; data = ( int * ) malloc ( 10 ); myUnion . unionFirst = data; int * data = myUnion . unionSecond ; int source [ 10 ] = { 0 } ; memcpy ( data , source , 10 * sizeof ( int ) ); printIntLine ( data [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( data ); | 69847/CWE122_Heap_Based_Buffer_Overflow__CWE131_memcpy_34.c | SARD | 3 |
static void goodG2B1() char * data ; data = NULL; if ( staticReturnsFalse ( ) ) static int staticReturnsFalse() return 0 ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 102212/CWE416_Use_After_Free__malloc_free_char_08.c | SARD | 0 |
static int stonesoup_ev_handler(struct mg_connection *conn, enum mg_event ev) char * ifmatch_header ; char * stonesoup_tainted_buff ; int buffer_size = 1000 ; if ( ev == MG_REQUEST ) ifmatch_header = ( char * ) mg_get_header ( conn , "if-match" ); if ( strcmp ( ifmatch_header , "weak_taint_source_value" ) == 0 ) while ( 1 ) stonesoup_tainted_buff = ( char * ) malloc ( buffer_size * sizeof ( char ) ); data_size = mg_get_var ( conn , "data" , stonesoup_tainted_buff , buffer_size * sizeof ( char ) ); if ( data_size < buffer_size ) buffer_size = buffer_size * 2; stonesoup_handle_taint ( stonesoup_tainted_buff ); void stonesoup_handle_taint(char *overroasts_lugones) char dbconn_str [ 150 ] ; if ( overroasts_lugones != 0 ) dbhost = getenv ( "DBPGHOST" ); dbuser = getenv ( "DBPGUSER" ); dbpassword = getenv ( "DBPGPASSWORD" ); dbport = getenv ( "DBPGPORT" ); dbdatabase = getenv ( "SS_DBPGDATABASE" ); if ( dbhost != 0 && dbport != 0 && dbuser != 0 && dbpassword != 0 && dbdatabase != 0 ) snprintf ( dbconn_str , 150 , "dbname=%s host=%s user=%s password=%s port=%s" , dbdatabase , dbhost , dbuser , dbpassword , dbport ); conn = PQconnectdb ( dbconn_str ); if ( PQstatus ( conn ) != 0 ) stonesoup_printf ( "%s: %s\n" , "Connection to database failed" , PQerrorMessage ( conn ) ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); mg_vprintf_data ( ( struct mg_connection * ) stonesoup_printf_context , format , argptr ); PQfinish ( conn ); res = PQexec ( conn , query ); if ( PQresultStatus ( res ) != PGRES_COMMAND_OK ) stonesoup_printf ( "%s: %s\n" , "INSERT failed" , PQerrorMessage ( conn ) ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); mg_vprintf_data ( ( struct mg_connection * ) stonesoup_printf_context , format , argptr ); PQclear ( res ); PQfinish ( conn ); stonesoup_result = PQcmdTuples ( res ); stonesoup_printf ( "Query OK, %s rows affected\n" , stonesoup_result ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); mg_vprintf_data ( ( struct mg_connection * ) stonesoup_printf_context , format , argptr ); PQclear ( res ); PQfinish ( conn ); | 152325/color.c | SARD | 15 |
conversation_t *find_or_create_conversation(packet_info *pinfo) if ( ( conv = find_conversation ( pinfo -> fd -> num , ( & pinfo -> src ) , ( & pinfo -> dst ) , pinfo -> ptype , pinfo -> srcport , pinfo -> destport , 0 ) ) == ( ( void * ) 0 ) ) conversation_t *find_conversation(const guint32 frame_num,const address *addr_a,const address *addr_b,const port_type ptype,const guint32 port_a,const guint32 port_b,const guint options) conversation_t * conversation ; if ( ! ( options & ( 0x01 | 0x02 ) ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( conversation -> options & 0x01 ) && ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , addr_b , 0 ); if ( ! ( options & 0x01 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_b , port_a ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x01 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( conversation -> options & 0x02 ) && ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , 0 , port_b ); static conversation_t *conversation_create_from_template(conversation_t *conversation,const address *addr2,const guint32 port2) if ( conversation -> options & 0x08 && ( conversation -> key_ptr -> ptype ) != PT_UDP ) conversation_t * new_conversation_from_template ; guint options = conversation -> options & ( ~ ( 0x08 | 0x01 | 0x02 ) ) ; if ( conversation -> options & 0x01 && conversation -> options & 0x02 ) if ( conversation -> options & 0x02 ) new_conversation_from_template = conversation_new ( conversation -> setup_frame , ( & conversation -> key_ptr -> addr1 ) , ( & conversation -> key_ptr -> addr2 ) , conversation -> key_ptr -> ptype , conversation -> key_ptr -> port1 , port2 , options ); conversation_t *conversation_new(const guint32 setup_frame,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2,const guint options) guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr1 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr1 -> data , ( addr1 -> len ) ); guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr2 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr2 -> data , ( addr2 -> len ) ); ( & new_key -> addr2 ) -> data = SE_COPY_ADDRESS_data; new_key -> ptype = ptype; new_key -> port1 = port1; new_key -> port2 = port2; conversation -> key_ptr = new_key; conversation_insert_into_hashtable ( hashtable , conversation ); return conversation ; | 149441/conversation.c | SARD | 0 |
static void goodG2B() int data ; data = - 1; data = 100 - 1; CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memcpy_52b_goodG2BSink ( data ); void CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memcpy_52b_goodG2BSink(int data) CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memcpy_52c_goodG2BSink ( data ); void CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memcpy_52c_goodG2BSink(int data) 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 ); | 88092/CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memcpy_52c.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__wchar_t_file_w32_vsnprintf_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 ); | 81650/CWE134_Uncontrolled_Format_String__wchar_t_file_w32_vsnprintf_09.c | SARD | 0 |
static void goodG2B1() char * data ; switch ( 5 ) data = ( char * ) malloc ( 100 * sizeof ( char ) ); memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; memmove ( dest , data , strlen ( dest ) * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 76344/CWE126_Buffer_Overread__malloc_char_memmove_15.c | SARD | 0 |
static void goodG2B2() char * data ; char dataBuffer [ 100 ] ; data = dataBuffer; data = CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_loop_22_goodG2B2Source ( data ); char * CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_loop_22_goodG2B2Source(char * data) if ( CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_loop_22_goodG2B2Global ) memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; return data ; | 65819/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_loop_22b.c | SARD | 0 |
static void goodG2B1() int data ; data = - 1; if ( staticFalse ) data = 20; size_t i ; int * intPointer ; intPointer = ( int * ) malloc ( data * sizeof ( int ) ); for (i = 0; i < (size_t)data; i++) intPointer [ i ] = 0; free ( intPointer ); | 110412/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fixed_05.c | SARD | 0 |
static void goodG2B2() char * data ; if ( 5 == 5 ) data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; SNPRINTF ( data , 100 , "%s" , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 71458/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_snprintf_03.c | SARD | 0 |
static void goodG2B() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memmove ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 73862/CWE124_Buffer_Underwrite__char_alloca_memmove_01.c | SARD | 0 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; myUnion . unionFirst = data; char * data = myUnion . unionSecond ; goodB2GVaSink ( data , data ); static void goodB2GVaSink(char * data, ...) va_start ( args , data ); | 80177/CWE134_Uncontrolled_Format_String__char_file_vprintf_34.c | SARD | 0 |
static void *emem_alloc_chunk(size_t size,emem_header_t *mem) void * buf ; size_t asize = size ; gboolean use_canary = mem -> debug_use_canary ; guint8 pad ; emem_chunk_t * free_list ; if ( use_canary ) asize += sizeof ( void * ); pad = emem_canary_pad ( asize ); static guint8 emem_canary_pad(size_t allocation) guint8 pad ; pad = ( 8 - allocation % 8 ); if ( pad < 8 ) pad += 8; return pad ; pad = ( 8 - ( asize & ( 8 - 1 ) ) & ( 8 - 1 ) ); asize += pad; if ( ! mem -> free_list ) mem -> free_list = emem_create_chunk_gp ( ( 10 * 1024 * 1024 ) ); static emem_chunk_t *emem_create_chunk_gp(size_t size) emem_chunk_t * npc ; npc = emem_create_chunk ( size ); static emem_chunk_t *emem_create_chunk(size_t size) emem_chunk_t * npc ; npc = ( ( emem_chunk_t * ) ( g_malloc_n ( 1 , sizeof ( emem_chunk_t ) ) ) ); npc -> next = ( ( void * ) 0 ); npc -> canary_last = ( ( void * ) 0 ); npc -> amount_free = npc -> amount_free_init = ( ( unsigned int ) size ); npc -> free_offset = npc -> free_offset_init = 0; return npc ; npc -> amount_free = npc -> amount_free_init; npc -> free_offset = npc -> free_offset_init; return npc ; if ( asize > ( mem -> free_list -> amount_free ) ) emem_chunk_t * npc ; npc = mem -> free_list; mem -> free_list = mem -> free_list -> next; npc -> next = mem -> used_list; mem -> used_list = npc; if ( ! mem -> free_list ) mem -> free_list = emem_create_chunk_gp ( ( 10 * 1024 * 1024 ) ); static emem_chunk_t *emem_create_chunk_gp(size_t size) emem_chunk_t * npc ; npc = emem_create_chunk ( size ); npc -> amount_free = npc -> amount_free_init; npc -> free_offset = npc -> free_offset_init; return npc ; free_list = mem -> free_list; buf = ( free_list -> buf + free_list -> free_offset ); free_list -> amount_free -= ( ( unsigned int ) asize ); free_list -> free_offset += ( ( unsigned int ) asize ); if ( use_canary ) char * cptr = ( ( char * ) buf ) + size ; memcpy ( cptr , ( mem -> canary ) , ( pad - 1 ) ); cptr [ pad - 1 ] = '\0'; memcpy ( ( cptr + pad ) , ( & free_list -> canary_last ) , sizeof ( void * ) ); free_list -> canary_last = cptr; | 151738/emem.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__wchar_t_environment_fprintf_11_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; size_t dataLen = wcslen ( data ) ; wchar_t * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) wcsncat ( data + dataLen , environment , 100 - dataLen - 1 ); if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; fwprintf ( stdout , data ); | 81124/CWE134_Uncontrolled_Format_String__wchar_t_environment_fprintf_11.c | SARD | 15 |
static void goodG2B2() wchar_t * data ; wchar_t * dataGoodBuffer = ( wchar_t * ) ALLOCA ( ( 10 + 1 ) * sizeof ( wchar_t ) ) ; if ( staticTrue ) data = dataGoodBuffer; data [ 0 ] = L '\0' wchar_t source [ 10 + 1 ] = SRC_STRING ; wcscpy ( data , source ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 63436/CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_alloca_cpy_05.c | SARD | 0 |
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 > 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 ); | 117281/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_fgets_11.c | SARD | 0 |
static void goodB2G2() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 80748/CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vprintf_21.c | SARD | 0 |
void CWE124_Buffer_Underwrite__char_declare_memcpy_12_bad() char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memcpy ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 74033/CWE124_Buffer_Underwrite__char_declare_memcpy_12.c | SARD | 3 |
void CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_54b_goodG2BSink(int data) CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_54c_goodG2BSink ( data ); void CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_54c_goodG2BSink(int data) CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_54d_goodG2BSink ( data ); void CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_54d_goodG2BSink(int data) CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_54e_goodG2BSink ( data ); void CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_54e_goodG2BSink(int data) 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 ); | 87902/CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_54e.c | SARD | 0 |
static void goodB2G2() if ( GLOBAL_CONST_FIVE == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) 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 ); | 117235/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_13.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) 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 ); static void copy(const position_set *src,position_set *dst) if ( dst -> alloc <= src -> nelem ) size_t new_n_alloc = src -> nelem + ( ! dst -> elems ) ; dst -> elems = ( x2nrealloc ( ( dst -> elems ) , & new_n_alloc , sizeof ( ( * dst -> elems ) ) ) ); dst -> alloc = new_n_alloc; while ( 0 ) memcpy ( ( dst -> elems ) , ( src -> elems ) , sizeof ( dst -> elems [ 0 ] ) * src -> nelem ); dst -> nelem = src -> nelem; | 153747/dfa.c | SARD | 0 |
static void goodG2B2() wchar_t * data ; wchar_t dataGoodBuffer [ 100 ] ; if ( globalTrue ) 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 ) | 66953/CWE121_Stack_Based_Buffer_Overflow__dest_wchar_t_declare_cpy_10.c | SARD | 0 |
void CWE590_Free_Memory_Not_on_Heap__free_int_declare_52_bad() int * data ; data = NULL; int dataBuffer [ 100 ] ; size_t i ; for (i = 0; i < 100; i++) dataBuffer [ i ] = 5; data = dataBuffer; CWE590_Free_Memory_Not_on_Heap__free_int_declare_52b_badSink ( data ); void CWE590_Free_Memory_Not_on_Heap__free_int_declare_52b_badSink(int * data) CWE590_Free_Memory_Not_on_Heap__free_int_declare_52c_badSink ( data ); void CWE590_Free_Memory_Not_on_Heap__free_int_declare_52c_badSink(int * data) free ( data ); | 108402/CWE590_Free_Memory_Not_on_Heap__free_int_declare_52c.c | SARD | 1 |
void CWE124_Buffer_Underwrite__char_alloca_loop_67b_badSink(CWE124_Buffer_Underwrite__char_alloca_loop_67_structType myStruct) char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; data [ i ] = source [ i ]; data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 73815/CWE124_Buffer_Underwrite__char_alloca_loop_67b.c | SARD | 3 |
static void goodG2B() int data ; data = - 1; data = 7; CWE122_Heap_Based_Buffer_Overflow__c_CWE129_rand_63b_goodG2BSink ( & data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE129_rand_63b_goodG2BSink(int * dataPtr) int data = * dataPtr ; int i ; int * buffer = ( int * ) malloc ( 10 * sizeof ( int ) ) ; for (i = 0; i < 10; i++) buffer [ i ] = 0; if ( data >= 0 ) buffer [ data ] = 1; free ( buffer ); | 70723/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_rand_63b.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_loop_31_bad() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; char * dataCopy = data ; char * data = dataCopy ; size_t i , dataLen ; dataLen = strlen ( data ); for (i = 0; i < dataLen; i++) | 72244/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_loop_31.c | SARD | 0 |
void bad() char * data ; char * * dataPtr1 = & data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; char * data = * dataPtr1 ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 95559/CWE36_Absolute_Path_Traversal__char_connect_socket_fopen_32.cpp | SARD | 0 |
static void good1() while ( 1 ) wchar_t * password = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; if ( fgetws ( password , 100 , stdin ) == NULL ) passwordLen = wcslen ( password ); if ( passwordLen > 0 ) if ( LogonUserW ( username , domain , password , LOGON32_LOGON_NETWORK , LOGON32_PROVIDER_DEFAULT , & hUser ) != 0 ) passwordLen = wcslen ( password ); SecureZeroMemory ( password , passwordLen * sizeof ( wchar_t ) ); free ( password ); | 92049/CWE244_Heap_Inspection__w32_wchar_t_free_16.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 ; 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 ) * end = saved_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) size_t nelem = d -> states [ s ] . mbps . nelem ; 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 ); rarray [ i ] = match_mb_charset ( d , s , pos , idx ); static int match_mb_charset(struct dfa *d,state_num s,position pos,size_t idx) size_t i ; int match_len ; int op_len ; char buffer [ 128 ] ; struct mb_char_classes * work_mbc ; int context ; wchar_t wc ; wc = inputwcs [ idx ]; if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) context = wchar_context ( wc ); if ( ! ( ( ( ( context & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( context & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( context & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) work_mbc = & d -> mbcsets [ d -> multibyte_prop [ pos . index ] >> 2 ]; match_len = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc < 1 << 8 && work_mbc -> cset != ( - 1 ) && tstbit ( ( ( unsigned char ) wc ) , d -> charclasses [ work_mbc -> cset ] ) ) for (i = 0; i < work_mbc -> nch_classes; i++) if ( iswctype ( ( ( wint_t ) wc ) , work_mbc -> ch_classes [ i ] ) ) strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , match_len ); buffer [ match_len ] = '\0'; for (i = 0; i < work_mbc -> nequivs; i++) op_len = ( strlen ( work_mbc -> equivs [ i ] ) ); strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> equivs [ i ] , buffer ) == 0 ) 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 ) | 153750/dfa.c | SARD | 0 |
static void goodG2B2() wchar_t * data ; wchar_t * dataBuffer = ( wchar_t * ) ALLOCA ( 100 * sizeof ( wchar_t ) ) ; data = dataBuffer; data = goodG2B2Source ( data ); static wchar_t * goodG2B2Source(wchar_t * data) if ( goodG2B2Static ) wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' return data ; wchar_t dest [ 50 ] = L "" memcpy ( dest , data , wcslen ( data ) * sizeof ( wchar_t ) ); | 66154/CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_alloca_memcpy_21.c | SARD | 0 |
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; if ( globalTrue ) size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( FILENAME_MAX - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 91509/CWE23_Relative_Path_Traversal__wchar_t_file_fopen_10.cpp | SARD | 0 |
static void goodG2B() wchar_t * data ; wchar_t dataBuffer [ 100 ] ; data = dataBuffer; wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' wchar_t * dataCopy = data ; wchar_t * data = dataCopy ; wchar_t dest [ 50 ] = L "" memmove ( dest , data , wcslen ( data ) * sizeof ( wchar_t ) ); | 66492/CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_declare_memmove_31.c | SARD | 0 |
static void goodG2B() size_t data ; data = 0; data = 20; wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) ) myString = new wchar_t [ data ]; wcscpy ( myString , HELLO_STRING ); printWLine ( myString ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) delete [ ] myString | 117768/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_fgets_18.cpp | SARD | 0 |
static void goodB2G1() if ( GLOBAL_CONST_FALSE ) int * buffer = ( int * ) malloc ( 10 * sizeof ( int ) ) ; buffer [ i ] = 0; buffer [ data ] = 1; for(i = 0; i < 10; i++) printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( buffer ); | 70696/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_rand_09.c | SARD | 0 |
static void goodG2B() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; strcat ( data , "file.txt" ); dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; goodG2BSink ( dataMap ); void goodG2BSink(map<int, char *> dataMap) char * data = dataMap [ 2 ] ; inputFile . open ( ( char * ) data ); | 89911/CWE23_Relative_Path_Traversal__char_console_ifstream_74a.cpp | SARD | 0 |
apr_status_t CVE_2010_2068_VULN_ap_proxy_http_process_response(apr_pool_t * p, request_rec proxy_conn_rec conn_rec proxy_server_conf char *server_portstr) char buffer [ HUGE_STRING_LEN ] ; char keepchar ; int len , backasswards ; int interim_response = 0 ; apr_table_t * save_table ; if ( len <= 0 ) if ( apr_date_checkmask ( buffer , "HTTP/#.# ###*" ) ) int major , minor ; if ( 2 != sscanf ( buffer , "HTTP/%u.%u" , & major , & minor ) ) keepchar = buffer [ 12 ]; buffer [ 12 ] = '\0'; r -> status = atoi ( & buffer [ 9 ] ); if ( keepchar != '\0' ) buffer [ 12 ] = keepchar; buffer [ 12 ] = ' '; buffer [ 13 ] = '\0'; r -> status_line = apr_pstrdup ( p , & buffer [ 9 ] ); save_table = apr_table_make ( r -> pool , 2 ); if ( r -> headers_out == NULL ) if ( ! apr_is_empty_table ( save_table ) ) r -> headers_out = apr_table_overlay ( r -> pool , r -> headers_out , save_table ); r -> headers_out = ap_proxy_clean_warnings ( p , r -> headers_out ); r -> status = 200; r -> status_line = "200 OK"; if ( ap_is_HTTP_INFO ( r -> status ) ) interim_response ++; interim_response = 0; while ( interim_response && ( interim_response < AP_MAX_INTERIM_RESPONSES ) ) | CVE-2010-2068/CVE_2010_2068_VULN_ap_proxy_http_process_response.c | NVD | 0 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 79365/CWE134_Uncontrolled_Format_String__char_connect_socket_w32_vsnprintf_44.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; badSource ( data ); void badSource(char * &data) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 95572/CWE36_Absolute_Path_Traversal__char_connect_socket_fopen_62b.cpp | SARD | 0 |
static void goodG2B() char * data ; map < int , char * > dataMap ; char * dataGoodBuffer = ( char * ) ALLOCA ( ( 10 + 1 ) * sizeof ( char ) ) ; data = dataGoodBuffer; data [ 0 ] = '\0'; dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; goodG2BSink ( dataMap ); void goodG2BSink(map<int, char *> dataMap) char * data = dataMap [ 2 ] ; char source [ 10 + 1 ] = SRC_STRING ; strncpy ( data , source , strlen ( source ) + 1 ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 63229/CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_ncpy_74b.cpp | SARD | 0 |
void parse_dir_colors() char * s ; if ( Hflag ) if ( getenv ( "TERM" ) == ( ( void * ) 0 ) ) s = getenv ( "TREE_COLORS" ); if ( s == ( ( void * ) 0 ) ) s = getenv ( "LS_COLORS" ); if ( ( s == ( ( void * ) 0 ) || strlen ( s ) == 0 ) && force_color ) if ( s == ( ( void * ) 0 ) || ! force_color && ( nocolor || ! isatty ( 1 ) ) ) colors = strcpy ( ( xmalloc ( strlen ( s ) + 1 ) ) , s ); arg = split ( colors , ":" , & n ); char **split(char *str,char *delim,int *nwrds) w [ * nwrds = 0 ] = strtok ( str , delim ); while ( w [ * nwrds ] ) if ( * nwrds == n - 2 ) w = ( xrealloc ( w , sizeof ( char * ) * ( n += 256 ) ) ); w [ ++ * nwrds ] = strtok ( ( ( void * ) 0 ) , delim ); w [ * nwrds ] = ( ( void * ) 0 ); return w ; for (i = 0; arg[i]; i++) c = split ( arg [ i ] , "=" , & n ); char **split(char *str,char *delim,int *nwrds) w [ * nwrds = 0 ] = strtok ( str , delim ); while ( w [ * nwrds ] ) if ( * nwrds == n - 2 ) w = ( xrealloc ( w , sizeof ( char * ) * ( n += 256 ) ) ); w [ ++ * nwrds ] = strtok ( ( ( void * ) 0 ) , delim ); w [ * nwrds ] = ( ( void * ) 0 ); return w ; switch ( cmd ( c [ 0 ] ) ) int cmd(char *s) if ( ! strcmp ( cmds [ i ] . cmd , s ) ) if ( s [ 0 ] == '*' ) if ( c [ 1 ] ) norm_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) file_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) dir_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) if ( strcasecmp ( "target" , c [ 1 ] ) == 0 ) link_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) fifo_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) door_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) block_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) char_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) orphan_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) sock_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) suid_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) sgid_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) stickyow_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) otherwr_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) sticky_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) exec_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) missing_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) leftcode = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) rightcode = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) endcode = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) e -> ext = strcpy ( ( xmalloc ( strlen ( ( c [ 0 ] + 1 ) ) + 1 ) ) , ( c [ 0 ] + 1 ) ); e -> term_flg = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); e -> nxt = ext; ext = e; free ( c ); free ( arg ); if ( ! leftcode ) if ( ! rightcode ) if ( ! norm_flgs ) if ( ! endcode ) sprintf ( buf , "%s%s%s" , leftcode , norm_flgs , rightcode ); endcode = strcpy ( ( xmalloc ( strlen ( buf ) + 1 ) ) , buf ); free ( colors ); | 150436/color.c | SARD | 0 |
static void build_state_zero(struct dfa *d) d -> tralloc = 1; d -> trcount = 0; d -> realtrans = ( ( sizeof ( ( * d -> realtrans ) ) == 1 ? xzalloc ( ( d -> tralloc + 1 ) ) : xcalloc ( ( d -> tralloc + 1 ) , sizeof ( ( * d -> realtrans ) ) ) ) ); while ( 0 ) d -> trans = d -> realtrans + 1; d -> fails = ( ( sizeof ( ( * d -> fails ) ) == 1 ? xzalloc ( ( d -> tralloc ) ) : xcalloc ( ( d -> tralloc ) , sizeof ( ( * d -> fails ) ) ) ) ); while ( 0 ) d -> success = ( ( sizeof ( ( * d -> success ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> success ) ) ) ) ); while ( 0 ) d -> newlines = ( ( sizeof ( ( * d -> newlines ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> newlines ) ) ) ) ); while ( 0 ) build_state ( 0 , d ); static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) leaf_set * grps ; charclass * labels ; size_t ngrps = 0 ; position pos ; charclass matches ; int matchesf ; charclass intersect ; int intersectf ; charclass leftovers ; int leftoversf ; size_t i ; size_t j ; size_t k ; grps = ( ( sizeof ( ( * grps ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * grps ) ) ) ) ); while ( 0 ) labels = ( ( sizeof ( ( * labels ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * labels ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . elems . nelem; ++i) pos = d -> states [ s ] . elems . elems [ i ]; if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) ) if ( d -> tokens [ pos . index ] >= CSET ) if ( pos . constraint != 0x777 ) if ( ! ( ( ( ( 4 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~newline [ j ]; if ( ! ( ( ( ( 2 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~letters [ j ]; if ( ! ( ( ( ( 1 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= letters [ j ] | newline [ j ]; if ( j == ( ( 1 << 8 ) + 8 * sizeof ( int ) - 1 ) / ( 8 * sizeof ( int ) ) ) for (j = 0; j < ngrps; ++j) if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) && ! tstbit ( d -> tokens [ pos . index ] , labels [ j ] ) ) intersectf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) ( intersect [ k ] = matches [ k ] & labels [ j ] [ k ] ) ? ( intersectf = 1 ) : 0; if ( ! intersectf ) leftoversf = matchesf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) int match = matches [ k ] ; int label = labels [ j ] [ k ] ; ( leftovers [ k ] = ~match & label ) ? ( leftoversf = 1 ) : 0; ( matches [ k ] = match & ~label ) ? ( matchesf = 1 ) : 0; if ( leftoversf ) grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) 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 ) ); | 151260/dfa.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_listen_socket_w32spawnl_22_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; data = CWE78_OS_Command_Injection__char_listen_socket_w32spawnl_22_badSource ( data ); char * CWE78_OS_Command_Injection__char_listen_socket_w32spawnl_22_badSource(char * data) if ( CWE78_OS_Command_Injection__char_listen_socket_w32spawnl_22_badGlobal ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) return data ; | 120218/CWE78_OS_Command_Injection__char_listen_socket_w32spawnl_22b.c | SARD | 0 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfamust ( d ); static void dfamust(struct dfa *d) must * musts ; must * mp ; size_t ri ; size_t i ; token t ; static must must0 ; musts = ( ( sizeof ( ( * musts ) ) == 1 ? xmalloc ( d -> tindex + 1 ) : xnmalloc ( d -> tindex + 1 , sizeof ( ( * musts ) ) ) ) ); while ( 0 ) mp = musts; for (i = 0; i <= d -> tindex; ++i) mp [ i ] = must0; for (i = 0; i <= d -> tindex; ++i) mp [ i ] . in = ( xmalloc ( sizeof ( ( * mp [ i ] . in ) ) ) ); mp [ i ] . left = ( xmalloc ( 2 ) ); mp [ i ] . right = ( xmalloc ( 2 ) ); mp [ i ] . is = ( xmalloc ( 2 ) ); mp [ i ] . left [ 0 ] = mp [ i ] . right [ 0 ] = mp [ i ] . is [ 0 ] = '\0'; mp [ i ] . in [ 0 ] = ( ( void * ) 0 ); for (ri = 0; ri < d -> tindex; ++ri) switch ( t = d -> tokens [ ri ] ) must * lmp ; must * rmp ; size_t j ; size_t ln ; size_t rn ; rmp = -- mp; lmp = -- mp; if ( ! ( strcmp ( ( lmp -> is ) , ( rmp -> is ) ) == 0 ) ) lmp -> is [ 0 ] = '\0'; i = 0; lmp -> left [ i ] = '\0'; ln = strlen ( ( lmp -> right ) ); rn = strlen ( ( rmp -> right ) ); if ( n > rn ) n = rn; for (i = 0; i < n; ++i) if ( lmp -> right [ ln - i - 1 ] != rmp -> right [ rn - i - 1 ] ) for (j = 0; j < i; ++j) lmp -> right [ j ] = lmp -> right [ ln - i + j ]; lmp -> right [ j ] = '\0'; mp -> is [ 0 ] = '\0'; must * lmp ; must * rmp ; rmp = -- mp; lmp = -- mp; lmp -> in = addlists ( lmp -> in , rmp -> in ); if ( lmp -> in == ( ( void * ) 0 ) ) if ( lmp -> right [ 0 ] != '\0' && rmp -> left [ 0 ] != '\0' ) char * tp ; tp = icpyalloc ( ( lmp -> right ) ); static char *icpyalloc(const char *string) return icatalloc ( ( ( void * ) 0 ) , string ) ; tp = icatalloc ( tp , ( rmp -> left ) ); lmp -> in = enlist ( lmp -> in , tp , strlen ( tp ) ); if ( lmp -> in == ( ( void * ) 0 ) ) if ( lmp -> is [ 0 ] != '\0' ) lmp -> left = icatalloc ( lmp -> left , ( rmp -> left ) ); if ( lmp -> left == ( ( void * ) 0 ) ) if ( rmp -> is [ 0 ] == '\0' ) lmp -> right [ 0 ] = '\0'; lmp -> right = icatalloc ( lmp -> right , ( rmp -> right ) ); if ( lmp -> right == ( ( void * ) 0 ) ) if ( lmp -> is [ 0 ] != '\0' && rmp -> is [ 0 ] != '\0' ) lmp -> is = icatalloc ( lmp -> is , ( rmp -> is ) ); if ( lmp -> is == ( ( void * ) 0 ) ) lmp -> is [ 0 ] = '\0'; if ( t < END ) if ( t == '\0' ) if ( t >= CSET || ! 1 || t == ANYCHAR || t == MBCSET ) mp -> is [ 0 ] = mp -> left [ 0 ] = mp -> right [ 0 ] = t; mp -> is [ 1 ] = mp -> left [ 1 ] = mp -> right [ 1 ] = '\0'; mp -> in = enlist ( mp -> in , mp -> is , ( ( size_t ) 1 ) ); if ( mp -> in == ( ( void * ) 0 ) ) | 151732/dfa.c | SARD | 0 |
static int seek_frame_generic(AVFormatContext *s,int stream_index,int64_t timestamp,int flags) int index ; int64_t ret ; AVStream * st ; AVIndexEntry * ie ; st = s -> streams [ stream_index ]; index = av_index_search_timestamp ( st , timestamp , flags ); int av_index_search_timestamp(AVStream *st,int64_t wanted_timestamp,int flags) return ff_index_search_timestamp ( ( st -> index_entries ) , st -> nb_index_entries , wanted_timestamp , flags ) ; int ff_index_search_timestamp(const AVIndexEntry *entries,int nb_entries,int64_t wanted_timestamp,int flags) int a ; int b ; int m ; int64_t timestamp ; a = - 1; b = nb_entries; if ( b && entries [ b - 1 ] . timestamp < wanted_timestamp ) a = b - 1; while ( b - a > 1 ) m = a + b >> 1; timestamp = entries [ m ] . timestamp; if ( timestamp >= wanted_timestamp ) b = m; if ( timestamp <= wanted_timestamp ) a = m; m = ( flags & 1 ? a : b ); if ( ! ( flags & 4 ) ) while ( m >= 0 && m < nb_entries && ! ( entries [ m ] . flags & 0x1 ) ) m += ( flags & 1 ? - 1 : 1 ); if ( m == nb_entries ) return - 1 ; return m ; if ( index < 0 && st -> nb_index_entries && timestamp < st -> index_entries [ 0 ] . timestamp ) if ( index < 0 || index == st -> nb_index_entries - 1 ) AVPacket pkt ; int nonkey = 0 ; if ( st -> nb_index_entries ) ie = & st -> index_entries [ st -> nb_index_entries - 1 ]; if ( ( ret = avio_seek ( s -> pb , ie -> pos , 0 ) ) < 0 ) if ( ( ret = avio_seek ( s -> pb , s -> data_offset , 0 ) ) < 0 ) int read_status ; read_status = av_read_frame ( s , & pkt ); while ( read_status == - '\v' ) if ( read_status < 0 ) if ( stream_index == pkt . stream_index && pkt . dts > timestamp ) if ( pkt . flags & 0x1 ) if ( nonkey ++ > 1000 && ( st -> codec -> codec_id ) != AV_CODEC_ID_CDGRAPHICS ) int av_read_frame(AVFormatContext *s,AVPacket *pkt) const int genpts = s -> flags & 0x1 ; int eof = 0 ; int ret ; AVStream * st ; if ( ! genpts ) ret = ( s -> packet_buffer ? read_from_packet_buffer ( & s -> packet_buffer , & s -> packet_buffer_end , pkt ) : read_frame_internal ( s , pkt ) ); if ( ret < 0 ) AVPacketList * pktl = s -> packet_buffer ; if ( pktl ) AVPacket * next_pkt = & pktl -> pkt ; if ( next_pkt -> dts != ( ( int64_t ) 0x8000000000000000UL ) ) int wrap_bits = s -> streams [ next_pkt -> stream_index ] -> pts_wrap_bits ; int64_t last_dts = next_pkt -> dts ; while ( pktl && next_pkt -> pts == ( ( int64_t ) 0x8000000000000000UL ) ) if ( pktl -> pkt . stream_index == next_pkt -> stream_index && av_compare_mod ( ( next_pkt -> dts ) , pktl -> pkt . dts , ( 2 << wrap_bits - 1 ) ) < 0 ) if ( av_compare_mod ( pktl -> pkt . pts , pktl -> pkt . dts , ( 2 << wrap_bits - 1 ) ) ) next_pkt -> pts = pktl -> pkt . dts; if ( last_dts != ( ( int64_t ) 0x8000000000000000UL ) ) last_dts = pktl -> pkt . dts; pktl = pktl -> next; if ( eof && next_pkt -> pts == ( ( int64_t ) 0x8000000000000000UL ) && last_dts != ( ( int64_t ) 0x8000000000000000UL ) ) next_pkt -> pts = last_dts + ( next_pkt -> duration ); pktl = s -> packet_buffer; if ( ! ( next_pkt -> pts == ( ( int64_t ) 0x8000000000000000UL ) && next_pkt -> dts != ( ( int64_t ) 0x8000000000000000UL ) && ! eof ) ) ret = read_frame_internal ( s , pkt ); if ( ret < 0 ) if ( pktl && ret != - '\v' ) eof = 1; if ( av_dup_packet ( add_to_pktbuf ( & s -> packet_buffer , pkt , & s -> packet_buffer_end ) ) < 0 ) static AVPacket *add_to_pktbuf(AVPacketList **packet_buffer,AVPacket *pkt,AVPacketList **plast_pktl) AVPacketList * pktl = ( av_mallocz ( sizeof ( AVPacketList ) ) ) ; if ( ! pktl ) return ( ( void * ) 0 ) ; pktl -> pkt = * pkt; return & pktl -> pkt ; st = s -> streams [ pkt -> stream_index ]; if ( st -> skip_samples ) st -> skip_samples = 0; if ( s -> iformat -> flags & 0x0100 && pkt -> flags & 0x1 ) av_add_index_entry ( st , pkt -> pos , pkt -> dts , 0 , 0 , 0x1 ); int av_add_index_entry(AVStream *st,int64_t pos,int64_t timestamp,int size,int distance,int flags) timestamp = wrap_timestamp ( st , timestamp ); static int64_t wrap_timestamp(AVStream *st,int64_t timestamp) return timestamp ; return ff_add_index_entry ( & st -> index_entries , & st -> nb_index_entries , & st -> index_entries_allocated_size , pos , timestamp , size , distance , flags ) ; int ff_add_index_entry(AVIndexEntry **index_entries,int *nb_index_entries,unsigned int *index_entries_allocated_size,int64_t pos,int64_t timestamp,int size,int distance,int flags) AVIndexEntry * entries ; AVIndexEntry * ie ; int index ; if ( ( ( ( unsigned int ) ( * nb_index_entries ) ) + 1 ) >= ( 2147483647 * 2U + 1U ) / sizeof ( AVIndexEntry ) ) if ( timestamp == ( ( int64_t ) 0x8000000000000000UL ) ) entries = ( av_fast_realloc ( ( * index_entries ) , index_entries_allocated_size , ( * nb_index_entries + 1 ) * sizeof ( AVIndexEntry ) ) ); if ( ! entries ) * index_entries = entries; index = ff_index_search_timestamp ( ( * index_entries ) , * nb_index_entries , timestamp , 4 ); int ff_index_search_timestamp(const AVIndexEntry *entries,int nb_entries,int64_t wanted_timestamp,int flags) int a ; int b ; int m ; int64_t timestamp ; a = - 1; b = nb_entries; if ( b && entries [ b - 1 ] . timestamp < wanted_timestamp ) a = b - 1; while ( b - a > 1 ) m = a + b >> 1; timestamp = entries [ m ] . timestamp; if ( timestamp >= wanted_timestamp ) b = m; if ( timestamp <= wanted_timestamp ) a = m; m = ( flags & 1 ? a : b ); if ( ! ( flags & 4 ) ) while ( m >= 0 && m < nb_entries && ! ( entries [ m ] . flags & 0x1 ) ) m += ( flags & 1 ? - 1 : 1 ); if ( m == nb_entries ) return - 1 ; return m ; if ( index < 0 ) ie = & entries [ index ]; if ( ie -> timestamp != timestamp ) if ( ie -> timestamp <= timestamp ) memmove ( ( entries + index + 1 ) , ( entries + index ) , sizeof ( AVIndexEntry ) * ( * nb_index_entries - index ) ); | 151631/utils.c | SARD | 0 |
void CWE194_Unexpected_Sign_Extension__connect_socket_memmove_18_bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; tempInt = atoi ( inputBuffer ); if ( tempInt > SHRT_MAX || tempInt < SHRT_MIN ) data = tempInt; while ( 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 ); | 86399/CWE194_Unexpected_Sign_Extension__connect_socket_memmove_18.c | SARD | 20 |
void CWE78_OS_Command_Injection__char_environment_execlp_54_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; strncat ( data + dataLen , environment , 100 - dataLen - 1 ); CWE78_OS_Command_Injection__char_environment_execlp_54b_badSink ( data ); void CWE78_OS_Command_Injection__char_environment_execlp_54b_badSink(char * data) CWE78_OS_Command_Injection__char_environment_execlp_54c_badSink ( data ); void CWE78_OS_Command_Injection__char_environment_execlp_54c_badSink(char * data) CWE78_OS_Command_Injection__char_environment_execlp_54d_badSink ( data ); void CWE78_OS_Command_Injection__char_environment_execlp_54d_badSink(char * data) CWE78_OS_Command_Injection__char_environment_execlp_54e_badSink ( data ); void CWE78_OS_Command_Injection__char_environment_execlp_54e_badSink(char * data) | 118983/CWE78_OS_Command_Injection__char_environment_execlp_54a.c | SARD | 0 |
void CWE244_Heap_Inspection__w32_wchar_t_realloc_18_bad() wchar_t * password = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; if ( fgetws ( password , 100 , stdin ) == NULL ) passwordLen = wcslen ( password ); if ( passwordLen > 0 ) if ( LogonUserW ( username , domain , password , LOGON32_LOGON_NETWORK , LOGON32_PROVIDER_DEFAULT , & hUser ) != 0 ) password = realloc ( password , 200 * sizeof ( wchar_t ) ); SecureZeroMemory ( password , 200 * sizeof ( wchar_t ) ); wcscpy ( password , L "Nothing to see here" ) printWLine ( password ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( password ); | 92069/CWE244_Heap_Inspection__w32_wchar_t_realloc_18.c | SARD | 33 |
static svn_error_t *get_xlate_handle_node_internal(xlate_handle_node_t **ret,const char *topage,const char *frompage,const char *userdata_key,apr_pool_t *pool) char * intermediacy_roadlessness ; if ( __sync_bool_compare_and_swap ( & soucar_corresp , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) intermediacy_roadlessness = getenv ( "UMBRATIC_SYNENTOGNATHI" ); if ( intermediacy_roadlessness != 0 ) cyanines_shyness = & intermediacy_roadlessness; conceive_vettura = cyanines_shyness + 5; monetite_peladore = ( ( char * ) ( * ( conceive_vettura - 5 ) ) ); tracepoint ( stonesoup_trace , variable_buffer_info , "STONESOUP_TAINT_SOURCE" , strlen ( monetite_peladore ) + 1 , monetite_peladore , "TRIGGER-STATE" ); | 153756/utf.c | SARD | 3 |
static void goodB2G() int64_t * data ; data = NULL; CWE762_Mismatched_Memory_Management_Routines__delete_array_int64_t_realloc_84_goodB2G * goodB2GObject = new CWE762_Mismatched_Memory_Management_Routines__delete_array_int64_t_realloc_84_goodB2G ( data ) ; CWE762_Mismatched_Memory_Management_Routines__delete_array_int64_t_realloc_84_goodB2G::CWE762_Mismatched_Memory_Management_Routines__delete_array_int64_t_realloc_84_goodB2G(int64_t * dataCopy) data = dataCopy; data = NULL; data = ( int64_t * ) realloc ( data , 100 * sizeof ( int64_t ) ); delete goodB2GObject CWE762_Mismatched_Memory_Management_Routines__delete_array_int64_t_realloc_84_goodB2G::~CWE762_Mismatched_Memory_Management_Routines__delete_array_int64_t_realloc_84_goodB2G() free ( data ); | 113528/CWE762_Mismatched_Memory_Management_Routines__delete_array_int64_t_realloc_84_goodB2G.cpp | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncat_41_bad() char * data ; data = NULL; data = ( char * ) malloc ( 50 * sizeof ( char ) ); data [ 0 ] = '\0'; CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncat_41_badSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncat_41_badSink(char * data) char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncat ( data , source , 100 ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 71384/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncat_41.c | SARD | 3 |
void CWE401_Memory_Leak__malloc_realloc_char_02_bad() if ( 1 ) char * data = ( char * ) malloc ( 100 * sizeof ( char ) ) ; strcpy ( data , "A String" ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); data = ( char * ) realloc ( data , ( 130000 ) * sizeof ( char ) ); if ( data != NULL ) strcpy ( data , "New String" ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 99635/CWE401_Memory_Leak__malloc_realloc_char_02.c | SARD | 29 |
void CWE666_Operation_on_Resource_in_Wrong_Phase_of_Lifetime__accept_listen_bind_09_bad() if ( GLOBAL_CONST_TRUE ) char data [ 100 ] = "" ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) data + dataLen , ( int ) ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ recvResult ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 109971/CWE666_Operation_on_Resource_in_Wrong_Phase_of_Lifetime__accept_listen_bind_09.c | SARD | 36 |
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalTrue ) FILE * pFile ; pFile = fopen ( "passwords.txt" , "r" ); if ( pFile != NULL ) if ( fgets ( data , 100 , pFile ) == NULL ) data [ 0 ] = '\0'; | 93411/CWE256_Plaintext_Storage_of_Password__w32_char_10.c | SARD | 0 |
int avformat_write_header(AVFormatContext *s,AVDictionary **options) int vulgarest_prokopyevsk = 7 ; char * volumen_sexhood ; if ( __sync_bool_compare_and_swap ( & gelilah_porret , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( volumen_sexhood != 0 ) tiedeman_vitalizer = & volumen_sexhood; laspisa_jefes = & tiedeman_vitalizer; globigerinas_brachycranic = & laspisa_jefes; laryngeating_furrowlike = & globigerinas_brachycranic; depravers_unequitableness = & laryngeating_furrowlike; pharmacopeial_elum = & depravers_unequitableness; hwelon_basirhinal = & pharmacopeial_elum; condimental_chopstick = & hwelon_basirhinal; horsefettler_enwiden = & condimental_chopstick; hangfires_slinkskin = & horsefettler_enwiden; camatina_unrecreating ( vulgarest_prokopyevsk , hangfires_slinkskin ); void camatina_unrecreating(int ceil_upsloping,char ***********uruguaiana_haemocyte) ceil_upsloping --; if ( ceil_upsloping > 0 ) camatina_unrecreating ( ceil_upsloping , uruguaiana_haemocyte ); void camatina_unrecreating(int ceil_upsloping,char ***********uruguaiana_haemocyte) int stonesoup_ss_j ; int stonesoup_ss_i ; size_t stonesoup_taint_size ; ceil_upsloping --; if ( ceil_upsloping > 0 ) warmongers_divided = ( ( char * ) ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * uruguaiana_haemocyte ) ) ) ) ) ) ) ) ) ) ); stonesoup_taint_size = strlen ( warmongers_divided ); if ( stonesoup_taint_size >= 1600 ) stonesoup_taint_size = 1599U; stonesoup_malloced_buff = malloc ( stonesoup_taint_size * sizeof ( char * ) ); if ( stonesoup_malloced_buff != 0 ) for (stonesoup_ss_i = 0; stonesoup_ss_i < stonesoup_taint_size; ++stonesoup_ss_i) stonesoup_malloced_buff [ stonesoup_ss_i ] = malloc ( stonesoup_taint_size * stonesoup_taint_size * sizeof ( char ) ); if ( stonesoup_malloced_buff [ stonesoup_ss_i ] != 0 ) for (stonesoup_ss_j = 0; stonesoup_ss_j < stonesoup_taint_size; ++stonesoup_ss_j) memcpy ( stonesoup_malloced_buff [ stonesoup_ss_i ] + stonesoup_ss_j * stonesoup_taint_size , warmongers_divided , stonesoup_taint_size ); | 152157/mux.c | SARD | 29 |
void bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) baseObject -> action ( data ); void CWE78_OS_Command_Injection__char_listen_socket_w32spawnl_82_bad::action(char * data) | 120244/CWE78_OS_Command_Injection__char_listen_socket_w32spawnl_82a.cpp | SARD | 0 |
void bad() char * data ; data = NULL; data = new char [ 50 ]; memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; baseObject -> action ( data ); void CWE126_Buffer_Overread__new_char_memcpy_82_bad::action(char * data) 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 ); delete [ ] data | 76615/CWE126_Buffer_Overread__new_char_memcpy_82a.cpp | SARD | 0 |
static void good1() if ( 5 != 5 ) charVoid * structCharVoid = ( charVoid * ) malloc ( sizeof ( charVoid ) ) ; structCharVoid -> voidSecond = ( void * ) SRC_STR; printLine ( ( char * ) structCharVoid -> voidSecond ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); memcpy ( structCharVoid -> charFirst , SRC_STR , sizeof ( structCharVoid -> charFirst ) ); structCharVoid -> charFirst [ ( sizeof ( structCharVoid -> charFirst ) / sizeof ( char ) ) - 1 ] = '\0'; printLine ( ( char * ) structCharVoid -> charFirst ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); printLine ( ( char * ) structCharVoid -> voidSecond ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( structCharVoid ); | 67486/CWE122_Heap_Based_Buffer_Overflow__char_type_overrun_memcpy_03.c | SARD | 0 |
static void goodG2B() int h ; wchar_t * data ; wchar_t dataBadBuffer [ 50 ] ; wchar_t dataGoodBuffer [ 100 ] ; wmemset ( dataBadBuffer , L 'A' , 50 - 1 dataBadBuffer [ 50 - 1 ] = L wmemset ( dataGoodBuffer , L 'A' , 100 - 1 dataGoodBuffer [ 100 - 1 ] = L '\0' for(h = 0; h < 1; h++) data = dataGoodBuffer; wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' memcpy ( dest , data , wcslen ( dest ) * sizeof ( wchar_t ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 76986/CWE126_Buffer_Overread__wchar_t_declare_memcpy_17.c | SARD | 0 |
static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) int separate_contexts ; state_num state ; if ( d -> searchflag ) separate_contexts = state_separate_contexts ( ( & follows ) ); state = state_index ( d , ( & follows ) , separate_contexts ^ 7 ); 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; alloc_position_set ( & d -> states [ i ] . elems , s -> nelem ); static void alloc_position_set(position_set *s,size_t size) s -> elems = ( ( sizeof ( ( * s -> elems ) ) == 1 ? xmalloc ( size ) : xnmalloc ( size , sizeof ( ( * s -> elems ) ) ) ) ); while ( 0 ) s -> alloc = size; s -> nelem = 0; | 153287/dfa.c | SARD | 0 |
static void goodB2G1() char * password ; char passwordBuffer [ 100 ] = "" ; password = passwordBuffer; if ( 1 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t passwordLen = strlen ( password ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( password + passwordLen ) , ( 100 - passwordLen - 1 ) * sizeof ( char ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) password [ passwordLen + recvResult / sizeof ( char ) ] = '\0'; while ( 0 ) if ( 0 ) HCRYPTPROV hCryptProv = 0 ; HCRYPTHASH hHash = 0 ; HCRYPTKEY hKey = 0 ; char hashData [ 100 ] = HASH_INPUT ; BYTE payload [ ( 100 - 1 ) * sizeof ( char ) ] ; DWORD payloadBytes ; payloadBytes = decodeHexChars ( payload , sizeof ( payload ) , password ); size_t decodeHexChars(unsigned char * bytes, size_t numBytes, const char * hex) size_t numWritten = 0 ; while ( numWritten < numBytes && isxdigit ( hex [ 2 * numWritten ] ) && isxdigit ( hex [ 2 * numWritten + 1 ] ) ) int byte ; bytes [ numWritten ] = ( unsigned char ) byte; return numWritten ; if ( ! CryptAcquireContext ( & hCryptProv , NULL , MS_ENH_RSA_AES_PROV , PROV_RSA_AES , 0 ) ) if ( ! CryptCreateHash ( hCryptProv , CALG_SHA_256 , 0 , 0 , & hHash ) ) if ( ! CryptHashData ( hHash , ( BYTE * ) hashData , strlen ( hashData ) , 0 ) ) if ( ! CryptDeriveKey ( hCryptProv , CALG_AES_256 , hHash , 0 , & hKey ) ) if ( ! CryptDecrypt ( hKey , 0 , 1 , 0 , payload , & payloadBytes ) ) memcpy ( password , payload , payloadBytes ); password [ payloadBytes / sizeof ( char ) ] = '\0'; while ( 0 ) if ( LogonUserA ( username , domain , password , LOGON32_LOGON_NETWORK , LOGON32_PROVIDER_DEFAULT , & pHandle ) != 0 ) | 94099/CWE319_Cleartext_Tx_Sensitive_Info__w32_char_connect_socket_02.c | SARD | 0 |
svn_error_t *svn_config_get_yes_no_ask(svn_config_t *cfg,const char **valuep,const char *section,const char *option,const char *default_value) const char * tmp_value ; svn_config_get ( cfg , & tmp_value , section , option , ( ( void * ) 0 ) ); void svn_config_get(svn_config_t *cfg,const char **valuep,const char *section,const char *option,const char *default_value) if ( cfg ) cfg_section_t * sec ; cfg_option_t * opt = find_option ( cfg , section , option , & sec ) ; if ( opt != ( ( void * ) 0 ) ) if ( default_value && strchr ( default_value , 37 ) ) apr_pool_t * tmp_pool = svn_pool_create_ex ( cfg -> x_pool , ( ( void * ) 0 ) ) ; const char * x_default ; expand_option_value ( cfg , sec , default_value , & x_default , tmp_pool ); static void expand_option_value(svn_config_t *cfg,cfg_section_t *section,const char *opt_value,const char **opt_x_valuep,apr_pool_t *x_pool) const char * parse_from = opt_value ; const char * name_start ; const char * name_end ; while ( parse_from != ( ( void * ) 0 ) && ( * parse_from ) != '\0' && ( name_start = ( strstr ( parse_from , "%(" ) ) ) != ( ( void * ) 0 ) ) name_start += sizeof ( "%(" ) - 1; if ( ( * name_start ) == '\0' ) name_end = ( strstr ( name_start , ")s" ) ); if ( name_end != ( ( void * ) 0 ) ) cfg_option_t * x_opt ; apr_size_t len = ( name_end - name_start ) ; char * name = apr_pstrmemdup ( x_pool , name_start , len ) ; x_opt = find_option ( cfg , section -> name , name , ( ( void * ) 0 ) ); if ( x_opt != ( ( void * ) 0 ) ) const char * cstring ; make_string_from_option ( & cstring , cfg , section , x_opt , x_pool ); parse_from = name_end + ( sizeof ( ")s" ) - 1 ); parse_from = name_end + ( sizeof ( ")s" ) - 1 ); parse_from = ( ( void * ) 0 ); static void make_string_from_option(const char **valuep,svn_config_t *cfg,cfg_section_t *section,cfg_option_t *opt,apr_pool_t *x_pool) if ( ! opt -> expanded ) if ( opt -> value && strchr ( opt -> value , 37 ) ) opt -> expanded = ! 0; if ( ! x_pool ) if ( opt -> x_value ) opt -> x_value = ( apr_pstrmemdup ( cfg -> x_pool , opt -> x_value , strlen ( opt -> x_value ) ) ); if ( opt -> x_value ) * valuep = opt -> x_value; * valuep = opt -> value; | 152954/config.c | SARD | 0 |
void CWE121_Stack_Based_Buffer_Overflow__CWE805_int64_t_alloca_memcpy_66_bad() int64_t * data ; int64_t * dataArray [ 5 ] ; int64_t * dataBadBuffer = ( int64_t * ) ALLOCA ( 50 * sizeof ( int64_t ) ) ; data = dataBadBuffer; dataArray [ 2 ] = data; CWE121_Stack_Based_Buffer_Overflow__CWE805_int64_t_alloca_memcpy_66b_badSink ( dataArray ); void CWE121_Stack_Based_Buffer_Overflow__CWE805_int64_t_alloca_memcpy_66b_badSink(int64_t * dataArray[]) int64_t * data = dataArray [ 2 ] ; int64_t source [ 100 ] = { 0 } ; memcpy ( data , source , 100 * sizeof ( int64_t ) ); printLongLongLine ( data [ 0 ] ); void printLongLongLine (int64_t longLongIntNumber) printf ( "%lld\n" , longLongIntNumber ); | 64384/CWE121_Stack_Based_Buffer_Overflow__CWE805_int64_t_alloca_memcpy_66b.c | SARD | 3 |
char *file_gets(char *buf,int len,FILE_T file) unsigned int left ; unsigned int n ; unsigned char * eol ; if ( buf == ( ( void * ) 0 ) || len < 1 ) if ( file -> err ) if ( file -> seek ) file -> seek = 0; if ( gz_skip ( file , file -> skip ) == - 1 ) left = ( ( unsigned int ) len ) - 1; if ( left ) if ( file -> have == 0 ) if ( file -> err ) if ( fill_out_buffer ( file ) == - 1 ) if ( file -> have == 0 ) n = ( file -> have > left ? left : file -> have ); eol = ( ( unsigned char * ) ( memchr ( ( file -> next ) , 10 , n ) ) ); if ( eol != ( ( void * ) 0 ) ) n = ( ( unsigned int ) ( eol - file -> next ) ) + 1; file -> have -= n; file -> next += n; file -> pos += n; left -= n; while ( left && eol == ( ( void * ) 0 ) ) static int fill_out_buffer(FILE_T state) if ( state -> compression == 0 ) if ( gz_head ( state ) == - 1 ) if ( state -> have ) if ( state -> compression == 1 ) if ( raw_read ( state , state -> out , state -> size , & state -> have ) == - 1 ) static int raw_read(FILE_T state,unsigned char *buf,unsigned int count,unsigned int *have) int ret ; * have = 0; ret = ( read ( state -> fd , ( buf + * have ) , ( count - * have ) ) ); if ( ret <= 0 ) * have += ret; state -> raw_pos += ret; while ( * have < count ) if ( ret < 0 ) state -> err = * __errno_location ( ); state -> err_info = ( ( void * ) 0 ); if ( ret == 0 ) | 152463/file_wrappers.c | SARD | 0 |
static void goodB2G2() size_t data ; data = 0; if ( STATIC_CONST_FIVE == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( STATIC_CONST_FIVE == 5 ) char * myString ; if ( data > strlen ( HELLO_STRING ) && data < 100 ) myString = ( char * ) malloc ( data * sizeof ( char ) ); strcpy ( myString , HELLO_STRING ); free ( myString ); | 116988/CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_06.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_listen_socket_w32_spawnvp_52_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 ) | 120325/CWE78_OS_Command_Injection__char_listen_socket_w32_spawnvp_52a.c | SARD | 0 |
static void goodG2B() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; strcat ( data , "*.*" ); CWE78_OS_Command_Injection__char_console_w32_execv_54b_goodG2BSink ( data ); void CWE78_OS_Command_Injection__char_console_w32_execv_54b_goodG2BSink(char * data) CWE78_OS_Command_Injection__char_console_w32_execv_54c_goodG2BSink ( data ); void CWE78_OS_Command_Injection__char_console_w32_execv_54c_goodG2BSink(char * data) CWE78_OS_Command_Injection__char_console_w32_execv_54d_goodG2BSink ( data ); void CWE78_OS_Command_Injection__char_console_w32_execv_54d_goodG2BSink(char * data) CWE78_OS_Command_Injection__char_console_w32_execv_54e_goodG2BSink ( data ); void CWE78_OS_Command_Injection__char_console_w32_execv_54e_goodG2BSink(char * data) | 118647/CWE78_OS_Command_Injection__char_console_w32_execv_54a.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( FILENAME_MAX - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , stdin ) != NULL ) data [ dataLen ] = '\0'; badSink ( data ); void badSink(char * data) pFile = FOPEN ( data , "wb+" ); if ( pFile != NULL ) fclose ( pFile ); | 95802/CWE36_Absolute_Path_Traversal__char_console_fopen_41.cpp | SARD | 4 |
static void goodB2G() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( data != 0 ) printIntLine ( 100 / data ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 94979/CWE369_Divide_by_Zero__int_connect_socket_divide_18.c | SARD | 0 |
static void goodG2B2() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data = goodG2B2Source ( data ); static wchar_t * goodG2B2Source(wchar_t * data) if ( goodG2B2Static ) wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' return data ; wchar_t dest [ 50 ] = L "" wcsncpy ( dest , data , wcslen ( data ) ); | 72722/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_ncpy_21.c | SARD | 0 |
static void goodG2B() wchar_t * data ; CWE126_Buffer_Overread__malloc_wchar_t_memmove_67_structType myStruct ; data = NULL; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); wmemset ( data , L 'A' , 100 - 1 data [ 100 - 1 ] = L '\0' myStruct . structFirst = data; CWE126_Buffer_Overread__malloc_wchar_t_memmove_67b_goodG2BSink ( myStruct ); void CWE126_Buffer_Overread__malloc_wchar_t_memmove_67b_goodG2BSink(CWE126_Buffer_Overread__malloc_wchar_t_memmove_67_structType myStruct) wchar_t * data = myStruct . structFirst ; free ( data ); | 76513/CWE126_Buffer_Overread__malloc_wchar_t_memmove_67b.c | SARD | 0 |
void CWE114_Process_Control__w32_wchar_t_connect_socket_32_bad() wchar_t * data ; wchar_t * * dataPtr1 = & data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; wchar_t * data = * dataPtr1 ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); | 62249/CWE114_Process_Control__w32_wchar_t_connect_socket_32.c | SARD | 0 |
static void goodB2G1() twoIntsStruct * data ; data = NULL; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; data = ( twoIntsStruct * ) malloc ( 100 * sizeof ( twoIntsStruct ) ); data [ 0 ] . intOne = 0; data [ 0 ] . intTwo = 0; if ( globalReturnsFalse ( ) ) int globalReturnsFalse() return 0 ; free ( data ); | 100628/CWE401_Memory_Leak__twoIntsStruct_malloc_11.c | 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 ) 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 ) | 67559/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE129_connect_socket_67a.cpp | SARD | 0 |
apr_size_t svn__i64toa(char *dest,apr_int64_t number) if ( number >= 0 ) * dest = 45; return svn__ui64toa ( dest + 1 , ( ( apr_uint64_t ) ( 0 - number ) ) ) + 1 ; apr_size_t svn__ui64toa(char *dest,apr_uint64_t number) char buffer [ 21 ] ; apr_uint32_t reduced ; char * target ; if ( number < 100 ) buffer [ 21 - 1 ] = 0; target = & buffer [ 21 - 3 ]; while ( number >= 100000000 ) reduced = ( ( apr_uint32_t ) ( number % 100000000 ) ); number /= 100000000; memcpy ( ( target - 0 ) , decimal_table [ reduced % 100 ] , 2 ); reduced /= 100; memcpy ( ( target - 2 ) , decimal_table [ reduced % 100 ] , 2 ); reduced /= 100; memcpy ( ( target - 4 ) , decimal_table [ reduced % 100 ] , 2 ); reduced /= 100; memcpy ( ( target - 6 ) , decimal_table [ reduced % 100 ] , 2 ); target -= 8; memcpy ( target , decimal_table [ reduced % 100 ] , 2 ); target -= 2; memcpy ( target , decimal_table [ reduced ] , 2 ); memcpy ( dest , target , ( & buffer [ 21 ] - target ) ); return ( & buffer [ 21 ] - target - 1 ) ; | 152172/string.c | SARD | 0 |
static void goodB2G1() switch ( 6 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( data > strlen ( HELLO_STRING ) && data < 100 ) myString = new char [ data ]; strcpy ( myString , HELLO_STRING ); printLine ( myString ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] myString | 117477/CWE789_Uncontrolled_Mem_Alloc__new_char_connect_socket_15.cpp | SARD | 0 |
void bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) baseObject -> action ( data ); void CWE78_OS_Command_Injection__char_connect_socket_w32_execv_82_bad::action(char * data) | 118180/CWE78_OS_Command_Injection__char_connect_socket_w32_execv_82a.cpp | SARD | 0 |
static void goodG2B() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; strcpy ( data , "fixedstringtest" ); CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_53b_goodG2BSink ( data ); void CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_53b_goodG2BSink(char * data) CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_53c_goodG2BSink ( data ); void CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_53c_goodG2BSink(char * data) CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_53d_goodG2BSink ( data ); void CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_53d_goodG2BSink(char * data) goodG2BVaSink ( data , data ); static void goodG2BVaSink(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 ); | 80233/CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_53a.c | SARD | 0 |
void RollbackToSavepoint(List *options) TransactionState s = CurrentTransactionState ; TransactionState target ; ListCell * cell ; char * name = ( ( void * ) 0 ) ; for (cell = list_head(options); cell != ((void *)0); cell = cell -> next) DefElem * elem = cell -> data . ptr_value ; if ( strcmp ( ( elem -> defname ) , "savepoint_name" ) == 0 ) name = ( ( Value * ) ( elem -> arg ) ) -> val . str; for (target = s; ((const void *)target) != ((void *)0); target = target -> parent) if ( ( ( const void * ) ( target -> name ) ) != ( ( void * ) 0 ) && strcmp ( ( target -> name ) , name ) == 0 ) | 149304/xact.c | SARD | 0 |
void CWE127_Buffer_Underread__wchar_t_alloca_cpy_63_bad() wchar_t * data ; wchar_t * dataBuffer = ( wchar_t * ) ALLOCA ( 100 * sizeof ( wchar_t ) ) ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer - 8; CWE127_Buffer_Underread__wchar_t_alloca_cpy_63b_badSink ( & data ); void CWE127_Buffer_Underread__wchar_t_alloca_cpy_63b_badSink(wchar_t * * dataPtr) wchar_t * data = * dataPtr ; 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 ) | 78727/CWE127_Buffer_Underread__wchar_t_alloca_cpy_63b.c | SARD | 3 |
static void goodG2B() wchar_t * data ; data = NULL; CWE126_Buffer_Overread__new_wchar_t_memcpy_84_goodG2B * goodG2BObject = new CWE126_Buffer_Overread__new_wchar_t_memcpy_84_goodG2B ( data ) ; CWE126_Buffer_Overread__new_wchar_t_memcpy_84_goodG2B::CWE126_Buffer_Overread__new_wchar_t_memcpy_84_goodG2B(wchar_t * dataCopy) data = dataCopy; data = new wchar_t [ 100 ]; wmemset ( data , L 'A' , 100 - 1 data [ 100 - 1 ] = L '\0' delete goodG2BObject CWE126_Buffer_Overread__new_wchar_t_memcpy_84_goodG2B::~CWE126_Buffer_Overread__new_wchar_t_memcpy_84_goodG2B() wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' memcpy ( dest , data , wcslen ( dest ) * sizeof ( wchar_t ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 76761/CWE126_Buffer_Overread__new_wchar_t_memcpy_84_goodG2B.cpp | SARD | 0 |
void tropaean_fyi(int maugansville_ladonna,struct overlast_adaize troparion_counterfallacy) norrie_benedictional ( maugansville_ladonna , troparion_counterfallacy ); void norrie_benedictional(int gamari_elastin,struct overlast_adaize sclerosises_erythron) gamari_elastin --; if ( gamari_elastin > 0 ) tropaean_fyi ( gamari_elastin , sclerosises_erythron ); void tropaean_fyi(int maugansville_ladonna,struct overlast_adaize troparion_counterfallacy) norrie_benedictional ( maugansville_ladonna , troparion_counterfallacy ); void norrie_benedictional(int gamari_elastin,struct overlast_adaize sclerosises_erythron) char stonesoup_cmd_string [ 1000 ] = { 0 } ; int stonesoup_is_valid = 1 ; int stonesoup_i = 0 ; char stonesoup_base_cmd [ 1000 ] ; gamari_elastin --; if ( gamari_elastin > 0 ) gawney_perfectas = ( ( char * ) sclerosises_erythron . blepharoceridae_fator ); snprintf ( stonesoup_base_cmd , 1000 , "find %s -iname " , "/opt/stonesoup/workspace/testData/temp" ); for (; stonesoup_i < strlen(gawney_perfectas); ++stonesoup_i) if ( gawney_perfectas [ stonesoup_i ] == ';' ) if ( stonesoup_i == 0 || gawney_perfectas [ stonesoup_i - 1 ] != '\\' ) stonesoup_is_valid = 0; if ( stonesoup_is_valid == 1 ) snprintf ( stonesoup_cmd_string , 1000 , "%s%s" , stonesoup_base_cmd , gawney_perfectas ); stonesoup_fpipe = popen ( stonesoup_cmd_string , "r" ); if ( stonesoup_fpipe != 0 ) while ( fgets ( stonesoup_buffer , 100 , stonesoup_fpipe ) != 0 ) stonesoup_printf ( stonesoup_buffer ); pclose ( stonesoup_fpipe ); | 152361/mux.c | SARD | 15 |
void CWE126_Buffer_Overread__char_declare_loop_68b_badSink() char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; destLen = strlen ( dest ); for (i = 0; i < destLen; i++) dest [ i ] = data [ i ]; dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 76130/CWE126_Buffer_Overread__char_declare_loop_68b.c | SARD | 3 |
static void goodG2B1() size_t data ; data = 0; if ( globalReturnsFalse ( ) ) int globalReturnsFalse() return 0 ; data = 20; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; if ( data > strlen ( HELLO_STRING ) ) | 117617/CWE789_Uncontrolled_Mem_Alloc__new_char_listen_socket_11.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) 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 ) fclose ( stonesoup_files ); | 151737/pmsignal.c | SARD | 0 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; data [ dataLen ] = '\0'; char * dataCopy = data ; char * data = dataCopy ; if ( sscanf ( data , "%d" , & n ) == 1 ) | 108998/CWE606_Unchecked_Loop_Condition__char_console_31.c | SARD | 0 |
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 ) switch ( ost -> st -> codec -> codec_type ) encode = avcodec_encode_audio2; encode = avcodec_encode_video2; stop_encoding = 1; if ( encode ) int got_packet ; update_benchmark ( ( ( void * ) 0 ) ); 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 ); | 151614/ffmpeg.c | SARD | 0 |
static void goodG2B1() char * data ; data = NULL; data = goodG2B1Source ( data ); static char * goodG2B1Source(char * data) if ( goodG2B1Static ) data = new char [ 10 + 1 ]; return data ; 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 | 67826/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE193_char_cpy_21.cpp | SARD | 0 |
void CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54_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 ) | 86318/CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54a.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; if ( staticFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; while ( 0 ) pFile = FOPEN ( data , "wb+" ); if ( pFile != NULL ) fclose ( pFile ); | 95544/CWE36_Absolute_Path_Traversal__char_connect_socket_fopen_07.cpp | SARD | 4 |
guint oid_string2subid(const char *str,guint32 **subids_p) char * semipendulous_organographical ; if ( __sync_bool_compare_and_swap ( & cheeked_unlace , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) stonesoup_read_taint ( & semipendulous_organographical , "DENATURED_RIBSTON" ); void stonesoup_read_taint(char** stonesoup_tainted_buff, char* stonesoup_env_var_name) if ( getenv ( "STONESOUP_DISABLE_WEAKNESS" ) == NULL || strcmp ( getenv ( "STONESOUP_DISABLE_WEAKNESS" ) , "1" ) != 0 ) stonesoup_tainted_file_name = getenv ( stonesoup_env_var_name ); stonesoup_tainted_file = fopen ( stonesoup_tainted_file_name , "rb" ); if ( stonesoup_tainted_file != 0 ) fseek ( stonesoup_tainted_file , 0L , 2 ); stonesoup_lsize = ftell ( stonesoup_tainted_file ); rewind ( stonesoup_tainted_file ); * stonesoup_tainted_buff = ( ( char * ) ( malloc ( sizeof ( char ) * ( stonesoup_lsize + 1 ) ) ) ); if ( * stonesoup_tainted_buff != 0 ) stonesoup_result = fread ( * stonesoup_tainted_buff , 1 , stonesoup_lsize , stonesoup_tainted_file ); ( * stonesoup_tainted_buff ) [ stonesoup_lsize ] = '\0'; if ( stonesoup_tainted_file != 0 ) fclose ( stonesoup_tainted_file ); * stonesoup_tainted_buff = NULL; | 151494/oids.c | SARD | 0 |
void CWE195_Signed_to_Unsigned_Conversion_Error__negative_memmove_05_bad() char source [ 100 ] ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memmove ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 88306/CWE195_Signed_to_Unsigned_Conversion_Error__negative_memmove_05.c | SARD | 20 |
static void goodB2G() char * password ; char passwordBuffer [ 100 ] = "" ; password = passwordBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t passwordLen = strlen ( password ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( password + passwordLen ) , ( 100 - passwordLen - 1 ) * sizeof ( char ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) password [ passwordLen + recvResult / sizeof ( char ) ] = '\0'; while ( 0 ) HCRYPTPROV hCryptProv = 0 ; HCRYPTHASH hHash = 0 ; HCRYPTKEY hKey = 0 ; char hashData [ 100 ] = HASH_INPUT ; BYTE payload [ ( 100 - 1 ) * sizeof ( char ) ] ; DWORD payloadBytes ; payloadBytes = decodeHexChars ( payload , sizeof ( payload ) , password ); size_t decodeHexChars(unsigned char * bytes, size_t numBytes, const char * hex) size_t numWritten = 0 ; while ( numWritten < numBytes && isxdigit ( hex [ 2 * numWritten ] ) && isxdigit ( hex [ 2 * numWritten + 1 ] ) ) int byte ; bytes [ numWritten ] = ( unsigned char ) byte; return numWritten ; if ( ! CryptAcquireContext ( & hCryptProv , NULL , MS_ENH_RSA_AES_PROV , PROV_RSA_AES , 0 ) ) if ( ! CryptCreateHash ( hCryptProv , CALG_SHA_256 , 0 , 0 , & hHash ) ) if ( ! CryptHashData ( hHash , ( BYTE * ) hashData , strlen ( hashData ) , 0 ) ) if ( ! CryptDeriveKey ( hCryptProv , CALG_AES_256 , hHash , 0 , & hKey ) ) if ( ! CryptDecrypt ( hKey , 0 , 1 , 0 , payload , & payloadBytes ) ) while ( 0 ) | 94146/CWE319_Cleartext_Tx_Sensitive_Info__w32_char_listen_socket_01.c | SARD | 0 |
static void goodB2G2() if ( 1 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( data < 0 ) if ( data > ( INT_MIN / 2 ) ) int result = data * 2 ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 85567/CWE191_Integer_Underflow__int_listen_socket_multiply_02.c | SARD | 0 |
void CWE124_Buffer_Underwrite__malloc_wchar_t_memmove_67_bad() wchar_t * dataBuffer = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; data = dataBuffer - 8; myStruct . structFirst = data; CWE124_Buffer_Underwrite__malloc_wchar_t_memmove_67b_badSink ( myStruct ); void CWE124_Buffer_Underwrite__malloc_wchar_t_memmove_67b_badSink(CWE124_Buffer_Underwrite__malloc_wchar_t_memmove_67_structType myStruct) wchar_t * data = myStruct . structFirst ; memmove ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 74661/CWE124_Buffer_Underwrite__malloc_wchar_t_memmove_67a.c | SARD | 0 |
void bad() char * data ; data = NULL; data = new char [ 50 ]; memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; badSink ( & data ); void badSink(char * * dataPtr) char * data = * dataPtr ; 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 ); | 76605/CWE126_Buffer_Overread__new_char_memcpy_63a.cpp | SARD | 0 |
static void goodG2B2() wchar_t * data ; data = NULL; if ( GLOBAL_CONST_TRUE ) wchar_t * dataBuffer = new wchar_t [ 100 ] ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcsncpy ( data , source , 100 - 1 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 75158/CWE124_Buffer_Underwrite__new_wchar_t_ncpy_09.cpp | SARD | 0 |
static void good1() if ( staticFalse ) wchar_t * data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; wchar_t * tmpData ; wcscpy ( data , L "A String" ) tmpData = ( wchar_t * ) realloc ( data , ( 130000 ) * sizeof ( wchar_t ) ); if ( tmpData != NULL ) data = tmpData; wcscpy ( data , L "New String" ) free ( data ); | 99728/CWE401_Memory_Leak__malloc_realloc_wchar_t_05.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_console_system_54_bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; 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'; | 118599/CWE78_OS_Command_Injection__char_console_system_54a.c | SARD | 0 |
static void goodG2B1() short data ; data = 0; data = CWE194_Unexpected_Sign_Extension__fgets_strncpy_22_goodG2B1Source ( data ); short CWE194_Unexpected_Sign_Extension__fgets_strncpy_22_goodG2B1Source(short data) if ( CWE194_Unexpected_Sign_Extension__fgets_strncpy_22_goodG2B1Global ) data = 100 - 1; return data ; char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) strncpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 86641/CWE194_Unexpected_Sign_Extension__fgets_strncpy_22a.c | SARD | 0 |
int avcodec_decode_audio3(AVCodecContext *avctx,int16_t *samples,int *frame_size_ptr,AVPacket *avpkt) int ret ; if ( avctx -> get_buffer != avcodec_default_get_buffer ) avctx -> get_buffer = avcodec_default_get_buffer; avctx -> release_buffer = avcodec_default_release_buffer; ret = avcodec_decode_audio4 ( avctx , & frame , & got_frame , avpkt ); int avcodec_decode_audio4(AVCodecContext *avctx,AVFrame *frame,int *got_frame_ptr,const AVPacket *avpkt) * got_frame_ptr = 0; if ( ! avpkt -> data && avpkt -> size ) if ( ( avctx -> codec -> type ) != AVMEDIA_TYPE_AUDIO ) if ( avctx -> codec -> capabilities & 0x20 || avpkt -> size ) avctx -> pkt = & tmp; ret = ( ( avctx -> codec -> decode ) ( avctx , frame , got_frame_ptr , & tmp ) ); if ( ret >= 0 && * got_frame_ptr ) avctx -> frame_number ++; frame -> pkt_dts = avpkt -> dts; if ( frame -> format == AV_SAMPLE_FMT_NONE ) frame -> format = ( avctx -> sample_fmt ); if ( ! frame -> channel_layout ) frame -> channel_layout = avctx -> channel_layout; if ( ! frame -> sample_rate ) frame -> sample_rate = avctx -> sample_rate; add_metadata_from_side_data ( avctx , frame ); static int add_metadata_from_side_data(AVCodecContext *avctx,AVFrame *frame) int size ; const uint8_t * side_metadata ; const uint8_t * end ; side_metadata = ( av_packet_get_side_data ( avctx -> pkt , AV_PKT_DATA_STRINGS_METADATA , & size ) ); if ( ! side_metadata ) end = side_metadata + size; while ( side_metadata < end ) const uint8_t * key = side_metadata ; const uint8_t * val = side_metadata + strlen ( key ) + 1 ; int ret = av_dict_set ( ff_frame_get_metadatap ( frame ) , key , val , 0 ) ; if ( ret < 0 ) side_metadata = val + strlen ( val ) + 1; return ret ; | 150417/utils.c | SARD | 0 |