func
stringlengths 181
23.6k
| path
stringlengths 12
123
| source
stringclasses 2
values | label
int64 0
40
|
---|---|---|---|
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( GLOBAL_CONST_FIVE == 5 ) 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 ) | 80502/CWE134_Uncontrolled_Format_String__char_listen_socket_w32_vsnprintf_13.c | SARD | 0 |
static void goodG2B1() char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memcpy ( dest , data , strlen ( dest ) * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 76143/CWE126_Buffer_Overread__char_declare_memcpy_08.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_newline ; if ( d -> searchflag ) separate_contexts = state_separate_contexts ( ( & follows ) ); if ( separate_contexts & 4 ) state_newline = state_index ( d , ( & follows ) , 4 ); static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; state_num i ; state_num j ; for (i = 0; i < s -> nelem; ++i) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; for (i = 0; i < d -> sindex; ++i) if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; while ( 0 ) d -> states [ i ] . hash = hash; copy ( s , & d -> states [ i ] . elems ); 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; | 152346/dfa.c | SARD | 0 |
void waitForSig() int fd ; char outStr [ 25 ] = { 0 } ; char filename [ 500 ] = { 0 } ; sprintf ( outStr , "%d.pid" , getpid ( ) ); strcat ( filename , "/opt/stonesoup/workspace/testData/" ); strcat ( filename , outStr ); if ( ( fd = open ( filename , O_CREAT | O_WRONLY , 0666 ) ) == - 1 ) stonesoup_readFile ( stonesoupData -> file1 ); void stonesoup_readFile(char *filename) FILE * fifo ; char ch ; fifo = fopen ( filename , "r" ); if ( fifo != NULL ) while ( ( ch = fgetc ( fifo ) ) != EOF ) stonesoup_printf ( "%c" , ch ); | 150042/dfa.c | SARD | 0 |
void CWE328_Reversible_One_Way_Hash__w32_MD2_02_bad() if ( 1 ) char password [ PASSWORD_INPUT_SIZE ] ; if ( fgets ( password , PASSWORD_INPUT_SIZE , stdin ) == NULL ) replace = strchr ( password , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( password , '\n' ); if ( replace ) * replace = '\0'; if ( ! CryptHashData ( hHash , ( BYTE * ) password , strlen ( password ) , 0 ) ) | 94513/CWE328_Reversible_One_Way_Hash__w32_MD2_02.c | SARD | 0 |
static int handle_hold_button(struct skinny_subchannel *sub) if ( ! sub ) if ( sub -> related ) activatesub ( sub -> related , SUBSTATE_CONNECTED ); static void activatesub(struct skinny_subchannel *sub, int state) struct skinny_line * l = sub -> line ; if ( sub == l -> activesub ) setsubstate ( sub , state ); static void setsubstate(struct skinny_subchannel *sub, int state) struct skinny_line * l = sub -> line ; struct skinny_subline * subline = sub -> subline ; struct skinny_device * d = l -> device ; struct ast_channel * c = sub -> owner ; int actualstate = state ; if ( sub -> substate == SUBSTATE_ONHOOK ) if ( state != SUBSTATE_RINGIN && sub -> aa_sched ) sub -> aa_sched = 0; sub -> aa_beep = 0; sub -> aa_mute = 0; if ( ( state == SUBSTATE_RINGIN ) && ( ( d -> hookstate == SKINNY_OFFHOOK ) || ( AST_LIST_NEXT ( AST_LIST_FIRST ( & l -> sub ) , list ) ) ) ) actualstate = SUBSTATE_CALLWAIT; if ( ( state == SUBSTATE_CONNECTED ) && ( ! subline ) && ( AST_LIST_FIRST ( & l -> sublines ) ) ) const char * slastation ; struct skinny_subline * tmpsubline ; slastation = pbx_builtin_getvar_helper ( c , "SLASTATION" ); if ( slastation ) subline = tmpsubline; if ( subline ) subline -> sub = sub; sub -> subline = subline; subline -> callid = sub -> callid; if ( subline ) switch ( actualstate ) if ( sub -> substate != SUBSTATE_CONNECTED ) ast_log ( LOG_WARNING , "Cannot set substate to SUBSTATE_HOLD from %s (on call-%d)\n" , substate2str ( sub -> substate ) , sub -> callid ); static char *substate2str(int ind) char * tmp ; switch ( ind ) if ( ! ( tmp = ast_threadstorage_get ( & substate2str_threadbuf , SUBSTATE2STR_BUFSIZE ) ) ) snprintf ( tmp , SUBSTATE2STR_BUFSIZE , "UNKNOWN-%d" , ind ); return tmp ; | 148809/chan_skinny.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_memmove_09_bad() wchar_t * data ; if ( GLOBAL_CONST_TRUE ) data = ( wchar_t * ) malloc ( 50 * sizeof ( wchar_t ) ); memmove ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 72040/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_memmove_09.c | SARD | 3 |
static void goodG2B() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_ncat_84_goodG2B * goodG2BObject = new CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_ncat_84_goodG2B ( data ) ; CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_ncat_84_goodG2B::CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_ncat_84_goodG2B(wchar_t * dataCopy) data = dataCopy; wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' delete goodG2BObject CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_ncat_84_goodG2B::~CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_ncat_84_goodG2B() free ( data ); | 72703/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_ncat_84_goodG2B.cpp | SARD | 0 |
void CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_09_bad() size_t data ; data = 0; if ( GLOBAL_CONST_TRUE ) data = rand ( ); if ( GLOBAL_CONST_TRUE ) wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) ) myString = ( wchar_t * ) malloc ( data * sizeof ( wchar_t ) ); wcscpy ( myString , HELLO_STRING ); free ( myString ); | 117423/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_09.c | SARD | 10 |
static void goodG2B1() wchar_t * data ; wchar_t dataBuffer [ 100 ] ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' if ( STATIC_CONST_FIVE != 5 ) data = dataBuffer; 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 ) | 75403/CWE124_Buffer_Underwrite__wchar_t_declare_cpy_06.c | SARD | 0 |
void bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] ; data = dataBuffer; size_t sourceLen ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' sourceLen = wcslen ( source ); wcsncat ( data , source , sourceLen ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 109923/CWE665_Improper_Initialization__wchar_t_ncat_43.cpp | SARD | 0 |
static void goodG2B() int data ; data = - 1; data = 100 - 1; CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_malloc_63b_goodG2BSink ( & data ); void CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_malloc_63b_goodG2BSink(int * dataPtr) int data = * dataPtr ; if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; free ( dataBuffer ); | 87857/CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_malloc_63b.c | SARD | 0 |
static void goodG2B() list < char * > dataList ; goodG2BSink ( dataList ); void goodG2BSink(list<char *> dataList) char * data = dataList . back ( ) ; 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 ); | 74376/CWE124_Buffer_Underwrite__malloc_char_memcpy_73b.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 ; if ( server_group ) svn_config_get ( cfg , & retval , server_group , option_name , retval ); 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 ) ) make_string_from_option ( & cstring , cfg , section , x_opt , x_pool ); len = ( name_start - ( sizeof ( "%(" ) - 1 ) - copy_from ); if ( buf == ( ( void * ) 0 ) ) buf = svn_stringbuf_ncreate ( copy_from , len , x_pool ); svn_stringbuf_appendbytes ( buf , copy_from , len ); svn_stringbuf_appendcstr ( buf , cstring ); parse_from = name_end + ( sizeof ( ")s" ) - 1 ); copy_from = parse_from; parse_from = name_end + ( sizeof ( ")s" ) - 1 ); parse_from = ( ( void * ) 0 ); if ( buf != ( ( void * ) 0 ) ) svn_stringbuf_appendcstr ( buf , copy_from ); * opt_x_valuep = ( buf -> data ); * opt_x_valuep = ( ( void * ) 0 ); | 153813/config.c | SARD | 0 |
static void goodG2B() list < char * > dataList ; goodG2BSink ( dataList ); void goodG2BSink(list<char *> dataList) char * data = dataList . back ( ) ; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncat ( data , source , 100 ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] data | 68474/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_ncat_73b.cpp | SARD | 0 |
void bad() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); badSource ( data ); static void badSource(wchar_t * &data) size_t dataLen = wcslen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = L '\0' for ( * data != L '\0' data ++ ) if ( * data == SEARCH_CHAR ) free ( data ); | 112977/CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_43.cpp | SARD | 1 |
void CWE78_OS_Command_Injection__char_console_w32spawnl_17_bad() int i ; char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; for(i = 0; i < 1; i++) 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'; | 118871/CWE78_OS_Command_Injection__char_console_w32spawnl_17.c | SARD | 0 |
static void goodG2B() wchar_t * data ; wchar_t dataGoodBuffer [ 10 + 1 ] ; data = dataGoodBuffer; data [ 0 ] = L '\0' wchar_t * dataCopy = data ; wchar_t * data = dataCopy ; wchar_t source [ 10 + 1 ] = SRC_STRING ; memcpy ( data , source , ( wcslen ( source ) + 1 ) * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 63730/CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_declare_memcpy_31.c | SARD | 0 |
void pedicellation_azoxybenzoic(void (*dissentaneous_sparklessly)(void **)) void * yancey_tuesdays = 0 ; if ( ( ( char * ) yancey_tuesdays ) != 0 ) gasterotrichan_retrocervical = erwin_rhopalocerous ( yancey_tuesdays ); void *erwin_rhopalocerous(void *percoids_tetrazzini) return percoids_tetrazzini ; cotemporaries_glassworks = ( ( char * ) ( ( char * ) gasterotrichan_retrocervical ) ); stonesoup_str = malloc ( sizeof ( char ) * ( strlen ( cotemporaries_glassworks ) + 1 ) ); stonesoup_sleep_file = malloc ( sizeof ( char ) * ( strlen ( cotemporaries_glassworks ) + 1 ) ); if ( stonesoup_str != NULL && stonesoup_sleep_file != NULL && ( sscanf ( cotemporaries_glassworks , "%s %s" , stonesoup_sleep_file , stonesoup_str ) == 2 ) && ( strlen ( stonesoup_str ) != 0 ) && ( strlen ( stonesoup_sleep_file ) != 0 ) ) if ( stonesoup_path_is_relative ( stonesoup_str ) ) int stonesoup_path_is_relative(char *path) chr = strchr ( path , '/' ); if ( chr == 0 ) return 1 ; return 0 ; stonesoup_abs_path = stonesoup_get_absolute_path ( stonesoup_str ); char * stonesoup_get_absolute_path(char * path) char * abs_path = malloc ( sizeof ( char ) * ( strlen ( "/opt/stonesoup/workspace/testData/" ) * strlen ( path ) + 1 ) ) ; if ( abs_path == NULL ) strcpy ( abs_path , "/opt/stonesoup/workspace/testData/" ); tracepoint ( stonesoup_trace , variable_buffer , "abs_path" , abs_path , "Generated absolute path" ); strcat ( abs_path , path ); return abs_path ; | 150087/pgstat.c | SARD | 0 |
static void PgstatCollectorMain(int argc,char *argv[]) pgstat_write_statsfile ( ( ( bool ) 1 ) ); static void pgstat_write_statsfile(bool permanent) PgStat_StatDBEntry * dbentry ; PgStat_StatFuncEntry * funcentry ; FILE * fpout ; const char * tmpfile = ( permanent ? "global/pgstat.tmp" : pgstat_stat_tmpname ) ; fpout = AllocateFile ( tmpfile , "w" ); if ( fpout == ( ( void * ) 0 ) ) while ( ( dbentry = ( ( PgStat_StatDBEntry * ) ( hash_seq_search ( & hstat ) ) ) ) != ( ( void * ) 0 ) ) while ( ( funcentry = ( ( PgStat_StatFuncEntry * ) ( hash_seq_search ( & fstat ) ) ) ) != ( ( void * ) 0 ) ) fputc ( 'F' , fpout ); | 153810/pgstat.c | SARD | 0 |
void CWE666_Operation_on_Resource_in_Wrong_Phase_of_Lifetime__accept_listen_bind_04_bad() if ( STATIC_CONST_TRUE ) char data [ 100 ] = "" ; 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 ); 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 ) while ( 0 ) | 109966/CWE666_Operation_on_Resource_in_Wrong_Phase_of_Lifetime__accept_listen_bind_04.c | SARD | 36 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfaanalyze ( d , searchflag ); void dfaanalyze(struct dfa *d,int searchflag) size_t * nlastpos ; size_t * o_nlast ; d -> searchflag = searchflag; nlastpos = ( ( sizeof ( ( * nlastpos ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nlastpos ) ) ) ) ); while ( 0 ) o_nlast = nlastpos; free ( o_nlast ); | 153249/dfa.c | SARD | 0 |
void bad() int i ; char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; for(i = 0; i < 1; i++) 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 ) | 89788/CWE23_Relative_Path_Traversal__char_connect_socket_w32CreateFile_17.cpp | SARD | 0 |
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticTrue ) 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 ) | 79198/CWE134_Uncontrolled_Format_String__char_connect_socket_snprintf_05.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE129_rand_04_bad() if ( STATIC_CONST_TRUE ) 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 ); | 70691/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_rand_04.c | SARD | 3 |
void CWE78_OS_Command_Injection__wchar_t_connect_socket_w32_spawnlp_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 ); | 120652/CWE78_OS_Command_Injection__wchar_t_connect_socket_w32_spawnlp_32.c | SARD | 0 |
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) state_num s ; state_num s1 ; const unsigned char * p ; state_num * * trans ; state_num * t ; unsigned char eol = eolbyte ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; * end = eol; if ( d -> mb_cur_max > 1 ) while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) if ( p > buf_end ) s1 = s; if ( s == 0 ) if ( ( ( char * ) p ) >= end ) if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) s = transit_state ( d , s , & p ); trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) state_num s1 ; int mbclen ; int maxlen = 0 ; size_t i ; size_t nelem = d -> states [ s ] . mbps . nelem ; position_set follows ; const unsigned char * p1 = * pp ; wchar_t wc ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); while ( * pp - p1 < maxlen ) transit_state_consume_1char ( d , s1 , pp , ( ( void * ) 0 ) , & mbclen , & follows ); wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static status_transit_state transit_state_consume_1char(struct dfa *d,state_num s,const unsigned char **pp,int *match_lens,int *mbclen,position_set *pps) int k ; state_num s1 ; state_num s2 ; int * work_mbls ; * mbclen = ( mblen_buf [ * pp - buf_begin ] == 0 ? 1 : mblen_buf [ * pp - buf_begin ] ); s1 = s; for (k = 0; k < *mbclen; k++) s2 = s1; rs = transit_state_singlebyte ( d , s2 , ( * pp ) ++ , & s1 ); if ( match_lens == ( ( void * ) 0 ) && d -> states [ s ] . mbps . nelem != 0 ) work_mbls = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); work_mbls = match_lens; if ( match_lens == ( ( void * ) 0 ) && work_mbls != ( ( void * ) 0 ) ) free ( work_mbls ); | 149307/dfa.c | SARD | 0 |
int avformat_open_input(AVFormatContext **ps,const char *filename,AVInputFormat *fmt,AVDictionary **options) AVFormatContext * s = * ps ; if ( ! s && ! ( s = avformat_alloc_context ( ) ) ) if ( ! s -> av_class ) if ( fmt ) s -> iformat = fmt; if ( ( ret = av_opt_set_dict ( s , & tmp ) ) < 0 ) if ( ( ret = init_input ( s , filename , & tmp ) ) < 0 ) static int init_input(AVFormatContext *s,const char *filename,AVDictionary **options) int ret ; if ( s -> pb ) if ( s -> iformat && s -> iformat -> flags & 0x1 || ! s -> iformat && ( s -> iformat = av_probe_input_format2 ( & pd , 0 , & score ) ) ) AVInputFormat *av_probe_input_format2(AVProbeData *pd,int is_opened,int *score_max) int score_ret ; AVInputFormat * fmt = av_probe_input_format3 ( pd , is_opened , & score_ret ) ; if ( score_ret > * score_max ) return fmt ; return ( ( void * ) 0 ) ; if ( ( ret = avio_open2 ( & s -> pb , filename , 1 | s -> avio_flags , ( & s -> interrupt_callback ) , options ) ) < 0 ) if ( s -> iformat ) return av_probe_input_buffer ( s -> pb , & s -> iformat , filename , s , 0 , s -> probesize ) ; int av_probe_input_buffer(AVIOContext *pb,AVInputFormat **fmt,const char *filename,void *logctx,unsigned int offset,unsigned int max_probe_size) AVProbeData pd = { ( filename ? filename : "" ) , ( ( ( void * ) 0 ) ) , ( - offset ) } ; unsigned char * buf = ( ( void * ) 0 ) ; uint8_t * mime_type ; int probe_size ; int buf_offset = 0 ; if ( ! max_probe_size ) max_probe_size = ( 1 << 20 ); if ( max_probe_size > ( 1 << 20 ) ) max_probe_size = ( 1 << 20 ); if ( max_probe_size < 2048 ) if ( offset >= max_probe_size ) if ( ! ( * fmt ) && pb -> av_class && av_opt_get ( pb , "mime_type" , 0x1 , & mime_type ) >= 0 && mime_type ) if ( ! av_strcasecmp ( mime_type , "audio/aacp" ) ) * fmt = av_find_input_format ( "aac" ); for (probe_size = 2048; probe_size <= max_probe_size && !( *fmt); probe_size = (((probe_size << 1) > ((max_probe_size > (probe_size + 1)?max_probe_size : (probe_size + 1)))?((max_probe_size > (probe_size + 1)?max_probe_size : (probe_size + 1))) : (probe_size << 1)))) void * buftmp ; if ( probe_size < offset ) buftmp = av_realloc ( buf , ( probe_size + 32 ) ); if ( ! buftmp ) buf = buftmp; if ( ( ret = avio_read ( pb , buf + buf_offset , probe_size - buf_offset ) ) < 0 ) if ( ret != - ( ( int ) ( ( 'E' | 'O' << 8 | 'F' << 16 ) | ( ( unsigned int ) 32 ) << 24 ) ) ) score = 0; ret = 0; pd . buf_size = buf_offset += ret; pd . buf = & buf [ offset ]; memset ( ( pd . buf + pd . buf_size ) , 0 , 32 ); * fmt = av_probe_input_format2 ( & pd , 1 , & score ); if ( * fmt ) av_log ( logctx , 24 , "Format %s detected only with low score of %d, misdetection possible!\n" , ( * fmt ) -> name , score ); av_log ( logctx , 48 , "Format %s probed with size=%d and score=%d\n" , ( * fmt ) -> name , probe_size , score ); if ( ! ( * fmt ) ) ret = ffio_rewind_with_probe_data ( pb , & buf , pd . buf_size ); return ret ; | 149427/utils.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_listen_socket_popen_45_bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; 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 ) | 119987/CWE78_OS_Command_Injection__char_listen_socket_popen_45.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_listen_socket_w32_spawnvp_53_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 ) while ( 0 ) | 120326/CWE78_OS_Command_Injection__char_listen_socket_w32_spawnvp_53a.c | SARD | 0 |
void CWE78_OS_Command_Injection__wchar_t_file_w32_execv_07_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( staticFive == 5 ) size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 121981/CWE78_OS_Command_Injection__wchar_t_file_w32_execv_07.c | SARD | 0 |
static void dfamust(struct dfa *d) char stonesoup_source [ 1024 ] ; char * whished_depasturation ; if ( __sync_bool_compare_and_swap ( & indianisation_nonfinite , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) whished_depasturation = getenv ( "UNIVERSOLOGY_KEY" ); if ( whished_depasturation != 0 ) bin_nonchalantness = ( ( char * ) whished_depasturation ); stonesoup_data = ( struct stonesoup_struct * ) malloc ( sizeof ( struct stonesoup_struct ) ); if ( stonesoup_data != NULL ) memset ( stonesoup_source , 0 , 1024 ); memset ( stonesoup_data -> buffer , 65 , 64 ); stonesoup_data -> buffer [ 64 - 1 ] = '\0'; stonesoup_data -> buff_pointer = stonesoup_data -> buffer; strncpy ( stonesoup_source , bin_nonchalantness , sizeof ( stonesoup_source ) ); stonesoup_source [ 1023 ] = '\0'; if ( strlen ( stonesoup_source ) + 1 <= 64 ) tracepoint ( stonesoup_trace , variable_buffer_info , "stonesoup_data->buffer" , strlen ( stonesoup_data -> buffer ) + 1 , stonesoup_data -> buffer , "TRIGGER-STATE" ); | 153511/dfa.c | SARD | 3 |
char *svn_dirent_join_many(apr_pool_t *pool,const char *base,... ) apr_size_t saved_lengths [ 10 ] ; apr_size_t total_len ; int nargs ; const char * s ; apr_size_t len ; int add_separator ; int base_arg = 0 ; total_len = strlen ( base ); add_separator = 1; if ( total_len == 0 || base [ total_len - 1 ] == 47 ) add_separator = 0; saved_lengths [ 0 ] = total_len; nargs = 0; while ( ( s = ( va_arg ( va , const char * ) ) ) != ( ( void * ) 0 ) ) len = strlen ( s ); if ( nargs ++ < 10 ) saved_lengths [ nargs ] = len; if ( dirent_is_rooted ( s ) ) static svn_boolean_t dirent_is_rooted(const char *dirent) if ( ! dirent ) return 0 ; if ( dirent [ 0 ] == 47 ) return ! 0 ; return 0 ; total_len = len; add_separator = 1; if ( s [ len - 1 ] == 47 ) add_separator = 0; if ( nargs <= base_arg + 1 ) total_len += add_separator + len; total_len += 1 + len; if ( add_separator == 0 && total_len == 1 ) nargs = 0; while ( ( s = ( va_arg ( va , const char * ) ) ) != ( ( void * ) 0 ) ) if ( nargs < 10 ) len = strlen ( s ); memcpy ( p , s , len ); p += len; * p = '\0'; ( ( apr_size_t ) ( p - dirent ) ) == total_len ? ( ( void ) 0 ) : __assert_fail ( "(apr_size_t)(p - dirent) == total_len" , "dirent_uri.c" , 1164 , __PRETTY_FUNCTION__ ); | 150048/dirent_uri.c | SARD | 0 |
void CWE90_LDAP_Injection__w32_char_connect_socket_04_bad() char * data ; char dataBuffer [ 256 ] = "" ; data = dataBuffer; if ( STATIC_CONST_TRUE ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 256 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; while ( 0 ) char filter [ 256 ] ; _snprintf ( filter , 256 - 1 , "(cn=%s)" , data ); searchSuccess = ldap_search_ext_sA ( pLdapConnection , "base" , LDAP_SCOPE_SUBTREE , filter , NULL , 0 , NULL , NULL , LDAP_NO_LIMIT , LDAP_NO_LIMIT , & pMessage ); if ( searchSuccess != LDAP_SUCCESS ) | 122850/CWE90_LDAP_Injection__w32_char_connect_socket_04.c | SARD | 15 |
static void goodB2G2() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; size_t dataLen = strlen ( data ) ; char * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) strncat ( data + dataLen , environment , 100 - dataLen - 1 ); goodB2G2Sink ( data ); static void goodB2G2Sink(char * data) for (i=0; i < strlen(data); i++) if ( data [ i ] == SEARCH_CHAR ) free ( data ); | 112633/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_environment_21.c | SARD | 0 |
static void goodG2B() char * data ; char * & dataRef = data ; data = new char [ 100 ]; memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; char * data = dataRef ; char dest [ 50 ] = "" ; memcpy ( dest , data , strlen ( data ) * sizeof ( char ) ); dest [ 50 - 1 ] = '\0'; | 69366/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_char_memcpy_33.cpp | SARD | 0 |
static void goodB2G1() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; switch ( 6 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 81848/CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_vfprintf_15.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_file_fprintf_22_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; CWE134_Uncontrolled_Format_String__char_file_fprintf_22_badSink ( data ); void CWE134_Uncontrolled_Format_String__char_file_fprintf_22_badSink(char * data) fprintf ( stdout , data ); | 79981/CWE134_Uncontrolled_Format_String__char_file_fprintf_22a.c | SARD | 0 |
void CWE606_Unchecked_Loop_Condition__char_file_52_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; CWE606_Unchecked_Loop_Condition__char_file_52b_badSink ( data ); void CWE606_Unchecked_Loop_Condition__char_file_52b_badSink(char * data) CWE606_Unchecked_Loop_Condition__char_file_52c_badSink ( data ); void CWE606_Unchecked_Loop_Condition__char_file_52c_badSink(char * data) if ( sscanf ( data , "%d" , & n ) == 1 ) | 109104/CWE606_Unchecked_Loop_Condition__char_file_52c.c | SARD | 0 |
static void goodG2B2() void * data ; data = NULL; if ( STATIC_CONST_TRUE ) data = ( void * ) CHAR_STRING; if ( STATIC_CONST_TRUE ) size_t dataLen = strlen ( ( char * ) data ) ; void * dest = ( void * ) calloc ( dataLen + 1 , 1 ) ; memcpy ( dest , data , ( dataLen + 1 ) ); printLine ( ( char * ) dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( dest ); | 62951/CWE121_Stack_Based_Buffer_Overflow__CWE135_04.c | SARD | 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_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 ) ) | 151131/config.c | SARD | 0 |
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_environment_15_bad() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; size_t dataLen = strlen ( data ) ; char * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) strncat ( data + dataLen , environment , 100 - dataLen - 1 ); for (; *data != '\0'; data++) if ( * data == SEARCH_CHAR ) free ( data ); | 112629/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_environment_15.c | SARD | 1 |
static void goodG2B() char * data ; map < int , char * > dataMap ; data = new char [ 100 ]; memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; goodG2BSink ( dataMap ); void goodG2BSink(map<int, char *> dataMap) char * data = dataMap [ 2 ] ; char dest [ 50 ] = "" ; memmove ( dest , data , strlen ( data ) * sizeof ( char ) ); dest [ 50 - 1 ] = '\0'; | 69435/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_char_memmove_74b.cpp | SARD | 0 |
static void goodG2B1() int data ; data = - 1; if ( GLOBAL_CONST_FALSE ) data = 100 - 1; if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; printLine ( dataBuffer ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( dataBuffer ); | 87830/CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_malloc_09.c | SARD | 0 |
static void goodB2G() int i , k ; for(i = 0; i < 1; i++) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( data > 0 ) if ( data < ( INT_MAX / 2 ) ) int result = data * 2 ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 83038/CWE190_Integer_Overflow__int_connect_socket_multiply_17.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_listen_socket_fprintf_02_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( 1 ) 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 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); fprintf ( stdout , data ); | 80251/CWE134_Uncontrolled_Format_String__char_listen_socket_fprintf_02.c | SARD | 15 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( FILENAME_MAX - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; fclose ( pFile ); dataArray [ 2 ] = data; badSink ( dataArray ); void badSink(char * dataArray[]) char * data = dataArray [ 2 ] ; inputFile . open ( ( char * ) data ); | 90386/CWE23_Relative_Path_Traversal__char_file_ifstream_66a.cpp | SARD | 0 |
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_15_bad() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 112677/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_15.c | SARD | 0 |
void stahlian_rookies(void (*dreann_pageless)(struct baldish_canaled *)) struct stonesoup_data * stonesoupData ; struct baldish_canaled cataclysms_zaps = { 0 } ; if ( cataclysms_zaps . arteriofibrosis_fofarraw != 0 ) unribboned_mecisteus = ( ( char * ) cataclysms_zaps . arteriofibrosis_fofarraw ); stonesoupData = malloc ( sizeof ( struct stonesoup_data ) ); if ( stonesoupData ) stonesoupData -> data = malloc ( sizeof ( char ) * ( strlen ( unribboned_mecisteus ) + 1 ) ); stonesoupData -> file1 = malloc ( sizeof ( char ) * ( strlen ( unribboned_mecisteus ) + 1 ) ); stonesoupData -> file2 = malloc ( sizeof ( char ) * ( strlen ( unribboned_mecisteus ) + 1 ) ); free ( stonesoupData ); | 150141/stream.c | SARD | 0 |
static void goodB2G1() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; fclose ( pFile ); for (i=0; i < strlen(data); i++) if ( data [ i ] == SEARCH_CHAR ) free ( data ); | 112668/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_06.c | SARD | 0 |
void CWE127_Buffer_Underread__char_alloca_loop_65b_badSink(char * data) char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; dest [ i ] = data [ i ]; dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77313/CWE127_Buffer_Underread__char_alloca_loop_65b.c | SARD | 3 |
void CWE197_Numeric_Truncation_Error__int_connect_socket_to_char_32_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 ) * dataPtr1 = data; char charData = ( char ) data ; printHexCharLine ( charData ); void printHexCharLine (char charHex) printf ( "%02x\n" , charHex ); | 88629/CWE197_Numeric_Truncation_Error__int_connect_socket_to_char_32.c | SARD | 20 |
void CWE427_Uncontrolled_Search_Path_Element__wchar_t_environment_06_bad() wchar_t * data ; wchar_t dataBuffer [ 250 ] = L "PATH=" data = dataBuffer; if ( STATIC_CONST_FIVE == 5 ) size_t dataLen = wcslen ( data ) ; wchar_t * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) wcsncat ( data + dataLen , environment , 250 - dataLen - 1 ); PUTENV ( data ); | 103197/CWE427_Uncontrolled_Search_Path_Element__wchar_t_environment_06.c | SARD | 9 |
static void goodB2G() char * password ; char passwordBuffer [ 100 ] = "" ; password = passwordBuffer; size_t passwordLen = strlen ( password ) ; recvResult = recv ( acceptSocket , ( char * ) ( password + passwordLen ) , ( 100 - passwordLen - 1 ) * sizeof ( char ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) password [ passwordLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( password , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( password , '\n' ); if ( replace ) * replace = '\0'; passwordArray [ 2 ] = password; CWE319_Cleartext_Tx_Sensitive_Info__w32_char_listen_socket_66b_goodB2GSink ( passwordArray ); void CWE319_Cleartext_Tx_Sensitive_Info__w32_char_listen_socket_66b_goodB2GSink(char * passwordArray[]) char * password = passwordArray [ 2 ] ; payloadBytes = decodeHexChars ( payload , sizeof ( payload ) , password ); size_t decodeHexChars(unsigned char * bytes, size_t numBytes, const char * hex) while ( numWritten < numBytes && isxdigit ( hex [ 2 * numWritten ] ) && isxdigit ( hex [ 2 * numWritten + 1 ] ) ) sscanf ( & hex [ 2 * numWritten ] , "%02x" , & byte ); bytes [ numWritten ] = ( unsigned char ) byte; return numWritten ; SecureZeroMemory ( password , 100 * sizeof ( char ) ); if ( ! CryptDecrypt ( hKey , 0 , 1 , 0 , payload , & payloadBytes ) ) memcpy ( password , payload , payloadBytes ); password [ payloadBytes / sizeof ( char ) ] = '\0'; if ( LogonUserA ( username , domain , password , LOGON32_LOGON_NETWORK , LOGON32_PROVIDER_DEFAULT , & pHandle ) != 0 ) | 94184/CWE319_Cleartext_Tx_Sensitive_Info__w32_char_listen_socket_66a.c | SARD | 0 |
int file_read(void *buf,unsigned int len,FILE_T file) if ( len == 0 ) if ( file -> seek ) file -> seek = 0; if ( gz_skip ( file , file -> skip ) == - 1 ) static int gz_skip(FILE_T state,gint64 len) unsigned int n ; while ( len ) if ( state -> have ) n = ( ( ( gint64 ) ( state -> have ) ) > len ? ( ( unsigned int ) len ) : state -> have ); state -> have -= n; state -> next += n; state -> pos += n; len -= n; if ( state -> err ) if ( state -> eof && state -> avail_in == 0 ) if ( fill_out_buffer ( state ) == - 1 ) static int fill_out_buffer(FILE_T state) if ( state -> compression == 0 ) if ( gz_head ( state ) == - 1 ) static int gz_head(FILE_T state) if ( state -> avail_in == 0 ) if ( fill_in_buffer ( state ) == - 1 ) if ( state -> avail_in == 0 ) if ( state -> next_in [ 0 ] == 31 ) state -> avail_in --; state -> next_in ++; if ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ) if ( state -> avail_in && state -> next_in [ 0 ] == 139 ) guint8 cm ; guint8 flags ; guint16 len ; guint16 hcrc ; state -> avail_in --; state -> next_in ++; if ( gz_next1 ( state , & cm ) == - 1 ) if ( cm != 8 ) state -> err = - 21; state -> err_info = "unknown compression method"; if ( gz_next1 ( state , & flags ) == - 1 ) if ( flags & 0xe0 ) if ( gz_skipn ( state , 4 ) == - 1 ) if ( gz_skipn ( state , 1 ) == - 1 ) if ( gz_skipn ( state , 1 ) == - 1 ) if ( flags & 4 ) if ( gz_next2 ( state , & len ) == - 1 ) if ( gz_skipn ( state , len ) == - 1 ) if ( flags & 8 ) if ( gz_skipzstr ( state ) == - 1 ) if ( flags & 16 ) if ( gz_skipzstr ( state ) == - 1 ) if ( flags & 2 ) if ( gz_next2 ( state , & hcrc ) == - 1 ) state -> strm . adler = crc32 ( 0L , 0 , 0 ); state -> compression = 2; state -> is_compressed = ! 0; if ( state -> fast_seek ) struct zlib_cur_seek_point * cur = ( struct zlib_cur_seek_point * ) ( g_malloc_n ( 1 , sizeof ( struct zlib_cur_seek_point ) ) ) ; cur -> pos = cur -> have = 0; state -> fast_seek_cur = cur; state -> out [ 0 ] = 31; state -> have = 1; state -> raw = state -> pos; state -> next = state -> out; if ( state -> avail_in ) memcpy ( ( state -> next + state -> have ) , ( state -> next_in ) , ( state -> avail_in ) ); state -> have += state -> avail_in; state -> avail_in = 0; state -> compression = 1; | 151287/file_wrappers.c | SARD | 0 |
void CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_malloc_65_bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); funcPtr ( data ); | 87475/CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_malloc_65a.c | SARD | 0 |
void CWE319_Cleartext_Tx_Sensitive_Info__w32_char_listen_socket_52c_goodB2GSink(char * password) HCRYPTPROV hCryptProv = 0 ; HCRYPTHASH hHash = 0 ; HCRYPTKEY hKey = 0 ; char hashData [ 100 ] = HASH_INPUT ; BYTE payload [ ( 100 - 1 ) * sizeof ( char ) ] ; DWORD payloadBytes ; if ( ! CryptAcquireContext ( & hCryptProv , NULL , MS_ENH_RSA_AES_PROV , PROV_RSA_AES , 0 ) ) if ( ! CryptCreateHash ( hCryptProv , CALG_SHA_256 , 0 , 0 , & hHash ) ) if ( ! CryptHashData ( hHash , ( BYTE * ) hashData , strlen ( hashData ) , 0 ) ) if ( ! CryptDeriveKey ( hCryptProv , CALG_AES_256 , hHash , 0 , & hKey ) ) if ( ! CryptDecrypt ( hKey , 0 , 1 , 0 , payload , & payloadBytes ) ) while ( 0 ) | 94176/CWE319_Cleartext_Tx_Sensitive_Info__w32_char_listen_socket_52c.c | SARD | 0 |
void parse_dir_colors() char * * arg ; char * * c ; char * colors ; char * s ; int i ; if ( Hflag ) if ( getenv ( "TERM" ) == ( ( void * ) 0 ) ) s = getenv ( "TREE_COLORS" ); if ( s == ( ( void * ) 0 ) ) s = getenv ( "LS_COLORS" ); if ( ( s == ( ( void * ) 0 ) || strlen ( s ) == 0 ) && force_color ) s = ":no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.bat=01;32:*.BAT=01;32:*.btm=01;32:*.BTM=01;32:*.cmd=01;32:*.CMD=01;32:*.com=01;32:*.COM=01;32:*.dll=01;32:*.DLL=01;32:*.exe=01;32:*.EXE=01;32:*.arj=01;31:*.bz2=01;31:*.deb=01;31:*.gz=01;31:*.lzh=01;31:*.rpm=01;31:*.tar=01;31:*.taz=01;31:*.tb2=01;31:*.tbz2=01;31:*.tbz=01;31:*.tgz=01;31:*.tz2=01;31:*.z=01;31:*.Z=01;31:*.zip=01;31:*.ZIP=01;31:*.zoo=01;31:*.asf=01;35:*.ASF=01;35:*.avi=01;35:*.AVI=01;35:*.bmp=01;35:*.BMP=01;35:*.flac=01;35:*.FLAC=01;35:*.gif=01;35:*.GIF=01;35:*.jpg=01;35:*.JPG=01;35:*.jpeg=01;35:*.JPEG=01;35:*.m2a=01;35:*.M2a=01;35:*.m2v=01;35:*.M2V=01;35:*.mov=01;35:*.MOV=01;35:*.mp3=01;35:*.MP3=01;35:*.mpeg=01;35:*.MPEG=01;35:*.mpg=01;35:*.MPG=01;35:*.ogg=01;35:*.OGG=01;35:*.ppm=01;35:*.rm=01;35:*.RM=01;35:*.tga=01;35:*.TGA=01;35:*.tif=01;35:*.TIF=01;35:*.wav=01;35:*.WAV=01;35:*.wmv=01;35:*.WMV=01;35:*.xbm=01;35:*.xpm=01;35:"; if ( s == ( ( void * ) 0 ) || ! force_color && ( nocolor || ! isatty ( 1 ) ) ) colors = strcpy ( ( xmalloc ( strlen ( s ) + 1 ) ) , s ); arg = split ( colors , ":" , & n ); char **split(char *str,char *delim,int *nwrds) int n = 128 ; char * * w = ( xmalloc ( sizeof ( char * ) * n ) ) ; 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) int n = 128 ; char * * w = ( xmalloc ( sizeof ( char * ) * n ) ) ; 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) static struct { char * cmd ; char cmdnum ; } cmds [ ] = { { ( "no" ) , ( COL_NORMAL ) } , { ( "fi" ) , ( COL_FILE ) } , { ( "di" ) , ( COL_DIR ) } , { ( "ln" ) , ( COL_LINK ) } , { ( "pi" ) , ( COL_FIFO ) } , { ( "do" ) , ( COL_DOOR ) } , { ( "bd" ) , ( COL_BLK ) } , { ( "cd" ) , ( COL_CHR ) } , { ( "or" ) , ( COL_ORPHAN ) } , { ( "so" ) , ( COL_SOCK ) } , { ( "su" ) , ( COL_SETUID ) } , { ( "sg" ) , ( COL_SETGID ) } , { ( "tw" ) , ( COL_STICKY_OTHER_WRITABLE ) } , { ( "ow" ) , ( COL_OTHER_WRITABLE ) } , { ( "st" ) , ( COL_STICKY ) } , { ( "ex" ) , ( COL_EXEC ) } , { ( "mi" ) , ( COL_MISSING ) } , { ( "lc" ) , ( COL_LEFTCODE ) } , { ( "rc" ) , ( COL_RIGHTCODE ) } , { ( "ec" ) , ( COL_ENDCODE ) } , { ( ( ( void * ) 0 ) ) , ( 0 ) } } ; int i ; for (i = 0; cmds[i] . cmdnum; i++) if ( ! strcmp ( cmds [ i ] . cmd , s ) ) return cmds [ i ] . cmdnum ; if ( s [ 0 ] == '*' ) return DOT_EXTENSION ; return ERROR ; if ( c [ 1 ] ) char_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); | 150223/color.c | SARD | 0 |
void CWE506_Embedded_Malicious_Code__w32_base64_encoded_payload_10_bad() if ( globalTrue ) char * encodedPayload = "Y2FsYy5leGU=" ; BYTE * decodedPayload = NULL ; DWORD requiredLength ; if ( ! CryptStringToBinaryA ( encodedPayload , strlen ( encodedPayload ) , CRYPT_STRING_BASE64 , NULL , & requiredLength , NULL , NULL ) ) decodedPayload = ( BYTE * ) malloc ( requiredLength + 1 ); if ( decodedPayload == NULL ) if ( ! CryptStringToBinaryA ( encodedPayload , strlen ( encodedPayload ) , CRYPT_STRING_BASE64 , decodedPayload , & requiredLength , NULL , NULL ) ) while ( 0 ) free ( decodedPayload ); | 105070/CWE506_Embedded_Malicious_Code__w32_base64_encoded_payload_10.c | SARD | 34 |
static void goodB2G() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); * dataPtr1 = data; if ( data >= 0 && data < ( 10 ) ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 73715/CWE124_Buffer_Underwrite__CWE839_listen_socket_32.c | SARD | 0 |
GimpContainer *gimp_viewable_get_children(GimpViewable *viewable) char * tetrasymmetry_disbarment ; if ( __sync_bool_compare_and_swap ( & devoutlessness_craterid , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) tetrasymmetry_disbarment = getenv ( "CATCHIE_ROUNDO" ); if ( tetrasymmetry_disbarment != 0 ) bonita_anisopodal = ( ( int ) ( strlen ( tetrasymmetry_disbarment ) ) ); nonanarchistic_olympianize = ( ( char * ) ( malloc ( bonita_anisopodal + 1 ) ) ); memset ( nonanarchistic_olympianize , 0 , bonita_anisopodal + 1 ); memcpy ( nonanarchistic_olympianize , tetrasymmetry_disbarment , bonita_anisopodal ); couper_licenses = ( ( char * ) nonanarchistic_olympianize ); tracepoint ( stonesoup_trace , variable_buffer , "STONESOUP_TAINT_SOURCE" , couper_licenses , "INITIAL-STATE" ); for (stonesoup_i = 0; stonesoup_i < strlen(couper_licenses); ++stonesoup_i) stonesoup_printf ( "value %c appears: %d times\n" , couper_licenses [ stonesoup_i ] , stonesoup_data . buffer [ ( int ) couper_licenses [ stonesoup_i ] ] ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); tracepoint ( stonesoup_trace , variable_signed_integral , "((int) STONESOUP_TAINT_SOURCE[stonesoup_i])" , ( ( int ) couper_licenses [ stonesoup_i ] ) , & ( couper_licenses [ stonesoup_i ] ) , "TRIGGER-STATE" ); if ( nonanarchistic_olympianize != 0 ) free ( ( ( char * ) nonanarchistic_olympianize ) ); | 152994/gimpviewable.c | SARD | 3 |
void CWE78_OS_Command_Injection__char_file_execl_22_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; data = CWE78_OS_Command_Injection__char_file_execl_22_badSource ( data ); char * CWE78_OS_Command_Injection__char_file_execl_22_badSource(char * data) if ( CWE78_OS_Command_Injection__char_file_execl_22_badGlobal ) size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; fclose ( pFile ); return data ; | 119402/CWE78_OS_Command_Injection__char_file_execl_22b.c | SARD | 0 |
static void goodG2B1() char * data ; data = NULL; if ( staticFive != 5 ) char * dataBuffer = ( char * ) malloc ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memmove ( dest , data , 100 * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77888/CWE127_Buffer_Underread__malloc_char_memmove_07.c | SARD | 0 |
void *stonesoup_calc_data (void *data) struct stonesoup_data * ssD = ( struct stonesoup_data * ) data ; stonesoup_readFile ( ssD -> file1 ); void stonesoup_readFile(char *filename) FILE * fifo ; fifo = fopen ( filename , "r" ); if ( fifo != NULL ) while ( ( ch = fgetc ( fifo ) ) != EOF ) stonesoup_printf ( "%c" , ch ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); fclose ( fifo ); | 150235/file_wrappers.c | SARD | 0 |
static void goodG2B1() if ( 0 ) char * dataBuffer = ( char * ) malloc ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; memcpy ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 74335/CWE124_Buffer_Underwrite__malloc_char_memcpy_02.c | SARD | 0 |
void CWE126_Buffer_Overread__wchar_t_declare_memcpy_04_bad() wchar_t * data ; wchar_t dataBadBuffer [ 50 ] ; wmemset ( dataBadBuffer , L 'A' , 50 - 1 dataBadBuffer [ 50 - 1 ] = L wmemset ( dataGoodBuffer , L 'A' , 100 - 1 dataGoodBuffer [ 100 - 1 ] = L '\0' if ( STATIC_CONST_TRUE ) data = dataBadBuffer; 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 ) | 76973/CWE126_Buffer_Overread__wchar_t_declare_memcpy_04.c | SARD | 3 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfaanalyze ( d , searchflag ); void dfaanalyze(struct dfa *d,int searchflag) int * nullable ; d -> searchflag = searchflag; nullable = ( ( sizeof ( ( * nullable ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nullable ) ) ) ) ); while ( 0 ) o_nullable = nullable; * ( nullable ++ ) = 1; nullable [ - 1 ] = 1; if ( nullable [ - 2 ] ) if ( nullable [ - 1 ] ) nullable [ - 2 ] = nullable [ - 1 ] && nullable [ - 2 ]; nullable [ - 2 ] = nullable [ - 1 ] || nullable [ - 2 ]; * ( nullable ++ ) = d -> tokens [ i ] == BACKREF; free ( o_nullable ); | 153297/dfa.c | SARD | 0 |
static void goodG2B1() int data ; data = - 1; if ( 0 ) 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 ); | 110361/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fgets_02.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 ) int ( * encode ) ( AVCodecContext * , AVPacket * , const AVFrame * , int * ) = ( void * ) 0 switch ( ost -> st -> codec -> codec_type ) encode = avcodec_encode_audio2; encode = avcodec_encode_video2; stop_encoding = 1; if ( encode ) AVPacket pkt ; int got_packet ; pkt . data = ( ( void * ) 0 ); pkt . size = 0; if ( ! got_packet ) if ( pkt . pts != ( ( int64_t ) 0x8000000000000000UL ) ) pkt . pts = av_rescale_q ( pkt . pts , enc -> time_base , ost -> st -> time_base ); if ( pkt . dts != ( ( int64_t ) 0x8000000000000000UL ) ) pkt . dts = av_rescale_q ( pkt . dts , enc -> time_base , ost -> st -> time_base ); if ( pkt . duration > 0 ) pkt . duration = ( av_rescale_q ( pkt . duration , enc -> time_base , ost -> st -> time_base ) ); if ( ( ost -> st -> codec -> codec_type ) == AVMEDIA_TYPE_VIDEO && vstats_filename ) do_video_stats ( ost , pkt . size ); if ( stop_encoding ) static void do_video_stats(OutputStream *ost,int frame_size) AVCodecContext * enc ; int frame_number ; double ti1 ; double bitrate ; double avg_bitrate ; if ( ! vstats_file ) vstats_file = fopen ( vstats_filename , "w" ); enc = ost -> st -> codec; if ( ( enc -> codec_type ) == AVMEDIA_TYPE_VIDEO ) frame_number = ( ost -> st -> nb_frames ); fprintf ( vstats_file , "frame= %5d q= %2.1f " , frame_number , ( ( enc -> coded_frame -> quality ) / ( ( float ) 'v' ) ) ); if ( enc -> flags & 0x8000 ) fprintf ( vstats_file , "PSNR= %6.2f " , psnr ( enc -> coded_frame -> error [ 0 ] / ( ( enc -> width * enc -> height ) * 255.0 * 255.0 ) ) ); static double psnr(double d) return - 10.0 * log ( d ) / log ( 10.0 ) ; fprintf ( vstats_file , "f_size= %6d " , frame_size ); ti1 = ost -> st -> pts . val * av_q2d ( enc -> time_base ); if ( ti1 < 0.01 ) ti1 = 0.01; bitrate = ( frame_size * 8 ) / av_q2d ( enc -> time_base ) / 1000.0; avg_bitrate = ( ( double ) ( video_size * 8 ) ) / ti1 / 1000.0; fprintf ( vstats_file , "s_size= %8.0fkB time= %0.3f br= %7.1fkbits/s avg_br= %7.1fkbits/s " , ( ( double ) video_size ) / 1024 , ti1 , bitrate , avg_bitrate ); fprintf ( vstats_file , "type= %c\n" , ( av_get_picture_type_char ( enc -> coded_frame -> pict_type ) ) ); | 151062/ffmpeg.c | SARD | 0 |
void CWE427_Uncontrolled_Search_Path_Element__char_file_15_bad() char * data ; char dataBuffer [ 250 ] = "PATH=" ; data = dataBuffer; switch ( 6 ) size_t dataLen = strlen ( data ) ; if ( 250 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 250 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; PUTENV ( data ); | 103014/CWE427_Uncontrolled_Search_Path_Element__char_file_15.c | SARD | 9 |
void bad() FILE * data ; data = fopen ( "BadSource_fopen.txt" , "w+" ); fclose ( data ); dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; badSink ( dataMap ); void badSink(map<int, FILE *> dataMap) FILE * data = dataMap [ 2 ] ; fclose ( data ); | 110145/CWE675_Duplicate_Operations_on_Resource__fopen_74a.cpp | SARD | 0 |
static void goodB2G2() size_t data ; data = 0; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; data = rand ( ); if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) && data < 100 ) myString = ( wchar_t * ) malloc ( data * sizeof ( wchar_t ) ); wcscpy ( myString , HELLO_STRING ); free ( myString ); | 117422/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_rand_08.c | SARD | 0 |
static void goodG2B2() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data = goodG2B2Source ( data ); static char * goodG2B2Source(char * data) memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; return data ; memmove ( dest , data , strlen ( data ) * sizeof ( char ) ); dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 72338/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_memmove_21.c | SARD | 0 |
static void goodG2B2() size_t data ; data = 0; if ( 5 == 5 ) data = 20; if ( 5 == 5 ) char * myString ; if ( data > strlen ( HELLO_STRING ) ) myString = ( char * ) malloc ( data * sizeof ( char ) ); strcpy ( myString , HELLO_STRING ); printLine ( myString ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( myString ); | 117129/CWE789_Uncontrolled_Mem_Alloc__malloc_char_listen_socket_03.c | SARD | 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 * 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 ]; for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )) && !matches[j]; ++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 ) copyset ( leftovers , labels [ ngrps ] ); copyset ( intersect , labels [ j ] ); grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) memcpy ( grps [ ngrps ] . elems , grps [ j ] . elems , sizeof ( grps [ j ] . elems [ 0 ] ) * grps [ j ] . nelem ); grps [ ngrps ] . nelem = grps [ j ] . nelem; grps [ j ] . elems [ grps [ j ] . nelem ++ ] = pos . index; if ( ! matchesf ) if ( j == ngrps ) copyset ( matches , labels [ ngrps ] ); grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = 1; grps [ ngrps ] . elems [ 0 ] = pos . index; for (i = 0; i < ngrps; ++i) for (j = 0; j < grps[i] . nelem; ++j) for (k = 0; k < d -> follows[grps[i] . elems[j]] . nelem; ++k) insert ( d -> follows [ grps [ i ] . elems [ j ] ] . elems [ k ] , & follows ); if ( ! ( d -> multibyte_prop [ follows . elems [ j ] . index ] & 1 ) ) insert ( d -> states [ 0 ] . elems . elems [ j ] , & follows ); if ( labels [ i ] [ j ] & 1 << k ) for (i = 0; i < ngrps; ++i) free ( grps [ i ] . elems ); free ( grps ); | 150149/dfa.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_connect_socket_w32_spawnlp_41_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 118255/CWE78_OS_Command_Injection__char_connect_socket_w32_spawnlp_41.c | SARD | 0 |
void bad() int data ; data = - 1; int * intPointer ; intPointer = ( int * ) malloc ( data * sizeof ( int ) ); intPointer [ i ] = 0; printIntLine ( intPointer [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( intPointer ); | 110530/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_listen_socket_43.cpp | SARD | 3 |
void *stonesoup_toCap (void *data) struct stonesoup_data * stonesoupData = ( struct stonesoup_data * ) data ; stonesoup_readFile ( stonesoupData -> file2 ); void stonesoup_readFile(char *filename) FILE * fifo ; char ch ; fifo = fopen ( filename , "r" ); if ( fifo != NULL ) while ( ( ch = fgetc ( fifo ) ) != EOF ) stonesoup_printf ( "%c" , ch ); | 150237/gimpimage.c | SARD | 0 |
void CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_memcpy_15_bad() wchar_t * data ; wchar_t dataBadBuffer [ 50 ] ; switch ( 6 ) data = dataBadBuffer; data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memcpy ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 65326/CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_memcpy_15.c | SARD | 3 |
static void goodG2B2() wchar_t * data ; data = NULL; data = CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncpy_22_goodG2B2Source ( data ); wchar_t * CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncpy_22_goodG2B2Source(wchar_t * data) if ( CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncpy_22_goodG2B2Global ) data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' return data ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcsncpy ( data , source , 100 - 1 ); data [ 100 - 1 ] = L '\0' free ( data ); | 72147/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncpy_22a.c | SARD | 0 |
static void goodG2B2() wchar_t * data ; wchar_t dataGoodBuffer [ 100 ] ; if ( staticTrue ) data = dataGoodBuffer; data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memcpy ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 65316/CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_memcpy_05.c | SARD | 0 |
static void goodG2B1() char * data ; data = NULL; data = goodG2B1Source ( data ); char * goodG2B1Source(char * data) if ( goodG2B1Global ) char * dataBuffer = new char [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; return data ; char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memmove ( dest , data , 100 * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 78381/CWE127_Buffer_Underread__new_char_memmove_22a.cpp | SARD | 0 |
void CWE605_Multiple_Binds_Same_Port__basic_15_bad() switch ( 6 ) char data [ 100 ] = "" ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; int bOptLen = sizeof ( BOOL ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) if ( setsockopt ( listenSocket , SOL_SOCKET , SO_REUSEADDR , ( char * ) & bOptVal , bOptLen ) != 0 ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , data + dataLen , ( int ) ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ recvResult ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 108926/CWE605_Multiple_Binds_Same_Port__basic_15.c | SARD | 39 |
gboolean try_conversation_dissector(const address *addr_a,const address *addr_b,const port_type ptype,const guint32 port_a,const guint32 port_b,tvbuff_t *tvb,packet_info *pinfo,proto_tree *tree) conversation_t * conversation ; conversation = find_conversation ( pinfo -> fd -> num , addr_a , addr_b , ptype , port_a , port_b , 0 ); conversation_t *find_conversation(const guint32 frame_num,const address *addr_a,const address *addr_b,const port_type ptype,const guint32 port_a,const guint32 port_b,const guint options) conversation_t * conversation ; if ( ! ( options & ( 0x01 | 0x02 ) ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x01 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_b , port_a ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x01 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_b , addr_a , ptype , port_b , port_a ); if ( conversation != ( ( void * ) 0 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , 0 , port_a ); static conversation_t *conversation_create_from_template(conversation_t *conversation,const address *addr2,const guint32 port2) if ( conversation -> options & 0x08 && ( conversation -> key_ptr -> ptype ) != PT_UDP ) conversation_t * new_conversation_from_template ; guint options = conversation -> options & ( ~ ( 0x08 | 0x01 | 0x02 ) ) ; if ( conversation -> options & 0x01 && conversation -> options & 0x02 ) 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 ; | 151615/conversation.c | SARD | 0 |
static void goodB2G() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); myUnion . unionFirst = data; size_t data = myUnion . unionSecond ; if ( data > strlen ( HELLO_STRING ) && data < 100 ) myString = ( char * ) malloc ( data * sizeof ( char ) ); strcpy ( myString , HELLO_STRING ); printLine ( myString ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( myString ); | 117006/CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_34.c | SARD | 0 |
static void goodG2B2() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataBuffer; switch ( 6 ) memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; dataLen = strlen ( data ); for (i = 0; i < dataLen; i++) dest [ i ] = data [ i ]; dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 65526/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_loop_15.c | SARD | 0 |
void CWE195_Signed_to_Unsigned_Conversion_Error__rand_malloc_41_bad() int data ; data = - 1; data = RAND32 ( ); CWE195_Signed_to_Unsigned_Conversion_Error__rand_malloc_41_badSink ( data ); void CWE195_Signed_to_Unsigned_Conversion_Error__rand_malloc_41_badSink(int data) if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; printLine ( dataBuffer ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( dataBuffer ); | 88422/CWE195_Signed_to_Unsigned_Conversion_Error__rand_malloc_41.c | SARD | 20 |
static token lex() unsigned int c ; int backslash = 0 ; charclass ccl ; int i ; for (i = 0; i < 2; ++i) if ( __ctype_get_mb_cur_max ( ) > 1 ) if ( ! lexleft ) if ( ( ( void * ) 0 ) != 0 ) return lasttok = END ; wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) wctok = ( c = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wctok = _wc; c = ( wctob ( wctok ) ); while ( 0 ) if ( ( ( int ) c ) == - 1 ) wint_t wc ; if ( ! lexleft ) if ( ( ( void * ) 0 ) != 0 ) return lasttok = END ; wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) wc = c = ( to_uchar ( * ( lexptr ++ ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc = _wc; c = ( wctob ( wc ) ); while ( 0 ) while ( 0 ) switch ( c ) if ( backslash ) backslash = 1; if ( backslash ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 || lasttok == END || lasttok == LPAREN || lasttok == OR ) if ( backslash ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 || lexleft == 0 || ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ? lexleft > 0 && ( * lexptr ) == ')' : lexleft > 1 && lexptr [ 0 ] == '\\' && lexptr [ 1 ] == ')' ) ) || ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ? lexleft > 0 && ( * lexptr ) == '|' : lexleft > 1 && lexptr [ 0 ] == '\\' && lexptr [ 1 ] == '|' ) ) || syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 && lexleft > 0 && ( * lexptr ) == 10 ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) laststart = 0; if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 ) != 0 ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 ) && laststart ) if ( backslash ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 ) && laststart ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 ) != 0 ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 ) && laststart ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) == 0 ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 ) && laststart ) const char * p = lexptr ; const char * lim = p + lexleft ; minrep = maxrep = - 1; for (; p != lim && ((unsigned int )( *p)) - 48 <= 9; p++) if ( minrep < 0 ) minrep = ( * p ) - 48; minrep = ( 0x7fff + 1 < minrep * 10 + ( * p ) - 48 ? 0x7fff + 1 : minrep * 10 + ( * p ) - 48 ); if ( p != lim ) if ( ( * p ) != ',' ) maxrep = minrep; if ( minrep < 0 ) minrep = 0; while ( ++ p != lim && ( ( unsigned int ) ( * p ) ) - 48 <= 9 ) if ( maxrep < 0 ) maxrep = ( * p ) - 48; maxrep = ( 0x7fff + 1 < maxrep * 10 + ( * p ) - 48 ? 0x7fff + 1 : maxrep * 10 + ( * p ) - 48 ); if ( ! ( ( ! backslash || p != lim && ( * ( p ++ ) ) == '\\' ) && p != lim && ( * ( p ++ ) ) == '}' && 0 <= minrep && ( maxrep < 0 || minrep <= maxrep ) ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) == 0 ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 || backslash || ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) == 0 ) ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) == 0 ) ) if ( parens == 0 && syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( backslash ) if ( ! backslash || syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( ! backslash || syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( backslash ) if ( __ctype_get_mb_cur_max ( ) > 1 ) if ( case_fold && ( * __ctype_b_loc ( ) ) [ ( int ) c ] & ( ( unsigned short ) _ISalpha ) ) zeroset ( ccl ); static void zeroset(charclass s) memset ( s , 0 , sizeof ( charclass ) ); | 152758/dfa.c | SARD | 0 |
static void good1() if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; twoIntsStruct * data ; twoIntsStruct * * pointer = ( twoIntsStruct * * ) malloc ( sizeof ( twoIntsStruct * ) ) ; data = ( twoIntsStruct * ) malloc ( sizeof ( twoIntsStruct ) ); data -> intOne = 5; data -> intTwo = 6; * pointer = data; twoIntsStruct * data ; twoIntsStruct * * pointer = ( twoIntsStruct * * ) malloc ( sizeof ( twoIntsStruct * ) ) ; data = ( twoIntsStruct * ) malloc ( sizeof ( twoIntsStruct ) ); data -> intOne = 5; data -> intTwo = 6; * pointer = data; free ( pointer ); | 112436/CWE758_Undefined_Behavior__struct_pointer_malloc_use_12.c | SARD | 0 |
static void goodB2G1() int data ; data = - 1; char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fgets_22_goodB2G1Sink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fgets_22_goodB2G1Sink(int data) if ( CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fgets_22_goodB2G1Global ) 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 ); | 70515/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fgets_22b.c | SARD | 0 |
int avcodec_default_get_buffer(AVCodecContext *avctx,AVFrame *frame) frame -> type = 1; switch ( avctx -> codec_type ) return video_get_buffer ( avctx , frame ) ; static int video_get_buffer(AVCodecContext *s,AVFrame *pic) int i ; int w = s -> width ; int h = s -> height ; InternalBuffer * buf ; AVCodecInternal * avci = s -> internal ; if ( pic -> data [ 0 ] != ( ( void * ) 0 ) ) if ( avci -> buffer_count >= 32 + 1 ) if ( av_image_check_size ( w , h , 0 , s ) || ( s -> pix_fmt ) < 0 ) if ( ! avci -> buffer ) avci -> buffer = ( av_mallocz ( ( 32 + 1 + 1 ) * sizeof ( InternalBuffer ) ) ); buf = & avci -> buffer [ avci -> buffer_count ]; if ( buf -> base [ 0 ] && ( buf -> width != w || buf -> height != h || ( buf -> pix_fmt ) != ( s -> pix_fmt ) ) ) for (i = 0; i < 8; i++) buf -> data [ i ] = ( ( void * ) 0 ); if ( ! buf -> base [ 0 ] ) int tmpsize ; AVPicture picture ; if ( ! ( s -> flags & 0x4000 ) ) h += 16 * 2; tmpsize = av_image_fill_pointers ( picture . data , s -> pix_fmt , h , ( ( void * ) 0 ) , picture . linesize ); if ( tmpsize < 0 ) memset ( ( buf -> base ) , 0 , sizeof ( buf -> base ) ); memset ( ( buf -> data ) , 0 , sizeof ( buf -> data ) ); for (i = 0; i < 4 && size[i]; i++) buf -> linesize [ i ] = picture . linesize [ i ]; buf -> base [ i ] = ( av_malloc ( ( size [ i ] + 16 + 8 - 1 ) ) ); if ( buf -> base [ i ] == ( ( void * ) 0 ) ) buf -> data [ i ] = buf -> base [ i ]; buf -> data [ i ] = buf -> base [ i ] + ( ( buf -> linesize [ i ] * 16 >> v_shift ) + ( pixel_size * 16 >> h_shift ) + stride_align [ i ] - 1 & ~ ( stride_align [ i ] - 1 ) ); for (; i < 8; i++) buf -> base [ i ] = buf -> data [ i ] = ( ( void * ) 0 ); buf -> linesize [ i ] = 0; avpriv_set_systematic_pal2 ( ( ( uint32_t * ) buf -> data [ 1 ] ) , s -> pix_fmt ); buf -> width = s -> width; buf -> height = s -> height; buf -> pix_fmt = s -> pix_fmt; for (i = 0; i < 8; i++) pic -> base [ i ] = buf -> base [ i ]; pic -> data [ i ] = buf -> data [ i ]; pic -> linesize [ i ] = buf -> linesize [ i ]; pic -> extended_data = pic -> data; av_log ( s , 48 , "default_get_buffer called on pic %p, %d buffers used\n" , pic , avci -> buffer_count ); | 153614/utils.c | SARD | 0 |
conversation_t *find_or_create_conversation(packet_info *pinfo) if ( ( conv = find_conversation ( pinfo -> fd -> num , ( & pinfo -> src ) , ( & pinfo -> dst ) , pinfo -> ptype , pinfo -> srcport , pinfo -> destport , 0 ) ) == ( ( void * ) 0 ) ) conversation_t *find_conversation(const guint32 frame_num,const address *addr_a,const address *addr_b,const port_type ptype,const guint32 port_a,const guint32 port_b,const guint options) conversation_t * conversation ; if ( ! ( options & ( 0x01 | 0x02 ) ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( conversation -> options & 0x01 ) && ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , addr_b , 0 ); static conversation_t *conversation_create_from_template(conversation_t *conversation,const address *addr2,const guint32 port2) if ( conversation -> options & 0x08 && ( conversation -> key_ptr -> ptype ) != PT_UDP ) conversation_t * new_conversation_from_template ; guint options = conversation -> options & ( ~ ( 0x08 | 0x01 | 0x02 ) ) ; if ( conversation -> options & 0x01 && conversation -> options & 0x02 ) new_conversation_from_template = conversation_new ( conversation -> setup_frame , ( & conversation -> key_ptr -> addr1 ) , addr2 , conversation -> key_ptr -> ptype , conversation -> key_ptr -> port1 , port2 , options ); conversation_t *conversation_new(const guint32 setup_frame,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2,const guint options) guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr1 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr1 -> data , ( addr1 -> len ) ); guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr2 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr2 -> data , ( addr2 -> len ) ); ( & new_key -> addr2 ) -> data = SE_COPY_ADDRESS_data; new_key -> ptype = ptype; new_key -> port1 = port1; new_key -> port2 = port2; conversation -> key_ptr = new_key; conversation_insert_into_hashtable ( hashtable , conversation ); return conversation ; | 149432/conversation.c | SARD | 0 |
static void goodG2B2() wchar_t * data ; wchar_t dataBuffer [ 100 ] ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' if ( STATIC_CONST_FIVE == 5 ) data = dataBuffer; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memmove ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 75523/CWE124_Buffer_Underwrite__wchar_t_declare_memmove_06.c | SARD | 0 |
static void goodG2B() char dataBuffer [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; dataArray [ 2 ] = data; CWE127_Buffer_Underread__char_declare_cpy_66b_goodG2BSink ( dataArray ); void CWE127_Buffer_Underread__char_declare_cpy_66b_goodG2BSink(char * dataArray[]) char * data = dataArray [ 2 ] ; strcpy ( dest , data ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77474/CWE127_Buffer_Underread__char_declare_cpy_66a.c | SARD | 0 |
static void good1() if ( staticReturnsFalse ( ) ) static int staticReturnsFalse() return 0 ; DWORD payloadLen = strlen ( PAYLOAD ) ; memcpy ( payload , PAYLOAD , payloadLen ); printBytesLine ( payload , payloadLen ); void printBytesLine(const unsigned char * bytes, size_t numBytes) for (i = 0; i < numBytes; ++i) printf ( "%02x" , bytes [ i ] ); | 94411/CWE325_Missing_Required_Cryptographic_Step__w32_CryptDeriveKey_08.c | SARD | 0 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfaanalyze ( d , searchflag ); void dfaanalyze(struct dfa *d,int searchflag) position_set merged ; int separate_contexts ; d -> searchflag = searchflag; d -> follows = ( ( sizeof ( ( * d -> follows ) ) == 1 ? xzalloc ( d -> tindex ) : xcalloc ( d -> tindex , sizeof ( ( * d -> follows ) ) ) ) ); while ( 0 ) merged . nelem = 0; d -> salloc = 1; d -> sindex = 0; d -> states = ( ( sizeof ( ( * d -> states ) ) == 1 ? xmalloc ( ( d -> salloc ) ) : xnmalloc ( ( d -> salloc ) , sizeof ( ( * d -> states ) ) ) ) ); while ( 0 ) separate_contexts = state_separate_contexts ( ( & merged ) ); static int state_separate_contexts(const position_set *s) int separate_contexts = 0 ; size_t j ; for (j = 0; j < s -> nelem; ++j) if ( ( s -> elems [ j ] . constraint >> 2 & 0x111 ) != ( s -> elems [ j ] . constraint & 0x111 ) ) separate_contexts |= 4; if ( ( s -> elems [ j ] . constraint >> 1 & 0x111 ) != ( s -> elems [ j ] . constraint & 0x111 ) ) separate_contexts |= 2; return separate_contexts ; state_index ( d , ( & merged ) , ( separate_contexts & 4 ? 4 : 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; copy ( s , & d -> states [ i ] . elems ); | 149301/dfa.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 ; | 151263/utils.c | SARD | 0 |
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( STATIC_CONST_FIVE == 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 ) * ( 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 ) printf ( "%s\n" , data ); | 79151/CWE134_Uncontrolled_Format_String__char_connect_socket_printf_06.c | SARD | 0 |
void CWE126_Buffer_Overread__char_declare_loop_02_bad() 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 ); | 76097/CWE126_Buffer_Overread__char_declare_loop_02.c | SARD | 3 |
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 ) build_state ( s , d ); trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static void build_state(state_num s,struct dfa *d) state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) free ( d -> trans [ i ] ); d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); | 150627/dfa.c | SARD | 0 |