func
stringlengths 181
23.6k
| path
stringlengths 12
123
| source
stringclasses 2
values | label
int64 0
40
|
---|---|---|---|
void CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_malloc_68_bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_malloc_68_badData = data; | 87478/CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_malloc_68a.c | SARD | 0 |
static void goodG2B() char * data ; char * * dataPtr1 = & data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; char * data = * dataPtr1 ; strcpy ( data , GOOD_OS_COMMAND ); * dataPtr1 = data; pipe = POPEN ( data , "wb" ); if ( pipe != NULL ) PCLOSE ( pipe ); | 102685/CWE426_Untrusted_Search_Path__char_popen_32.c | SARD | 0 |
void bad() list < int > dataList ; badSink ( dataList ); void badSink(list<int> dataList) int data = dataList . back ( ) ; size_t i ; int * intPointer ; intPointer = ( int * ) malloc ( data * sizeof ( int ) ); for (i = 0; i < (size_t)data; i++) intPointer [ i ] = 0; free ( intPointer ); | 110450/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fixed_73b.cpp | SARD | 3 |
ep_stack_t ep_stack_new() ep_stack_t s = ( struct _ep_stack_frame_t * * ) ( ep_alloc ( sizeof ( struct _ep_stack_frame_t * ) ) ) ; void *ep_alloc(size_t size) return emem_alloc ( size , & ep_packet_mem ) ; static void *emem_alloc(size_t size,emem_header_t *mem) void * buf = ( mem -> memory_alloc ) ( size , mem ) ; return buf ; * s = ( ( struct _ep_stack_frame_t * ) ( ep_alloc0 ( sizeof ( struct _ep_stack_frame_t ) ) ) ); void *ep_alloc0(size_t size) return memset ( ep_alloc ( size ) , '\0' , size ) ; void *ep_alloc(size_t size) return emem_alloc ( size , & ep_packet_mem ) ; | 150094/emem.c | SARD | 0 |
void CRYPTO_dbg_realloc(void *addr1,void *addr2,int num,const char *file,int line,int before_p) switch ( before_p ) if ( addr2 == ( ( void * ) 0 ) ) if ( addr1 == ( ( void * ) 0 ) ) CRYPTO_dbg_malloc ( addr2 , num , file , line , 128 | before_p ); void CRYPTO_dbg_malloc(void *addr,int num,const char *file,int line,int before_p) MEM * m ; switch ( before_p & 127 ) if ( addr == ( ( void * ) 0 ) ) if ( CRYPTO_is_mem_check_on ( ) ) int CRYPTO_is_mem_check_on() int ret = 0 ; if ( mh_mode & 0x1 ) ret = mh_mode & 0x2 || CRYPTO_THREADID_cmp ( ( & disabling_threadid ) , ( & cur ) ); return ret ; if ( ( m = ( ( MEM * ) ( CRYPTO_malloc ( ( ( int ) ( sizeof ( MEM ) ) ) , "mem_dbg.c" , 498 ) ) ) ) == ( ( void * ) 0 ) ) if ( mh == ( ( void * ) 0 ) ) if ( ( mh = ( ( struct lhash_st_MEM * ) ( lh_new ( mem_LHASH_HASH , mem_LHASH_COMP ) ) ) ) == ( ( void * ) 0 ) ) m -> addr = addr; m -> file = file; m -> line = line; m -> num = num; if ( options & 0x2 ) memset ( ( & m -> threadid ) , 0 , sizeof ( m -> threadid ) ); m -> order = order; m -> order = order ++; m -> time = time ( ( ( void * ) 0 ) ); | 150553/mem_dbg.c | SARD | 0 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfainit ( d ); void dfainit(struct dfa *d) memset ( d , 0 , sizeof ( ( * d ) ) ); d -> calloc = 1; d -> charclasses = ( ( sizeof ( ( * d -> charclasses ) ) == 1 ? xmalloc ( d -> calloc ) : xnmalloc ( d -> calloc , sizeof ( ( * d -> charclasses ) ) ) ) ); d -> talloc = 1; d -> tokens = ( ( sizeof ( ( * d -> tokens ) ) == 1 ? xmalloc ( d -> talloc ) : xnmalloc ( d -> talloc , sizeof ( ( * d -> tokens ) ) ) ) ); d -> mb_cur_max = ( __ctype_get_mb_cur_max ( ) ); if ( d -> mb_cur_max > 1 ) d -> nmultibyte_prop = 1; d -> multibyte_prop = ( ( sizeof ( ( * d -> multibyte_prop ) ) == 1 ? xmalloc ( d -> nmultibyte_prop ) : xnmalloc ( d -> nmultibyte_prop , sizeof ( ( * d -> multibyte_prop ) ) ) ) ); d -> mbcsets_alloc = 1; d -> mbcsets = ( ( sizeof ( ( * d -> mbcsets ) ) == 1 ? xmalloc ( d -> mbcsets_alloc ) : xnmalloc ( d -> mbcsets_alloc , sizeof ( ( * d -> mbcsets ) ) ) ) ); | 149307/dfa.c | SARD | 0 |
static void goodB2G() int data ; data = - 1; while ( 1 ) data = RAND32 ( ); while ( 1 ) int i ; int * buffer = ( int * ) malloc ( 10 * sizeof ( int ) ) ; for (i = 0; i < 10; i++) buffer [ i ] = 0; if ( data >= 0 && data < ( 10 ) ) buffer [ data ] = 1; free ( buffer ); | 70703/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_rand_16.c | SARD | 0 |
static void goodG2BSink() char * data = goodG2BData ; 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 ); | 74890/CWE124_Buffer_Underwrite__new_char_memmove_45.cpp | SARD | 0 |
svn_error_t *svn_config_get_server_setting_bool(svn_config_t *cfg,svn_boolean_t *valuep,const char *server_group,const char *option_name,svn_boolean_t default_value) const char * tmp_value ; tmp_value = svn_config_get_server_setting ( cfg , server_group , option_name , ( ( void * ) 0 ) ); const char *svn_config_get_server_setting(svn_config_t *cfg,const char *server_group,const char *option_name,const char *default_value) const char * retval ; svn_config_get ( cfg , & retval , "global" , option_name , default_value ); void svn_config_get(svn_config_t *cfg,const char **valuep,const char *section,const char *option,const char *default_value) if ( cfg ) cfg_option_t * opt = find_option ( cfg , section , option , & sec ) ; if ( opt != ( ( void * ) 0 ) ) if ( default_value && strchr ( default_value , 37 ) ) | 152954/config.c | SARD | 0 |
static void goodG2B() wchar_t * data ; CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_34_unionType myUnion ; wchar_t dataGoodBuffer [ 100 ] ; data = dataGoodBuffer; data [ 0 ] = L '\0' myUnion . unionFirst = data; wchar_t * data = myUnion . unionSecond ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcsncat ( data , source , 100 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 65413/CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_34.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 ) if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) * end = saved_end; s = transit_state ( d , s , & p ); trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) int maxlen = 0 ; size_t i ; size_t nelem = d -> states [ s ] . mbps . nelem ; 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 ) status_transit_state rs ; rs = transit_state_singlebyte ( d , s , * pp , & s1 ); static status_transit_state transit_state_singlebyte(struct dfa *d,state_num s,const unsigned char *p,state_num *next_state) state_num * t ; state_num works = s ; status_transit_state rval = TRANSIT_STATE_IN_PROGRESS ; while ( rval == TRANSIT_STATE_IN_PROGRESS ) if ( ( t = d -> trans [ works ] ) != ( ( void * ) 0 ) ) works = t [ * p ]; rval = TRANSIT_STATE_DONE; if ( works < 0 ) works = 0; if ( works < 0 ) works = 0; if ( d -> fails [ works ] ) works = d -> fails [ works ] [ * p ]; rval = TRANSIT_STATE_DONE; build_state ( works , d ); static void build_state(state_num s,struct dfa *d) state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) free ( d -> fails [ i ] ); d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); | 153811/dfa.c | SARD | 0 |
void bad() int data ; map < int , int > dataMap ; data = - 1; char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; badSink ( dataMap ); void badSink(map<int, int> dataMap) int data = dataMap [ 2 ] ; int * intPointer ; intPointer = ( int * ) malloc ( data * sizeof ( int ) ); intPointer [ i ] = 0; printIntLine ( intPointer [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( intPointer ); | 110403/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fgets_74b.cpp | SARD | 3 |
void CWE114_Process_Control__w32_wchar_t_relativePath_41_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; wcscpy ( data , L "winsrv.dll" ) CWE114_Process_Control__w32_wchar_t_relativePath_41_badSink ( data ); void CWE114_Process_Control__w32_wchar_t_relativePath_41_badSink(wchar_t * data) HMODULE hModule ; hModule = LoadLibraryW ( data ); if ( hModule != NULL ) FreeLibrary ( hModule ); | 62492/CWE114_Process_Control__w32_wchar_t_relativePath_41.c | SARD | 14 |
static void goodB2G() char * data ; data = NULL; data = CWE690_NULL_Deref_From_Return__char_malloc_61b_goodB2GSource ( data ); char * CWE690_NULL_Deref_From_Return__char_malloc_61b_goodB2GSource(char * data) data = ( char * ) malloc ( 20 * sizeof ( char ) ); return data ; if ( data != NULL ) strcpy ( data , "Initialize" ); free ( data ); | 111059/CWE690_NULL_Deref_From_Return__char_malloc_61a.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__CWE131_loop_13_bad() int * data ; data = NULL; if ( GLOBAL_CONST_FIVE == 5 ) data = ( int * ) malloc ( 10 ); int source [ 10 ] = { 0 } ; size_t i ; for (i = 0; i < 10; i++) data [ i ] = source [ i ]; free ( data ); | 69788/CWE122_Heap_Based_Buffer_Overflow__CWE131_loop_13.c | SARD | 3 |