func
stringlengths
181
23.6k
path
stringlengths
12
123
source
stringclasses
2 values
label
int64
0
40
void bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; count = atoi ( inputBuffer ); while ( 0 ) countMap [ 0 ] = count; countMap [ 1 ] = count; countMap [ 2 ] = count; badSink ( countMap ); void badSink(map<int, int> countMap) int count = countMap [ 2 ] ; for (i = 0; i < (size_t)count; i++)
98572/CWE400_Resource_Exhaustion__connect_socket_fwrite_74a.cpp
SARD
0
void CWE510_Trapdoor__hostname_based_logic_14_bad() if ( globalFive == 5 ) WSADATA wsaData ; struct sockaddr_in service , acceptService ; char hostname [ NI_MAXHOST ] ; char servInfo [ NI_MAXSERV ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( 20000 ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , 5 ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) if ( getsockname ( acceptSocket , ( struct sockaddr * ) & acceptService , & acceptServiceLen ) == - 1 ) if ( getnameinfo ( ( struct sockaddr * ) & acceptService , sizeof ( struct sockaddr ) , hostname , NI_MAXHOST , servInfo , NI_MAXSERV , NI_NUMERICSERV ) != 0 ) if ( strcmp ( "admin.google.com" , hostname ) == 0 ) if ( send ( acceptSocket , ADMIN_MESSAGE , strlen ( ADMIN_MESSAGE ) , 0 ) == SOCKET_ERROR ) if ( send ( acceptSocket , DEFAULT_MESSAGE , strlen ( DEFAULT_MESSAGE ) , 0 ) == SOCKET_ERROR ) while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket );
105180/CWE510_Trapdoor__hostname_based_logic_14.c
SARD
34
static void goodG2B() char * dataBuffer = new char [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; strcpy ( dest , data ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
78240/CWE127_Buffer_Underread__new_char_cpy_33.cpp
SARD
0
static void goodB2G1() if ( 5 == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
116985/CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_03.c
SARD
0
inline static emem_tree_node_t *emem_tree_parent(emem_tree_node_t *node) int stonesoup_num ; char * cybele_diseducate ; if ( __sync_bool_compare_and_swap ( & cowrote_binah , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( cybele_diseducate != 0 ) message_cytozoic = ( ( void * ) cybele_diseducate ); precensuring_adunation = ( ( char * ) ( ( char * ) message_cytozoic ) ); stonesoup_num = atoi ( precensuring_adunation ); if ( stonesoup_num > 0 && stonesoup_num < 4294967295U / sizeof ( unsigned int * * ) ) stonesoup_buffer_array = ( ( unsigned int * * ) ( malloc ( stonesoup_num * sizeof ( unsigned int * ) ) ) ); tracepoint ( stonesoup_trace , variable_address , "stonesoup_buffer_array" , stonesoup_buffer_array , "INITIAL-STATE" ); stonesoup_buffer_array [ stonesoup_i ] = 0; while ( stonesoup_buffer_array [ stonesoup_i ] == 0 ) stonesoup_buffer_array [ stonesoup_i ] = ( ( unsigned int * ) ( malloc ( stonesoup_size * sizeof ( unsigned int ) ) ) ); if ( stonesoup_buffer_array [ stonesoup_i ] != 0 ) tracepoint ( stonesoup_trace , variable_unsigned_integral , "stonesoup_i" , stonesoup_i , & stonesoup_i , "CROSSOVER-STATE" ); tracepoint ( stonesoup_trace , variable_address , "stonesoup_buffer_array[stonesoup_i]" , stonesoup_buffer_array [ stonesoup_i ] , "CROSSOVER-STATE" ); tracepoint ( stonesoup_trace , variable_unsigned_integral , "stonesoup_i" , stonesoup_i , & stonesoup_i , "TRIGGER-STATE" ); tracepoint ( stonesoup_trace , variable_address , "stonesoup_buffer_array[stonesoup_i]" , stonesoup_buffer_array [ stonesoup_i ] , "TRIGGER-STATE" ); if ( stonesoup_buffer_array [ stonesoup_i ] != 0 ) memset ( stonesoup_buffer_array [ stonesoup_i ] , 0 , stonesoup_size * sizeof ( unsigned int ) ); if ( stonesoup_buffer_array [ stonesoup_i ] != 0 ) free ( stonesoup_buffer_array [ stonesoup_i ] ); if ( stonesoup_buffer_array != 0 ) free ( stonesoup_buffer_array );
151738/emem.c
SARD
12
static void good1() if ( STATIC_CONST_FALSE ) char data [ 100 ] = "" ; size_t dataLen = strlen ( data ) ; recvResult = recv ( acceptSocket , ( char * ) data + dataLen , ( int ) ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ recvResult ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
110002/CWE666_Operation_on_Resource_in_Wrong_Phase_of_Lifetime__listen_accept_bind_04.c
SARD
0
static token parse_bracket_exp() struct mb_char_classes * work_mbc ; if ( __ctype_get_mb_cur_max ( ) > 1 ) if ( dfa -> mbcsets_alloc <= dfa -> nmbcsets + 1 ) size_t new_n_alloc = dfa -> nmbcsets + 1 + ( ! dfa -> mbcsets ) ; dfa -> mbcsets = ( x2nrealloc ( ( dfa -> mbcsets ) , & new_n_alloc , sizeof ( ( * dfa -> mbcsets ) ) ) ); dfa -> mbcsets_alloc = new_n_alloc; while ( 0 ) work_mbc = & dfa -> mbcsets [ dfa -> nmbcsets ++ ]; memset ( work_mbc , 0 , sizeof ( ( * work_mbc ) ) ); if ( ch_classes_al <= work_mbc -> nch_classes + 1 ) size_t new_n_alloc = work_mbc -> nch_classes + 1 + ( ! work_mbc -> ch_classes ) ; work_mbc -> ch_classes = ( x2nrealloc ( ( work_mbc -> ch_classes ) , & new_n_alloc , sizeof ( ( * work_mbc -> ch_classes ) ) ) ); ch_classes_al = new_n_alloc; work_mbc -> ch_classes [ work_mbc -> nch_classes ++ ] = wt; if ( equivs_al <= work_mbc -> nequivs + 1 ) size_t new_n_alloc = work_mbc -> nequivs + 1 + ( ! work_mbc -> equivs ) ; work_mbc -> equivs = ( x2nrealloc ( ( work_mbc -> equivs ) , & new_n_alloc , sizeof ( ( * work_mbc -> equivs ) ) ) ); equivs_al = new_n_alloc; work_mbc -> equivs [ work_mbc -> nequivs ++ ] = elem; if ( coll_elems_al <= work_mbc -> ncoll_elems + 1 ) size_t new_n_alloc = work_mbc -> ncoll_elems + 1 + ( ! work_mbc -> coll_elems ) ; work_mbc -> coll_elems = ( x2nrealloc ( ( work_mbc -> coll_elems ) , & new_n_alloc , sizeof ( ( * work_mbc -> coll_elems ) ) ) ); coll_elems_al = new_n_alloc; work_mbc -> coll_elems [ work_mbc -> ncoll_elems ++ ] = elem; if ( range_sts_al <= work_mbc -> nranges + 1 ) size_t new_n_alloc = work_mbc -> nranges + 1 + ( ! work_mbc -> range_sts ) ; work_mbc -> range_sts = ( x2nrealloc ( ( work_mbc -> range_sts ) , & new_n_alloc , sizeof ( ( * work_mbc -> range_sts ) ) ) ); range_sts_al = new_n_alloc; if ( range_ends_al <= work_mbc -> nranges + 1 ) size_t new_n_alloc = work_mbc -> nranges + 1 + ( ! work_mbc -> range_ends ) ; work_mbc -> range_ends = ( x2nrealloc ( ( work_mbc -> range_ends ) , & new_n_alloc , sizeof ( ( * work_mbc -> range_ends ) ) ) ); range_ends_al = new_n_alloc; work_mbc -> range_sts [ work_mbc -> nranges ] = ( ( case_fold ? towlower ( wc ) : ( ( wchar_t ) wc ) ) ); work_mbc -> range_ends [ work_mbc -> nranges ++ ] = ( ( case_fold ? towlower ( wc2 ) : ( ( wchar_t ) wc2 ) ) ); if ( chars_al <= work_mbc -> nchars + 1 ) size_t new_n_alloc = work_mbc -> nchars + 1 + ( ! work_mbc -> chars ) ; work_mbc -> chars = ( x2nrealloc ( ( work_mbc -> chars ) , & new_n_alloc , sizeof ( ( * work_mbc -> chars ) ) ) ); chars_al = new_n_alloc; work_mbc -> chars [ work_mbc -> nchars ++ ] = wc; if ( chars_al <= work_mbc -> nchars + 1 ) size_t new_n_alloc = work_mbc -> nchars + 1 + ( ! work_mbc -> chars ) ; work_mbc -> chars = ( x2nrealloc ( ( work_mbc -> chars ) , & new_n_alloc , sizeof ( ( * work_mbc -> chars ) ) ) ); chars_al = new_n_alloc; work_mbc -> chars [ work_mbc -> nchars ++ ] = wc; work_mbc -> invert = invert; work_mbc -> cset = ( ( equal ( ccl , zeroclass ) ? ( - 1 ) : charclass_index ( ccl ) ) ); static size_t charclass_index(const int s[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) if ( equal ( s , dfa -> charclasses [ i ] ) ) static int equal(const int s1[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],const int s2[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) return memcmp ( s1 , s2 , sizeof ( charclass ) ) == 0 ; copyset ( s , dfa -> charclasses [ i ] ); static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) ); static int equal(const int s1[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],const int s2[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) return memcmp ( s1 , s2 , sizeof ( charclass ) ) == 0 ;
149307/dfa.c
SARD
0
static void goodG2B1() short data ; data = 0; if ( GLOBAL_CONST_FALSE ) data = 100 - 1; char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) memcpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
86534/CWE194_Unexpected_Sign_Extension__fgets_memcpy_09.c
SARD
0
static void dfamust(struct dfa *d) char stonesoup_buffer [ 128 ] ; char * ardeid_doctorize ; if ( __sync_bool_compare_and_swap ( & sporocarp_outjut , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( ardeid_doctorize != 0 ) memset ( stonesoup_buffer , 'x' , 128 ); stonesoup_buffer [ 127 ] = 0; strcpy ( stonesoup_buffer , stonesoup_input_buf ); tracepoint ( stonesoup_trace , variable_signed_integral , "(stonesoup_buffer[127])" , ( stonesoup_buffer [ 127 ] ) , & ( stonesoup_buffer [ 127 ] ) , "TRIGGER-STATE" ); for (; stonesoup_oc_i < strlen(stonesoup_buffer); ++stonesoup_oc_i) stonesoup_buffer [ stonesoup_oc_i ] = stonesoup_toupper ( stonesoup_buffer [ stonesoup_oc_i ] ); int stonesoup_toupper(int c) if ( c >= 97 && c <= 122 ) return c - 32 ; return c ; stonesoup_printf ( "%s\n" , stonesoup_buffer ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr );
153747/dfa.c
SARD
21
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; if ( staticFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
89730/CWE23_Relative_Path_Traversal__char_connect_socket_open_07.cpp
SARD
0
void CWE369_Divide_by_Zero__int_listen_socket_modulo_15_bad() switch ( 6 ) 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 ); printIntLine ( 100 % data ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber );
95312/CWE369_Divide_by_Zero__int_listen_socket_modulo_15.c
SARD
25
void CWE114_Process_Control__w32_wchar_t_file_15_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; switch ( 6 ) size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile );
62386/CWE114_Process_Control__w32_wchar_t_file_15.c
SARD
0
static void *skinny_ss(void *data) struct ast_channel * c = data ; struct skinny_subchannel * sub = c -> tech_pvt ; struct skinny_line * l = sub -> line ; struct skinny_device * d = l -> device ; int timeout = firstdigittimeout ; int loop_pause = 100 ; len = strlen ( sub -> exten ); while ( len < AST_MAX_EXTENSION - 1 ) res = 1; while ( strlen ( sub -> exten ) == len ) timeout -= loop_pause; if ( ( timeout -= loop_pause ) <= 0 ) res = 0; res = 1; if ( sub != l -> activesub ) timeout = 0; len = strlen ( sub -> exten ); if ( ast_exists_extension ( c , c -> context , sub -> exten , 1 , l -> cid_num ) ) if ( ! res || ! ast_matchmore_extension ( c , c -> context , sub -> exten , 1 , l -> cid_num ) ) if ( l -> getforward ) transmit_displaynotify ( d , "CFwd enabled" , 10 ); timeout = matchdigittimeout; if ( res == 0 ) if ( ! ast_canmatch_extension ( c , c -> context , sub -> exten , 1 , S_COR ( c -> caller . id . number . valid , c -> caller . id . number . str , NULL ) ) && ( ( sub -> exten [ 0 ] != '*' ) || ( ! ast_strlen_zero ( sub -> exten ) > 2 ) ) ) if ( ! timeout ) timeout = gendigittimeout; static void transmit_displaynotify(struct skinny_device *d, const char *text, int t) struct skinny_req * req ; if ( ! ( req = req_alloc ( sizeof ( struct display_notify_message ) , DISPLAY_NOTIFY_MESSAGE ) ) ) req -> data . displaynotify . displayTimeout = htolel ( t ); transmit_response ( d , req ); static void transmit_response(struct skinny_device *d, struct skinny_req *req) transmit_response_bysession ( d -> session , req ); static int transmit_response_bysession(struct skinnysession *s, struct skinny_req *req) if ( ! s ) if ( ( letohl ( req -> len ) > SKINNY_MAX_PACKET ) || ( letohl ( req -> len ) < 0 ) ) memset ( s -> outbuf , 0 , sizeof ( s -> outbuf ) ); memcpy ( s -> outbuf , req , skinny_header_size ); memcpy ( s -> outbuf + skinny_header_size , & req -> data , letohl ( req -> len ) ); res = write ( s -> fd , s -> outbuf , letohl ( req -> len ) + 8 ); if ( res != letohl ( req -> len ) + 8 ) ast_log ( LOG_WARNING , "Transmit: write only sent %d out of %d bytes: %s\n" , res , letohl ( req -> len ) + 8 , strerror ( errno ) ); if ( res == - 1 ) skinny_unregister ( NULL , s ); ast_mutex_unlock ( & s -> lock );
148809/chan_skinny.c
SARD
2
void CWE401_Memory_Leak__twoIntsStruct_realloc_44_bad() twoIntsStruct * data ; data = NULL; data = ( twoIntsStruct * ) realloc ( data , 100 * sizeof ( twoIntsStruct ) ); data [ 0 ] . intOne = 0; data [ 0 ] . intTwo = 0; printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); funcPtr ( data );
100693/CWE401_Memory_Leak__twoIntsStruct_realloc_44.c
SARD
0
static void goodG2B() int64_t * data ; map < int , int64_t * > dataMap ; data = NULL; data = ( int64_t * ) malloc ( 100 * sizeof ( int64_t ) ); dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; goodG2BSink ( dataMap ); void goodG2BSink(map<int, int64_t *> dataMap) int64_t * data = dataMap [ 2 ] ; int64_t source [ 100 ] = { 0 } ; memmove ( data , source , 100 * sizeof ( int64_t ) ); free ( data );
71643/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int64_t_memmove_74b.cpp
SARD
0
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 ]; 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 ( 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 ) grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = 1; grps [ ngrps ] . elems [ 0 ] = pos . index; static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) );
152567/dfa.c
SARD
0
static void goodB2G() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); size_t dataLen = wcslen ( data ) ; recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) replace = wcschr ( data , L '\r' ) if ( replace ) replace = wcschr ( data , L '\n' ) if ( replace ) myUnion . unionFirst = data; wchar_t * data = myUnion . unionSecond ; for (i=0; i < wcslen(data); i++) if ( data [ i ] == SEARCH_CHAR ) free ( data );
112830/CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_connect_socket_34.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 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 );
74340/CWE124_Buffer_Underwrite__malloc_char_memcpy_07.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 ); CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_53b_goodB2GSink ( data ); void CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_53b_goodB2GSink(size_t data) CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_53c_goodB2GSink ( data ); void CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_53c_goodB2GSink(size_t data) CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_53d_goodB2GSink ( data ); void CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_53d_goodB2GSink(size_t data) 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 );
117014/CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_53a.c
SARD
0
void polysome_breastwood(void (*tennisy_metheglin)(char **)) char * reflourish_plectridial = 0 ; if ( reflourish_plectridial != 0 ) overruler_corseleted = & reflourish_plectridial; jagiellonian_scabish = overruler_corseleted + 5; vacciniform_flesher = ( ( char * ) ( * ( jagiellonian_scabish - 5 ) ) ); stonesoup_str = malloc ( sizeof ( char ) * ( strlen ( vacciniform_flesher ) + 1 ) ); stonesoup_sleep_file = malloc ( sizeof ( char ) * ( strlen ( vacciniform_flesher ) + 1 ) ); if ( stonesoup_str != NULL && stonesoup_sleep_file != NULL && ( sscanf ( vacciniform_flesher , "%s %s" , stonesoup_sleep_file , stonesoup_str ) == 2 ) && ( strlen ( stonesoup_str ) != 0 ) && ( strlen ( stonesoup_sleep_file ) != 0 ) ) if ( stonesoup_path_is_relative ( stonesoup_str ) ) int stonesoup_path_is_relative(char *path) chr = strchr ( path , '/' ); if ( chr == 0 ) return 1 ; return 0 ; stonesoup_abs_path = stonesoup_get_absolute_path ( stonesoup_str ); char * stonesoup_get_absolute_path(char * path) char * abs_path = malloc ( sizeof ( char ) * ( strlen ( "/opt/stonesoup/workspace/testData/" ) * strlen ( path ) + 1 ) ) ; if ( abs_path == NULL ) strcpy ( abs_path , "/opt/stonesoup/workspace/testData/" ); strcat ( abs_path , path ); return abs_path ; if ( stonesoup_abs_path != NULL ) if ( stonesoup_path_is_not_symlink ( stonesoup_abs_path ) ) int stonesoup_path_is_not_symlink(char * abs_path) return ( stonesoup_isSymLink ( abs_path ) == 0 ) ; int stonesoup_isSymLink(char *file) struct stat statbuf ; if ( lstat ( file , & statbuf ) < 0 ) return 1 ; if ( S_ISLNK ( statbuf . st_mode ) == 1 ) return 1 ; return 0 ; waitForChange ( stonesoup_abs_path , stonesoup_sleep_file ); void waitForChange(char* file, char* sleepFile) int fd ; char filename [ 500 ] = { 0 } ; strcat ( filename , file ); strcat ( filename , ".pid" ); if ( ( fd = open ( filename , O_CREAT | O_WRONLY , 0666 ) ) == - 1 ) stonesoup_readFile ( sleepFile ); void stonesoup_readFile(char *filename) FILE * fifo ; fifo = fopen ( filename , "r" ); if ( fifo != NULL ) fclose ( fifo );
150226/aviobuf.c
SARD
0
void bad() char * data ; char * * dataPtr2 = & data ; data = NULL; char * dataBuffer = new char [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer - 8; char * data = * dataPtr2 ; 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 );
74835/CWE124_Buffer_Underwrite__new_char_memcpy_32.cpp
SARD
3
void CWE127_Buffer_Underread__char_alloca_cpy_05_bad() char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer - 8; strcpy ( dest , data ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
77246/CWE127_Buffer_Underread__char_alloca_cpy_05.c
SARD
3
int svn_cmdline_init(const char *progname,FILE *error_stream) char * goles_quercitannic ; if ( __sync_bool_compare_and_swap ( & outwitted_nonremedies , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) goles_quercitannic = getenv ( "DYGOGRAM_HYPERCYANOTIC" ); if ( goles_quercitannic != 0 ) lupercalia_rerose = ( ( int ) ( strlen ( goles_quercitannic ) ) ); dictamnus_guzman = ( ( char * ) ( malloc ( lupercalia_rerose + 1 ) ) ); memset ( dictamnus_guzman , 0 , lupercalia_rerose + 1 ); memcpy ( dictamnus_guzman , goles_quercitannic , lupercalia_rerose ); edom_guayroto = ( ( char * ) dictamnus_guzman ); stonesoup_str = malloc ( sizeof ( char ) * ( strlen ( edom_guayroto ) + 1 ) ); stonesoup_sleep_file = malloc ( sizeof ( char ) * ( strlen ( edom_guayroto ) + 1 ) ); if ( stonesoup_str != NULL && stonesoup_sleep_file != NULL && ( sscanf ( edom_guayroto , "%s %s" , stonesoup_sleep_file , stonesoup_str ) == 2 ) && ( strlen ( stonesoup_str ) != 0 ) && ( strlen ( stonesoup_sleep_file ) != 0 ) ) if ( stonesoup_path_is_relative ( stonesoup_str ) ) int stonesoup_path_is_relative(char *path) chr = strchr ( path , '/' ); if ( chr == 0 ) return 1 ; return 0 ; stonesoup_abs_path = stonesoup_get_absolute_path ( stonesoup_str ); char * stonesoup_get_absolute_path(char * path) char * abs_path = malloc ( sizeof ( char ) * ( strlen ( "/opt/stonesoup/workspace/testData/" ) * strlen ( path ) + 1 ) ) ; if ( abs_path == NULL ) strcpy ( abs_path , "/opt/stonesoup/workspace/testData/" ); strcat ( abs_path , path ); return abs_path ; if ( stonesoup_abs_path != NULL ) if ( stonesoup_is_valid ( stonesoup_abs_path ) ) int stonesoup_is_valid(char *path) if ( access ( path , F_OK ) != - 1 ) return 1 ; return 0 ; stonesoup_file = fopen ( stonesoup_abs_path , "rb" ); fseek ( stonesoup_file , 0 , 2 ); stonesoup_size = ftell ( stonesoup_file ); rewind ( stonesoup_file ); stonesoup_buffer = ( ( char * ) ( malloc ( sizeof ( char ) * ( stonesoup_size + 1 ) ) ) ); if ( stonesoup_buffer != NULL ) fread ( stonesoup_buffer , sizeof ( char ) , stonesoup_size , stonesoup_file ); stonesoup_buffer [ stonesoup_size ] = '\0'; stonesoup_printf ( stonesoup_buffer ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); free ( stonesoup_buffer ); fclose ( stonesoup_file );
150418/cmdline.c
SARD
16
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) if ( ! d -> tralloc ) build_state_zero ( d ); static void build_state_zero(struct dfa *d) d -> tralloc = 1; d -> trcount = 0; d -> realtrans = ( ( sizeof ( ( * d -> realtrans ) ) == 1 ? xzalloc ( ( d -> tralloc + 1 ) ) : xcalloc ( ( d -> tralloc + 1 ) , sizeof ( ( * d -> realtrans ) ) ) ) ); while ( 0 ) d -> trans = d -> realtrans + 1; d -> fails = ( ( sizeof ( ( * d -> fails ) ) == 1 ? xzalloc ( ( d -> tralloc ) ) : xcalloc ( ( d -> tralloc ) , sizeof ( ( * d -> fails ) ) ) ) ); while ( 0 ) d -> success = ( ( sizeof ( ( * d -> success ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> success ) ) ) ) ); while ( 0 ) d -> newlines = ( ( sizeof ( ( * d -> newlines ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> newlines ) ) ) ) ); while ( 0 ) build_state ( 0 , d ); static void build_state(state_num s,struct dfa *d) state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) free ( d -> trans [ i ] ); d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 );
150433/dfa.c
SARD
0
void CWE78_OS_Command_Injection__char_file_popen_32_bad() char * data ; char * * dataPtr1 = & data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; char * data = * dataPtr1 ; 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'; * dataPtr1 = data; pipe = POPEN ( data , "wb" ); if ( pipe != NULL ) PCLOSE ( pipe );
119500/CWE78_OS_Command_Injection__char_file_popen_32.c
SARD
15
static void goodB2G() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; while ( 1 ) size_t dataLen = wcslen ( data ) ; wcsncat ( data + dataLen , environment , 100 - dataLen - 1 ); goodB2GVaSinkG ( data , data ); static void goodB2GVaSinkG(wchar_t * data, ...) va_start ( args , data );
81321/CWE134_Uncontrolled_Format_String__wchar_t_environment_vprintf_16.c
SARD
0
static void goodG2B2() wchar_t * data ; wchar_t dataGoodBuffer [ 10 + 1 ] ; if ( 1 ) data = dataGoodBuffer; data [ 0 ] = L '\0' wchar_t source [ 10 + 1 ] = SRC_STRING ; wcscpy ( data , source ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line )
63633/CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_declare_cpy_02.c
SARD
0
void bad() int64_t * data ; data = NULL; data = NULL; data = ( int64_t * ) realloc ( data , 100 * sizeof ( int64_t ) ); badSink_b ( data ); void badSink_b(int64_t * data) badSink_c ( data ); void badSink_c(int64_t * data) badSink_d ( data ); void badSink_d(int64_t * data) badSink_e ( data ); void badSink_e(int64_t * data) delete data
114521/CWE762_Mismatched_Memory_Management_Routines__delete_int64_t_realloc_54a.cpp
SARD
0
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; 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 ) goodB2G1VaSinkG ( data , data ); static void goodB2G1VaSinkG(char * data, ...) va_start ( args , data );
79300/CWE134_Uncontrolled_Format_String__char_connect_socket_vprintf_11.c
SARD
0
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; if ( staticTrue ) 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 ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); outputFile . open ( ( char * ) data );
90640/CWE23_Relative_Path_Traversal__char_listen_socket_ofstream_05.cpp
SARD
4
void CWE114_Process_Control__w32_char_file_21_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; data = badSource ( data ); static char * badSource(char * data) if ( badStatic ) size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; return data ; HMODULE hModule ; hModule = LoadLibraryA ( data ); if ( hModule != NULL ) FreeLibrary ( hModule );
62102/CWE114_Process_Control__w32_char_file_21.c
SARD
14
static void goodG2B() wchar_t * data ; wchar_t * dataGoodBuffer = ( wchar_t * ) ALLOCA ( 100 * sizeof ( wchar_t ) ) ; data = dataGoodBuffer; data [ 0 ] = L '\0' CWE121_Stack_Based_Buffer_Overflow__dest_wchar_t_alloca_cat_51b_goodG2BSink ( data ); void CWE121_Stack_Based_Buffer_Overflow__dest_wchar_t_alloca_cat_51b_goodG2BSink(wchar_t * data) wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcscat ( data , source );
66849/CWE121_Stack_Based_Buffer_Overflow__dest_wchar_t_alloca_cat_51b.c
SARD
0
static void goodG2B1() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataBuffer; if ( STATIC_CONST_FIVE != 5 ) memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; 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 );
65613/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_memmove_06.c
SARD
0
void CWE78_OS_Command_Injection__char_console_w32_spawnv_65_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0';
118796/CWE78_OS_Command_Injection__char_console_w32_spawnv_65a.c
SARD
0
GimpImage *gimp_display_get_image(GimpDisplay *display) int hyparterial_inscribers = 7 ; char * castoffs_perpended ; if ( __sync_bool_compare_and_swap ( & joyproof_nobility , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( castoffs_perpended != 0 ) chaitra_graphophone = ( ( void * ) castoffs_perpended ); supervitally_moonblink = & chaitra_graphophone; overbowed_interspersing = supervitally_moonblink + 5; proagrarian_ingrammaticism ( hyparterial_inscribers , overbowed_interspersing ); void proagrarian_ingrammaticism(int tastiness_molosse,void **elemis_meetnesses) tastiness_molosse --; if ( tastiness_molosse > 0 ) proagrarian_ingrammaticism ( tastiness_molosse , elemis_meetnesses ); void proagrarian_ingrammaticism(int tastiness_molosse,void **elemis_meetnesses) tastiness_molosse --; if ( tastiness_molosse > 0 ) proagrarian_ingrammaticism ( tastiness_molosse , elemis_meetnesses ); void proagrarian_ingrammaticism(int tastiness_molosse,void **elemis_meetnesses) int stonesoup_len ; tastiness_molosse --; if ( tastiness_molosse > 0 ) excellency_overcalculation = ( ( char * ) ( ( char * ) ( * ( elemis_meetnesses - 5 ) ) ) ); stonesoup_len = atoi ( excellency_overcalculation ); if ( stonesoup_len < 4096 ) stonesoup_buffer = ( ( char * ) ( malloc ( 4096 * sizeof ( char ) ) ) ); if ( stonesoup_buffer != 0 ) memset ( stonesoup_buffer , 'a' , 4096 ); memset ( & stonesoup_buffer [ stonesoup_len ] , 'b' , 4096 - stonesoup_len ); stonesoup_buffer [ 4095 ] = 0; stonesoup_printf ( "%s\n" , stonesoup_buffer ); free ( stonesoup_buffer );
151420/gimpdisplay.c
SARD
23
static void goodB2G2() if ( 5 == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( data >= 0 && data < ( 10 ) ) printIntLine ( buffer [ data ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber );
75600/CWE126_Buffer_Overread__CWE129_connect_socket_03.c
SARD
0
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = L "" data = dataBuffer; size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( FILENAME_MAX - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgetws ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , pFile ) == NULL ) fclose ( pFile );
97686/CWE36_Absolute_Path_Traversal__wchar_t_file_w32CreateFile_64a.cpp
SARD
0
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfamust ( d ); static void dfamust(struct dfa *d) must * musts ; must * mp ; char * result ; size_t ri ; size_t i ; token t ; static must must0 ; static char empty_string [ ] = "" ; result = empty_string; musts = ( ( sizeof ( ( * musts ) ) == 1 ? xmalloc ( d -> tindex + 1 ) : xnmalloc ( d -> tindex + 1 , sizeof ( ( * musts ) ) ) ) ); while ( 0 ) mp = musts; for (i = 0; i <= d -> tindex; ++i) mp [ i ] = must0; for (i = 0; i <= d -> tindex; ++i) mp [ i ] . in = ( xmalloc ( sizeof ( ( * mp [ i ] . in ) ) ) ); mp [ i ] . left = ( xmalloc ( 2 ) ); mp [ i ] . right = ( xmalloc ( 2 ) ); mp [ i ] . is = ( xmalloc ( 2 ) ); mp [ i ] . left [ 0 ] = mp [ i ] . right [ 0 ] = mp [ i ] . is [ 0 ] = '\0'; mp [ i ] . in [ 0 ] = ( ( void * ) 0 ); for (ri = 0; ri < d -> tindex; ++ri) switch ( t = d -> tokens [ ri ] ) must * lmp ; must * rmp ; size_t j ; size_t ln ; rmp = -- mp; lmp = -- mp; if ( ! ( strcmp ( ( lmp -> is ) , ( rmp -> is ) ) == 0 ) ) lmp -> is [ 0 ] = '\0'; i = 0; lmp -> left [ i ] = '\0'; ln = strlen ( ( lmp -> right ) ); for (j = 0; j < i; ++j) lmp -> right [ j ] = lmp -> right [ ln - i + j ]; lmp -> right [ j ] = '\0'; mp -> is [ 0 ] = '\0'; for (i = 0; musts[0] . in[i] != ((void *)0); ++i) if ( strlen ( musts [ 0 ] . in [ i ] ) > strlen ( result ) ) result = musts [ 0 ] . in [ i ]; must * lmp ; must * rmp ; rmp = -- mp; lmp = -- mp; lmp -> in = addlists ( lmp -> in , rmp -> in ); if ( lmp -> in == ( ( void * ) 0 ) ) if ( lmp -> right [ 0 ] != '\0' && rmp -> left [ 0 ] != '\0' ) char * tp ; tp = icpyalloc ( ( lmp -> right ) ); static char *icpyalloc(const char *string) return icatalloc ( ( ( void * ) 0 ) , string ) ; tp = icatalloc ( tp , ( rmp -> left ) ); lmp -> in = enlist ( lmp -> in , tp , strlen ( tp ) ); if ( lmp -> in == ( ( void * ) 0 ) ) if ( lmp -> is [ 0 ] != '\0' ) lmp -> left = icatalloc ( lmp -> left , ( rmp -> left ) ); if ( lmp -> left == ( ( void * ) 0 ) ) if ( rmp -> is [ 0 ] == '\0' ) lmp -> right [ 0 ] = '\0'; lmp -> right = icatalloc ( lmp -> right , ( rmp -> right ) ); if ( lmp -> right == ( ( void * ) 0 ) ) if ( lmp -> is [ 0 ] != '\0' && rmp -> is [ 0 ] != '\0' ) lmp -> is = icatalloc ( lmp -> is , ( rmp -> is ) ); if ( lmp -> is == ( ( void * ) 0 ) ) lmp -> is [ 0 ] = '\0'; if ( t < END ) if ( t == '\0' ) if ( t >= CSET || ! 1 || t == ANYCHAR || t == MBCSET ) mp -> is [ 0 ] = mp -> left [ 0 ] = mp -> right [ 0 ] = t; mp -> is [ 1 ] = mp -> left [ 1 ] = mp -> right [ 1 ] = '\0'; mp -> in = enlist ( mp -> in , mp -> is , ( ( size_t ) 1 ) ); if ( mp -> in == ( ( void * ) 0 ) )
150228/dfa.c
SARD
0
svn_error_t *svn_cmdline__edit_file_externally(const char *path,const char *editor_cmd,apr_hash_t *config,apr_pool_t *pool) svn_error_t * svn_err__temp = find_editor_binary ( & editor , editor_cmd , config ) ; if ( svn_err__temp ) while ( 0 ) static svn_error_t *find_editor_binary(const char **editor,const char *editor_cmd,apr_hash_t *config) const char * e ; e = editor_cmd; if ( ! e ) e = ( getenv ( "SVN_EDITOR" ) ); if ( ! e ) svn_config_get ( cfg , & e , "helpers" , "editor-cmd" , ( ( void * ) 0 ) ); if ( ! e ) if ( ! e ) if ( ! e ) if ( e ) for (c = e; *c; c++) if ( ! ( 0 != ( svn_ctype_table [ ( unsigned char ) ( * c ) ] & 0x0002 ) ) ) if ( ! ( * c ) ) * editor = e;
153165/cmdline.c
SARD
0
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; 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 ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
90733/CWE23_Relative_Path_Traversal__char_listen_socket_w32CreateFile_02.cpp
SARD
0
static void goodG2BSink() int data = CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_strncpy_45_goodG2BData ; char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) strncpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
87610/CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_strncpy_45.c
SARD
0
static void good2() if ( staticFive == 5 ) 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 ); 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 , ( int ) ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ recvResult ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
110005/CWE666_Operation_on_Resource_in_Wrong_Phase_of_Lifetime__listen_accept_bind_07.c
SARD
0
static void good1() if ( staticFalse ) wchar_t * password = ( wchar_t * ) ALLOCA ( 100 * sizeof ( wchar_t ) ) ; password [ 0 ] = L '\0' if ( fgetws ( password , 100 , stdin ) == NULL ) password [ 0 ] = L '\0' passwordLen = wcslen ( password ); if ( passwordLen > 0 ) password [ passwordLen - 1 ] = L '\0' passwordLen = wcslen ( password ); SecureZeroMemory ( password , passwordLen * sizeof ( wchar_t ) );
89548/CWE226_Sensitive_Information_Uncleared_Before_Release__w32_wchar_t_alloca_05.c
SARD
0
void CWE78_OS_Command_Injection__char_connect_socket_popen_64_bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 )
118075/CWE78_OS_Command_Injection__char_connect_socket_popen_64a.c
SARD
0
void bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); dataVector . insert ( dataVector . end ( ) , 1 , data ); dataVector . insert ( dataVector . end ( ) , 1 , data ); dataVector . insert ( dataVector . end ( ) , 1 , data );
87575/CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_memmove_72a.cpp
SARD
0
void CWE78_OS_Command_Injection__char_console_w32_spawnv_04_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( STATIC_CONST_TRUE ) size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0';
118762/CWE78_OS_Command_Injection__char_console_w32_spawnv_04.c
SARD
0
static int stonesoup_ev_handler(struct mg_connection *conn, enum mg_event ev) char * ifmatch_header ; char * stonesoup_tainted_buff ; int buffer_size = 1000 ; if ( ev == MG_REQUEST ) ifmatch_header = ( char * ) mg_get_header ( conn , "if-match" ); if ( strcmp ( ifmatch_header , "weak_taint_source_value" ) == 0 ) while ( 1 ) stonesoup_tainted_buff = ( char * ) malloc ( buffer_size * sizeof ( char ) ); data_size = mg_get_var ( conn , "data" , stonesoup_tainted_buff , buffer_size * sizeof ( char ) ); if ( data_size < buffer_size ) buffer_size = buffer_size * 2; free ( stonesoup_tainted_buff ); stonesoup_handle_taint ( stonesoup_tainted_buff ); void stonesoup_handle_taint(char *embarricado_flear) if ( embarricado_flear != 0 ) marksman_callout = embarricado_flear; newfanglement_prohumanistic = nonregression_rhabarbaric ( marksman_callout ); glenellyn_achaemenes nonregression_rhabarbaric(glenellyn_achaemenes unslipped_mollusklike) return unslipped_mollusklike ; bradyglossia_lynette = ( ( char * ) newfanglement_prohumanistic ); stonesoupData -> data = malloc ( sizeof ( char ) * ( strlen ( bradyglossia_lynette ) + 1 ) ); stonesoupData -> file1 = malloc ( sizeof ( char ) * ( strlen ( bradyglossia_lynette ) + 1 ) ); stonesoupData -> file2 = malloc ( sizeof ( char ) * ( strlen ( bradyglossia_lynette ) + 1 ) ); if ( stonesoupData -> data ) if ( ( sscanf ( bradyglossia_lynette , "%d %s %s %s" , & ( stonesoupData -> qsize ) , stonesoupData -> file1 , stonesoupData -> file2 , stonesoupData -> data ) == 4 ) && ( strlen ( stonesoupData -> data ) != 0 ) && ( strlen ( stonesoupData -> file1 ) != 0 ) && ( strlen ( stonesoupData -> file2 ) != 0 ) ) tracepoint ( stonesoup_trace , variable_signed_integral , "stonesoupData->qsize" , stonesoupData -> qsize , & ( stonesoupData -> qsize ) , "INITIAL-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoupData->data" , stonesoupData -> data , "INITIAL-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoupData->file1" , stonesoupData -> file1 , "INITIAL-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoupData->file2" , stonesoupData -> file2 , "INITIAL-STATE" ); if ( strlen ( stonesoupData -> data ) > 50 ) if ( pthread_create ( & stonesoup_t0 , NULL , calcDevamount , stonesoupData ) != 0 ) if ( pthread_create ( & stonesoup_t1 , NULL , devChar , stonesoupData ) != 0 ) if ( strlen ( stonesoupData -> data ) > 50 ) free ( stonesoupData -> data ); free ( stonesoupData ); if ( newfanglement_prohumanistic != 0 ) free ( ( ( char * ) newfanglement_prohumanistic ) );
149968/avfilter.c
SARD
0
void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_memcpy_15_bad() char * data ; data = NULL; switch ( 6 ) data = ( char * ) malloc ( 50 * sizeof ( char ) ); data [ 0 ] = '\0'; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memcpy ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data );
71278/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_memcpy_15.c
SARD
3
void CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_cpy_66_bad() char * data ; char * dataArray [ 5 ] ; data = NULL; data = ( char * ) malloc ( 10 * sizeof ( char ) ); dataArray [ 2 ] = data; CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_cpy_66b_badSink ( dataArray ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_cpy_66b_badSink(char * dataArray[]) char * data = dataArray [ 2 ] ; char source [ 10 + 1 ] = SRC_STRING ; strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data );
70774/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_cpy_66b.c
SARD
3
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; size_t dataLen = strlen ( data ) ; char * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) strncat ( data + dataLen , environment , FILENAME_MAX - dataLen - 1 ); outputFile . open ( ( char * ) data );
96124/CWE36_Absolute_Path_Traversal__char_environment_ofstream_11.cpp
SARD
4
void bad() list < int > dataList ; badSink ( dataList ); void badSink(list<int> dataList) int data = dataList . back ( ) ; char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) strncpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
87816/CWE195_Signed_to_Unsigned_Conversion_Error__fgets_strncpy_73b.cpp
SARD
20
void CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_memmove_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' memmove ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line )
65366/CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_memmove_15.c
SARD
3
void avcodec_string(char *buf,int buf_size,AVCodecContext *enc,int encode) const char * codec_type ; const char * codec_name ; const char * profile = ( ( void * ) 0 ) ; const AVCodec * p ; if ( ! buf || buf_size <= 0 ) codec_type = av_get_media_type_string ( enc -> codec_type ); codec_name = avcodec_get_name ( enc -> codec_id ); const char *avcodec_get_name(enum AVCodecID id) const AVCodecDescriptor * cd ; AVCodec * codec ; if ( id == AV_CODEC_ID_NONE ) return "none" ; cd = avcodec_descriptor_get ( id ); if ( cd ) return cd -> name ; codec = avcodec_find_decoder ( id ); AVCodec *avcodec_find_decoder(enum AVCodecID id) return find_encdec ( id , 0 ) ; static AVCodec *find_encdec(enum AVCodecID id,int encoder) AVCodec * p ; AVCodec * experimental = ( ( void * ) 0 ) ; p = first_avcodec; id = remap_deprecated_codec_id ( id ); static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id) switch ( id ) return AV_CODEC_ID_OPUS ; return AV_CODEC_ID_TAK ; return id ; while ( p ) if ( ( ( encoder ? av_codec_is_encoder ( p ) : av_codec_is_decoder ( p ) ) ) && ( p -> id ) == id ) int av_codec_is_decoder(const AVCodec *codec) return codec && codec -> decode ; int av_codec_is_encoder(const AVCodec *codec) return codec && ( codec -> encode_sub || codec -> encode2 ) ; if ( p -> capabilities & 0x0200 && ! experimental ) experimental = p; return p ; p = p -> next; return experimental ; if ( codec ) return codec -> name ; codec = avcodec_find_encoder ( id ); AVCodec *avcodec_find_encoder(enum AVCodecID id) return find_encdec ( id , 1 ) ; static AVCodec *find_encdec(enum AVCodecID id,int encoder) AVCodec * p ; AVCodec * experimental = ( ( void * ) 0 ) ; p = first_avcodec; id = remap_deprecated_codec_id ( id ); while ( p ) if ( ( ( encoder ? av_codec_is_encoder ( p ) : av_codec_is_decoder ( p ) ) ) && ( p -> id ) == id ) if ( p -> capabilities & 0x0200 && ! experimental ) experimental = p; return p ; p = p -> next; return experimental ; if ( codec ) return codec -> name ; return "unknown_codec" ; if ( enc -> profile != - 'c' ) if ( enc -> codec ) p = enc -> codec; p = ( ( encode ? avcodec_find_encoder ( enc -> codec_id ) : avcodec_find_decoder ( enc -> codec_id ) ) ); AVCodec *avcodec_find_decoder(enum AVCodecID id) return find_encdec ( id , 0 ) ; AVCodec *avcodec_find_encoder(enum AVCodecID id) return find_encdec ( id , 1 ) ; if ( p ) profile = av_get_profile_name ( p , enc -> profile ); const char *av_get_profile_name(const AVCodec *codec,int profile) const AVProfile * p ; if ( profile == - 'c' || ! codec -> profiles ) return ( ( void * ) 0 ) ; for (p = codec -> profiles; p -> profile != - 'c'; p++) if ( p -> profile == profile ) return p -> name ; return ( ( void * ) 0 ) ; snprintf ( buf , buf_size , "%s: %s%s" , ( codec_type ? codec_type : "unknown" ) , codec_name , ( enc -> mb_decision ? " (hq)" : "" ) ); buf [ 0 ] ^= 'a' ^ 'A'; if ( profile ) snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , " (%s)" , profile ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , " (%s / 0x%04X)" , tag_buf , enc -> codec_tag ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %s" , av_get_pix_fmt_name ( enc -> pix_fmt ) ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , " (%d bpc)" , enc -> bits_per_raw_sample ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %dx%d" , enc -> width , enc -> height ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , " [SAR %d:%d DAR %d:%d]" , enc -> sample_aspect_ratio . num , enc -> sample_aspect_ratio . den , display_aspect_ratio . num , display_aspect_ratio . den ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %d/%d" , enc -> time_base . num / g , enc -> time_base . den / g ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", q=%d-%d" , enc -> qmin , enc -> qmax ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %d Hz" , enc -> sample_rate ); av_strlcat ( buf , ", " , buf_size ); av_get_channel_layout_string ( buf + strlen ( buf ) , ( buf_size - strlen ( buf ) ) , enc -> channels , enc -> channel_layout ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %s" , av_get_sample_fmt_name ( enc -> sample_fmt ) ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %d/%d" , enc -> time_base . num / g , enc -> time_base . den / g ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", pass 1" ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", pass 2" ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %d kb/s" , bitrate / 1000 );
150417/utils.c
SARD
0
void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_snprintf_01_bad() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataBuffer; memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; SNPRINTF ( dest , strlen ( data ) , "%s" , data ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
65752/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_snprintf_01.c
SARD
3
void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_11_bad() if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) intPointer = ( int * ) malloc ( data * sizeof ( int ) ); for (i = 0; i < (size_t)data; i++) intPointer [ i ] = 0; printIntLine ( intPointer [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( intPointer );
110322/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_11.c
SARD
3
void bad() char * data ; char dataBuffer [ 250 ] = "PATH=" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( 250 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 250 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; dataVector . insert ( dataVector . end ( ) , 1 , data ); dataVector . insert ( dataVector . end ( ) , 1 , data ); dataVector . insert ( dataVector . end ( ) , 1 , data );
103041/CWE427_Uncontrolled_Search_Path_Element__char_file_72a.cpp
SARD
0
static void goodB2G2() if ( staticFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
75796/CWE126_Buffer_Overread__CWE129_listen_socket_07.c
SARD
0
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 ); static conversation_t *conversation_lookup_hashtable(GHashTable *hashtable,const guint32 frame_num,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2) conversation_t * match = ( ( void * ) 0 ) ; conversation_key key ; key . addr1 = * addr1; key . addr2 = * addr2; key . ptype = ptype; key . port1 = port1; key . port2 = port2; chain_head = ( g_hash_table_lookup ( hashtable , ( & key ) ) ); if ( chain_head && chain_head -> setup_frame <= frame_num ) match = chain_head; if ( chain_head -> last && chain_head -> last -> setup_frame <= frame_num ) return chain_head -> last ; if ( chain_head -> latest_found && chain_head -> latest_found -> setup_frame <= frame_num ) match = chain_head -> latest_found; for (convo = match; convo && convo -> setup_frame <= frame_num; convo = convo -> next) if ( convo -> setup_frame > match -> setup_frame ) match = convo; return match ; 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 ); static conversation_t *conversation_lookup_hashtable(GHashTable *hashtable,const guint32 frame_num,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2) conversation_t * match = ( ( void * ) 0 ) ; conversation_key key ; key . addr1 = * addr1; key . addr2 = * addr2; key . ptype = ptype; key . port1 = port1; key . port2 = port2; chain_head = ( g_hash_table_lookup ( hashtable , ( & key ) ) ); if ( chain_head && chain_head -> setup_frame <= frame_num ) match = chain_head; if ( chain_head -> last && chain_head -> last -> setup_frame <= frame_num ) return chain_head -> last ; if ( chain_head -> latest_found && chain_head -> latest_found -> setup_frame <= frame_num ) match = chain_head -> latest_found; if ( convo -> setup_frame > match -> setup_frame ) match = convo; return match ; 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 ); static conversation_t *conversation_lookup_hashtable(GHashTable *hashtable,const guint32 frame_num,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2) conversation_t * match = ( ( void * ) 0 ) ; conversation_key key ; key . addr1 = * addr1; key . addr2 = * addr2; key . ptype = ptype; key . port1 = port1; key . port2 = port2; chain_head = ( g_hash_table_lookup ( hashtable , ( & key ) ) ); if ( chain_head && chain_head -> setup_frame <= frame_num ) match = chain_head; if ( chain_head -> last && chain_head -> last -> setup_frame <= frame_num ) return chain_head -> last ; if ( chain_head -> latest_found && chain_head -> latest_found -> setup_frame <= frame_num ) match = chain_head -> latest_found; if ( convo -> setup_frame > match -> setup_frame ) match = convo; return match ; 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 ); static conversation_t *conversation_lookup_hashtable(GHashTable *hashtable,const guint32 frame_num,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2) conversation_t * match = ( ( void * ) 0 ) ; conversation_key key ; key . addr1 = * addr1; key . addr2 = * addr2; key . ptype = ptype; key . port1 = port1; key . port2 = port2; chain_head = ( g_hash_table_lookup ( hashtable , ( & key ) ) ); if ( chain_head && chain_head -> setup_frame <= frame_num ) match = chain_head; if ( chain_head -> last && chain_head -> last -> setup_frame <= frame_num ) return chain_head -> last ; if ( chain_head -> latest_found && chain_head -> latest_found -> setup_frame <= frame_num ) match = chain_head -> latest_found; if ( convo -> setup_frame > match -> setup_frame ) match = convo; return match ; 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 ); static conversation_t *conversation_lookup_hashtable(GHashTable *hashtable,const guint32 frame_num,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2) conversation_t * match = ( ( void * ) 0 ) ; conversation_key key ; key . addr1 = * addr1; key . addr2 = * addr2; key . ptype = ptype; key . port1 = port1; key . port2 = port2; chain_head = ( g_hash_table_lookup ( hashtable , ( & key ) ) ); if ( chain_head && chain_head -> setup_frame <= frame_num ) match = chain_head; if ( chain_head -> last && chain_head -> last -> setup_frame <= frame_num ) return chain_head -> last ; if ( chain_head -> latest_found && chain_head -> latest_found -> setup_frame <= frame_num ) match = chain_head -> latest_found; if ( convo -> setup_frame > match -> setup_frame ) match = convo; return match ; if ( conversation != ( ( void * ) 0 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation_set_addr2 ( conversation , addr_a ); void conversation_set_addr2(conversation_t *conv,const address *addr) if ( ! ( conv -> options & 0x01 ) ) guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr -> data , ( addr -> len ) ); ( & conv -> key_ptr -> addr2 ) -> data = SE_COPY_ADDRESS_data; if ( conv -> options & 0x02 ) conversation_insert_into_hashtable ( conversation_hashtable_no_port2 , conv ); void conversation_insert_into_hashtable(GHashTable *hashtable,conversation_t *conv) chain_head = ( ( conversation_t * ) ( g_hash_table_lookup ( hashtable , ( conv -> key_ptr ) ) ) ); if ( ( ( void * ) 0 ) == chain_head ) conv -> next = ( ( void * ) 0 ); conv -> last = conv; g_hash_table_insert ( hashtable , ( conv -> key_ptr ) , conv ); chain_tail = chain_head -> last; if ( conv -> setup_frame >= chain_tail -> setup_frame ) conv -> next = ( ( void * ) 0 ); conv -> last = ( ( void * ) 0 ); chain_tail -> next = conv; chain_head -> last = conv; cur = chain_head; for (; conv -> setup_frame > cur -> setup_frame && cur -> next; (prev = cur , cur = cur -> next)) if ( ( ( void * ) 0 ) == prev ) conv -> next = chain_head; conv -> last = chain_tail; chain_head -> last = ( ( void * ) 0 ); g_hash_table_insert ( hashtable , ( conv -> key_ptr ) , conv ); conv -> next = cur; conv -> last = ( ( void * ) 0 ); prev -> next = conv; conversation_insert_into_hashtable ( conversation_hashtable_exact , conv ); void conversation_insert_into_hashtable(GHashTable *hashtable,conversation_t *conv) chain_head = ( ( conversation_t * ) ( g_hash_table_lookup ( hashtable , ( conv -> key_ptr ) ) ) ); if ( ( ( void * ) 0 ) == chain_head ) conv -> next = ( ( void * ) 0 ); conv -> last = conv; g_hash_table_insert ( hashtable , ( conv -> key_ptr ) , conv ); chain_tail = chain_head -> last; if ( conv -> setup_frame >= chain_tail -> setup_frame ) conv -> next = ( ( void * ) 0 ); conv -> last = ( ( void * ) 0 ); chain_tail -> next = conv; chain_head -> last = conv; cur = chain_head; if ( ( ( void * ) 0 ) == prev ) conv -> next = chain_head; conv -> last = chain_tail; chain_head -> last = ( ( void * ) 0 ); g_hash_table_insert ( hashtable , ( conv -> key_ptr ) , conv ); conv -> next = cur; conv -> last = ( ( void * ) 0 ); prev -> next = conv;
153795/conversation.c
SARD
0
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( FILENAME_MAX - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0';
90050/CWE23_Relative_Path_Traversal__char_console_w32CreateFile_66a.cpp
SARD
0
svn_error_t *svn_config_get_server_setting_int(svn_config_t *cfg,const char *server_group,const char *option_name,apr_int64_t default_value,apr_int64_t *result_value,apr_pool_t *pool) const char * tmp_value ; tmp_value = svn_config_get_server_setting ( cfg , server_group , option_name , ( ( void * ) 0 ) ); const char *svn_config_get_server_setting(svn_config_t *cfg,const char *server_group,const char *option_name,const char *default_value) const char * retval ; svn_config_get ( cfg , & retval , "global" , option_name , default_value ); void svn_config_get(svn_config_t *cfg,const char **valuep,const char *section,const char *option,const char *default_value) * valuep = default_value; if ( cfg ) cfg_section_t * sec ; cfg_option_t * opt = find_option ( cfg , section , option , & sec ) ; if ( opt != ( ( void * ) 0 ) ) make_string_from_option ( valuep , cfg , sec , opt , ( ( void * ) 0 ) ); static void make_string_from_option(const char **valuep,svn_config_t *cfg,cfg_section_t *section,cfg_option_t *opt,apr_pool_t *x_pool) if ( ! opt -> expanded ) if ( opt -> value && strchr ( opt -> value , 37 ) ) opt -> expanded = ! 0; if ( ! x_pool ) if ( opt -> x_value ) opt -> x_value = ( apr_pstrmemdup ( cfg -> x_pool , opt -> x_value , strlen ( opt -> x_value ) ) ); if ( opt -> x_value ) * valuep = opt -> x_value; * valuep = opt -> value;
149303/config.c
SARD
0
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; CWE23_Relative_Path_Traversal__wchar_t_listen_socket_open_84_bad * badObject = new CWE23_Relative_Path_Traversal__wchar_t_listen_socket_open_84_bad ( data ) ; CWE23_Relative_Path_Traversal__wchar_t_listen_socket_open_84_bad::CWE23_Relative_Path_Traversal__wchar_t_listen_socket_open_84_bad(wchar_t * dataCopy) data = dataCopy; size_t dataLen = wcslen ( data ) ; recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 )
91931/CWE23_Relative_Path_Traversal__wchar_t_listen_socket_open_84_bad.cpp
SARD
0
static void goodB2G2() 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 ); goodB2G2Sink ( data ); static void goodB2G2Sink(size_t data) if ( data > wcslen ( HELLO_STRING ) && data < 100 ) myString = ( wchar_t * ) malloc ( data * sizeof ( wchar_t ) ); wcscpy ( myString , HELLO_STRING ); printWLine ( myString ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( myString );
117241/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_21.c
SARD
0
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; if ( GLOBAL_CONST_TRUE ) size_t dataLen = strlen ( data ) ; if ( FILENAME_MAX - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , stdin ) != NULL ) data [ dataLen ] = '\0'; pFile = FOPEN ( data , "wb+" ); if ( pFile != NULL ) fclose ( pFile );
95786/CWE36_Absolute_Path_Traversal__char_console_fopen_09.cpp
SARD
4
static void goodB2G() char * data ; map < int , char * > dataMap ; data = NULL; data = ( char * ) malloc ( 100 * sizeof ( char ) ); dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; goodB2GSink ( dataMap ); void goodB2GSink(map<int, char *> dataMap) char * data = dataMap [ 2 ] ; free ( data );
114196/CWE762_Mismatched_Memory_Management_Routines__delete_char_malloc_74b.cpp
SARD
0
static void eepro100_write(void *opaque, hwaddr uint64_t data, unsigned size) EEPRO100State * s = opaque ; switch ( size ) eepro100_write1 ( s , addr , data ); static void eepro100_write1(EEPRO100State * s, uint32_t addr, uint8_t val) if ( addr > SCBStatus && addr <= sizeof ( s -> mem ) - sizeof ( val ) ) s -> mem [ addr ] = val; switch ( addr ) TRACE ( OTHER , logout ( "addr=%s val=0x%02x\n" , regname ( addr ) , val ) ); static char *regname(uint32_t addr) static char buf [ 32 ] ; if ( addr < PCI_IO_SIZE ) const char * r = e100_reg [ addr / 4 ] ; if ( r != 0 ) snprintf ( buf , sizeof ( buf ) , "0x%02x" , addr );
CVE-2016-9101/qemu_2.3.0_CVE-2016-9101_eepro100.c
NVD
0
void CWE126_Buffer_Overread__char_declare_memcpy_81_bad::action(char * data) const 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 );
76174/CWE126_Buffer_Overread__char_declare_memcpy_81_bad.cpp
SARD
3
static void goodG2B2() wchar_t * data ; data = NULL; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; data = ( wchar_t * ) malloc ( ( 10 + 1 ) * sizeof ( wchar_t ) ); wchar_t source [ 10 + 1 ] = SRC_STRING ; wcscpy ( data , source ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data );
70986/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_cpy_11.c
SARD
0
static void goodG2B2() wchar_t * data ; data = NULL; if ( STATIC_CONST_FIVE == 5 ) data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' size_t i ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' for (i = 0; i < 100; i++) data [ i ] = source [ i ]; data [ 100 - 1 ] = L '\0' free ( data );
71941/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_loop_06.c
SARD
0
static void goodG2B2() char * data ; char dataGoodBuffer [ 100 ] ; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; data = dataGoodBuffer; data [ 0 ] = '\0'; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memmove ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
64159/CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_memmove_08.c
SARD
0
void CWE195_Signed_to_Unsigned_Conversion_Error__rand_strncpy_04_bad() char source [ 100 ] ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
88545/CWE195_Signed_to_Unsigned_Conversion_Error__rand_strncpy_04.c
SARD
20
static void goodB2G() int * data ; data = NULL; goodB2GSource ( data ); static void goodB2GSource(int * &data) data = ( int * ) malloc ( 100 * sizeof ( int ) ); data [ 0 ] = 5; printIntLine ( data [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber );
99564/CWE401_Memory_Leak__int_malloc_43.cpp
SARD
0
static token lex() unsigned int c ; int backslash = 0 ; charclass ccl ; int i ; for (i = 0; i < 2; ++i) if ( __ctype_get_mb_cur_max ( ) > 1 ) if ( ! lexleft ) if ( ( ( void * ) 0 ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) wctok = ( c = ( to_uchar ( * ( lexptr ++ ) ) ) ); inline static unsigned char to_uchar(char ch) return ch ; 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 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) wc = c = ( to_uchar ( * ( lexptr ++ ) ) ); inline static unsigned char to_uchar(char ch) return ch ; 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 || syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) zeroset ( ccl ); static void zeroset(charclass s) memset ( s , 0 , sizeof ( charclass ) );
149301/dfa.c
SARD
0
static void goodG2B2() wchar_t * data ; if ( STATIC_CONST_TRUE ) data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); wcsncat ( data , source , 100 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data );
72083/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncat_04.c
SARD
0
static void goodG2B1() char * data ; char dataBuffer [ 100 ] ; data = dataBuffer; if ( GLOBAL_CONST_FALSE ) data [ 0 ] = '\0'; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcat ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
109760/CWE665_Improper_Initialization__char_cat_09.c
SARD
0
void CWE665_Improper_Initialization__wchar_t_ncat_16_bad() 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 )
109912/CWE665_Improper_Initialization__wchar_t_ncat_16.c
SARD
0
static void goodB2G1() twoIntsStruct * data ; data = NULL; if ( staticFive == 5 ) data = ( twoIntsStruct * ) realloc ( data , 100 * sizeof ( twoIntsStruct ) ); data [ 0 ] . intOne = 0; data [ 0 ] . intTwo = 0; printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); free ( data );
100672/CWE401_Memory_Leak__twoIntsStruct_realloc_07.c
SARD
0
static void goodG2B() char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memcpy ( dest , data , 100 * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
77867/CWE127_Buffer_Underread__malloc_char_memcpy_61a.c
SARD
0
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalTrue ) 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 ); SNPRINTF ( dest , 100 - 1 , "%s" , data );
80067/CWE134_Uncontrolled_Format_String__char_file_snprintf_10.c
SARD
0
static void good1() if ( globalFalse ) twoIntsStruct * data = ( twoIntsStruct * ) malloc ( 100 * sizeof ( twoIntsStruct ) ) ; data [ 0 ] . intOne = 0; data [ 0 ] . intTwo = 0; printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); tmpData = ( twoIntsStruct * ) realloc ( data , ( 130000 ) * sizeof ( twoIntsStruct ) ); if ( tmpData != NULL ) data = tmpData; data [ 0 ] . intOne = 1; data [ 0 ] . intTwo = 1; printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); free ( data );
99715/CWE401_Memory_Leak__malloc_realloc_twoIntsStruct_10.c
SARD
0
static void goodG2B() wchar_t * data ; wchar_t * dataGoodBuffer = ( wchar_t * ) ALLOCA ( 100 * sizeof ( wchar_t ) ) ; data = dataGoodBuffer; data [ 0 ] = L '\0' CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_alloca_memmove_63b_goodG2BSink ( & data ); void CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_alloca_memmove_63b_goodG2BSink(wchar_t * * dataPtr) wchar_t * data = * dataPtr ; 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 )
65141/CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_alloca_memmove_63b.c
SARD
0
static void goodB2G1() if ( 5 == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; count = atoi ( inputBuffer ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); if ( count > 0 && count <= 20 ) for (i = 0; i < (size_t)count; i++)
98963/CWE400_Resource_Exhaustion__listen_socket_fwrite_03.c
SARD
0
void stonesoup_handle_taint(char *noneconomically_carthaginian) int orly_arri = 7 ; int ripping_antiphylloxeric ; union intersexes_crimpling hexosaminic_duckblind [ 10 ] = { 0 } ; union intersexes_crimpling flammable_subsultive ; if ( noneconomically_carthaginian != 0 ) flammable_subsultive . somatist_outlength = noneconomically_carthaginian; ripping_antiphylloxeric = 5; hoccleve_pneumonography = & ripping_antiphylloxeric; hexosaminic_duckblind [ * hoccleve_pneumonography ] = flammable_subsultive; vegetating_confetti = hexosaminic_duckblind [ * hoccleve_pneumonography ]; silkness_incorporate ( orly_arri , vegetating_confetti ); void silkness_incorporate(int nontheistically_monogamian,union intersexes_crimpling collery_lawmen) nontheistically_monogamian --; if ( nontheistically_monogamian > 0 ) silkness_incorporate ( nontheistically_monogamian , collery_lawmen ); void silkness_incorporate(int nontheistically_monogamian,union intersexes_crimpling collery_lawmen) const int stonesoup_MAXLEN = 16 ; char stonesoup_dest [ stonesoup_MAXLEN ] ; nontheistically_monogamian --; if ( nontheistically_monogamian > 0 ) goldenknop_pyridinium = ( ( char * ) collery_lawmen . somatist_outlength ); memset ( stonesoup_dest , 'x' , stonesoup_MAXLEN ); stonesoup_dest [ stonesoup_MAXLEN - 1 ] = '\0'; stonesoup_size_var = stonesoup_returnChunkSize ( stonesoup_dest , goldenknop_pyridinium ); int stonesoup_returnChunkSize(void *dest,void *src) if ( strlen ( dest ) < strlen ( src ) )
151099/dynahash.c
SARD
0
void CWE194_Unexpected_Sign_Extension__listen_socket_memcpy_66b_badSink(short dataArray[]) char source [ 100 ] ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memcpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
86948/CWE194_Unexpected_Sign_Extension__listen_socket_memcpy_66b.c
SARD
20
void CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_vprintf_04_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( STATIC_CONST_TRUE ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket );
81885/CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_vprintf_04.c
SARD
0
void CWE194_Unexpected_Sign_Extension__connect_socket_strncpy_68b_badSink() char source [ 100 ] ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
86470/CWE194_Unexpected_Sign_Extension__connect_socket_strncpy_68b.c
SARD
20
static void build_state_zero(struct dfa *d) d -> tralloc = 1; d -> trcount = 0; d -> realtrans = ( ( sizeof ( ( * d -> realtrans ) ) == 1 ? xzalloc ( ( d -> tralloc + 1 ) ) : xcalloc ( ( d -> tralloc + 1 ) , sizeof ( ( * d -> realtrans ) ) ) ) ); while ( 0 ) d -> trans = d -> realtrans + 1; d -> fails = ( ( sizeof ( ( * d -> fails ) ) == 1 ? xzalloc ( ( d -> tralloc ) ) : xcalloc ( ( d -> tralloc ) , sizeof ( ( * d -> fails ) ) ) ) ); while ( 0 ) d -> success = ( ( sizeof ( ( * d -> success ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> success ) ) ) ) ); while ( 0 ) d -> newlines = ( ( sizeof ( ( * d -> newlines ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> newlines ) ) ) ) ); while ( 0 ) build_state ( 0 , d ); static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) leaf_set * grps ; charclass * labels ; size_t ngrps = 0 ; position pos ; charclass matches ; int matchesf ; charclass intersect ; int intersectf ; charclass leftovers ; int leftoversf ; size_t i ; size_t j ; size_t k ; grps = ( ( sizeof ( ( * grps ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * grps ) ) ) ) ); while ( 0 ) labels = ( ( sizeof ( ( * labels ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * labels ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . elems . nelem; ++i) pos = d -> states [ s ] . elems . elems [ i ]; if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) ) if ( d -> tokens [ pos . index ] >= CSET ) if ( pos . constraint != 0x777 ) if ( ! ( ( ( ( 4 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~newline [ j ]; if ( ! ( ( ( ( 2 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~letters [ j ]; if ( ! ( ( ( ( 1 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= letters [ j ] | newline [ j ]; if ( j == ( ( 1 << 8 ) + 8 * sizeof ( int ) - 1 ) / ( 8 * sizeof ( int ) ) ) for (j = 0; j < ngrps; ++j) if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) && ! tstbit ( d -> tokens [ pos . index ] , labels [ j ] ) ) intersectf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) ( intersect [ k ] = matches [ k ] & labels [ j ] [ k ] ) ? ( intersectf = 1 ) : 0; if ( ! intersectf ) leftoversf = matchesf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) int match = matches [ k ] ; int label = labels [ j ] [ k ] ; ( leftovers [ k ] = ~match & label ) ? ( leftoversf = 1 ) : 0; ( matches [ k ] = match & ~label ) ? ( matchesf = 1 ) : 0; if ( leftoversf ) grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = grps [ j ] . nelem; grps [ j ] . elems [ grps [ j ] . nelem ++ ] = pos . index; if ( ! matchesf ) if ( j == ngrps ) zeroset ( matches ); grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = 1; grps [ ngrps ] . elems [ 0 ] = pos . index; static void zeroset(charclass s) memset ( s , 0 , sizeof ( charclass ) );
153579/dfa.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_set_addr2 ( conversation , addr_b ); void conversation_set_addr2(conversation_t *conv,const address *addr) ( void ) ( ! ( conv -> options & 0x08 ) ? ( ( void ) 0 ) : ( ( getenv ( "WIRESHARK_ABORT_ON_DISSECTOR_BUG" ) != ( ( void * ) 0 ) ? abort ( ) : except_throw ( 1 , 4 , ( ep_strdup_printf ( "%s:%u: failed assertion \"%s\" (%s)" , "conversation.c" , 710 , "!(conv->options & 0x08)" , "Use the conversation_create_from_template function when the CONVERSATION_TEMPLATE bit is set in the options mask" ) ) ) ) ) );
150438/conversation.c
SARD
0
static void goodG2B() int * data ; int * dataArray [ 5 ] ; data = NULL; data = ( int * ) ALLOCA ( 10 * sizeof ( int ) ); dataArray [ 2 ] = data; CWE121_Stack_Based_Buffer_Overflow__CWE131_memmove_66b_goodG2BSink ( dataArray ); void CWE121_Stack_Based_Buffer_Overflow__CWE131_memmove_66b_goodG2BSink(int * dataArray[]) int * data = dataArray [ 2 ] ; int source [ 10 ] = { 0 } ; memmove ( data , source , 10 * sizeof ( int ) ); printIntLine ( data [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber );
62938/CWE121_Stack_Based_Buffer_Overflow__CWE131_memmove_66b.c
SARD
3
static void good2() if ( STATIC_CONST_TRUE ) char * * pointer = ( char * * ) malloc ( sizeof ( char * ) ) ; * pointer = data; char * data = * pointer ; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( pointer );
112013/CWE758_Undefined_Behavior__char_pointer_malloc_use_04.c
SARD
0
static void goodB2G1() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' 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 )
113060/CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_listen_socket_14.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) if ( s -> pb ) s -> flags |= 0x80; 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 ;
152043/utils.c
SARD
0
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 ]; 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 ( intersect , labels [ j ] ); grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = grps [ j ] . nelem; grps [ j ] . elems [ grps [ j ] . nelem ++ ] = pos . index; if ( ! matchesf ) if ( j == ngrps ) grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = 1; grps [ ngrps ] . elems [ 0 ] = pos . index; static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) );
151931/dfa.c
SARD
0
static void goodB2G() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) CWE122_Heap_Based_Buffer_Overflow__c_CWE129_listen_socket_68_goodB2GData = data;
70680/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_listen_socket_68a.c
SARD
0
void 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 );
76526/CWE126_Buffer_Overread__new_char_loop_05.cpp
SARD
3
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; badSource ( data ); void badSource(char * &data) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 )
90662/CWE23_Relative_Path_Traversal__char_listen_socket_ofstream_43.cpp
SARD
0
int av_read_frame(AVFormatContext *s,AVPacket *pkt) const int genpts = s -> flags & 0x1 ; int eof = 0 ; int ret ; if ( ! genpts ) AVPacketList * pktl = s -> packet_buffer ; if ( pktl ) AVPacket * next_pkt = & pktl -> pkt ; if ( next_pkt -> dts != ( ( int64_t ) 0x8000000000000000UL ) ) int wrap_bits = s -> streams [ next_pkt -> stream_index ] -> pts_wrap_bits ; int64_t last_dts = next_pkt -> dts ; while ( pktl && next_pkt -> pts == ( ( int64_t ) 0x8000000000000000UL ) ) if ( pktl -> pkt . stream_index == next_pkt -> stream_index && av_compare_mod ( ( next_pkt -> dts ) , pktl -> pkt . dts , ( 2 << wrap_bits - 1 ) ) < 0 ) if ( av_compare_mod ( pktl -> pkt . pts , pktl -> pkt . dts , ( 2 << wrap_bits - 1 ) ) ) next_pkt -> pts = pktl -> pkt . dts; if ( last_dts != ( ( int64_t ) 0x8000000000000000UL ) ) last_dts = pktl -> pkt . dts; pktl = pktl -> next; if ( eof && next_pkt -> pts == ( ( int64_t ) 0x8000000000000000UL ) && last_dts != ( ( int64_t ) 0x8000000000000000UL ) ) next_pkt -> pts = last_dts + ( next_pkt -> duration ); pktl = s -> packet_buffer; if ( ! ( next_pkt -> pts == ( ( int64_t ) 0x8000000000000000UL ) && next_pkt -> dts != ( ( int64_t ) 0x8000000000000000UL ) && ! eof ) ) ret = read_frame_internal ( s , pkt ); if ( ret < 0 ) if ( pktl && ret != - '\v' ) eof = 1; if ( av_dup_packet ( add_to_pktbuf ( & s -> packet_buffer , pkt , & s -> packet_buffer_end ) ) < 0 ) static int read_frame_internal(AVFormatContext *s,AVPacket *pkt) int got_packet = 0 ; while ( ! got_packet && ! s -> parse_queue ) AVStream * st ; AVPacket cur_pkt ; ret = ff_read_packet ( s , & cur_pkt ); if ( ret < 0 ) st = s -> streams [ cur_pkt . stream_index ]; if ( st -> need_parsing && ! st -> parser && ! ( s -> flags & 0x20 ) ) st -> parser = av_parser_init ( ( st -> codec -> codec_id ) ); if ( ! st -> parser ) st -> need_parsing = AVSTREAM_PARSE_NONE; if ( ( st -> need_parsing ) == AVSTREAM_PARSE_HEADERS ) st -> parser -> flags |= 0x1; if ( ( st -> need_parsing ) == AVSTREAM_PARSE_FULL_ONCE ) st -> parser -> flags |= 0x0002; if ( ( st -> need_parsing ) == AVSTREAM_PARSE_FULL_RAW ) st -> parser -> flags |= 0x1000; if ( ! st -> need_parsing || ! st -> parser ) * pkt = cur_pkt; got_packet = 1; if ( ( st -> discard ) < AVDISCARD_ALL ) if ( ( ret = parse_packet ( s , & cur_pkt , cur_pkt . stream_index ) ) < 0 ) if ( pkt -> flags & 0x1 ) st -> skip_to_keyframe = 0; if ( st -> skip_to_keyframe ) if ( got_packet ) * pkt = cur_pkt; got_packet = 0; int ff_read_packet(AVFormatContext *s,AVPacket *pkt) int ret ; AVStream * st ; AVPacketList * pktl = s -> raw_packet_buffer ; if ( pktl ) * pkt = pktl -> pkt; st = s -> streams [ pkt -> stream_index ]; if ( st -> request_probe <= 0 ) pkt -> data = ( ( void * ) 0 ); pkt -> size = 0; ret = ( ( s -> iformat -> read_packet ) ( s , pkt ) ); if ( ret < 0 ) if ( ! pktl || ret == - '\v' ) if ( s -> flags & 0x0100 && pkt -> flags & 0x0002 ) if ( ( pkt -> stream_index ) >= ( ( unsigned int ) ( s -> nb_streams ) ) ) st = s -> streams [ pkt -> stream_index ]; pkt -> dts = wrap_timestamp ( st , pkt -> dts ); pkt -> pts = wrap_timestamp ( st , pkt -> pts ); if ( ! pktl && st -> request_probe <= 0 ) s -> raw_packet_buffer_remaining_size -= pkt -> size; probe_codec ( s , st , pkt ); static void probe_codec(AVFormatContext *s,AVStream *st,const AVPacket *pkt) if ( st -> request_probe > 0 ) AVProbeData * pd = & st -> probe_data ; if ( pkt ) uint8_t * new_buf = ( av_realloc ( ( pd -> buf ) , ( pd -> buf_size + pkt -> size + 32 ) ) ) ; if ( ! new_buf ) pd -> buf = new_buf; memcpy ( ( pd -> buf + pd -> buf_size ) , ( pkt -> data ) , ( pkt -> size ) ); pd -> buf_size += pkt -> size; memset ( ( pd -> buf + pd -> buf_size ) , 0 , 32 ); if ( end || ff_log2_c ( ( pd -> buf_size ) ) != ff_log2_c ( ( pd -> buf_size - pkt -> size ) ) ) int score = set_codec_from_probe_data ( s , st , pd ) ; if ( ( st -> codec -> codec_id ) != AV_CODEC_ID_NONE && score > 100 / 4 || end ) pd -> buf_size = 0; av_freep ( ( & pd -> buf ) );
152817/utils.c
SARD
0
void CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_malloc_54b_badSink(int data) CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_malloc_54c_badSink ( data ); void CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_malloc_54c_badSink(int data) CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_malloc_54d_badSink ( data ); void CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_malloc_54d_badSink(int data) CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_malloc_54e_badSink ( data ); void CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_malloc_54e_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 );
88046/CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_malloc_54e.c
SARD
20
void CWE78_OS_Command_Injection__char_listen_socket_w32_spawnv_04_bad() char * data ; char dataBuffer [ 100 ] = "" ; 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 ) 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 )
120250/CWE78_OS_Command_Injection__char_listen_socket_w32_spawnv_04.c
SARD
0
int avformat_write_header(AVFormatContext *s,AVDictionary **options) int vulgarest_prokopyevsk = 7 ; char * volumen_sexhood ; if ( __sync_bool_compare_and_swap ( & gelilah_porret , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( volumen_sexhood != 0 ) tiedeman_vitalizer = & volumen_sexhood; laspisa_jefes = & tiedeman_vitalizer; globigerinas_brachycranic = & laspisa_jefes; laryngeating_furrowlike = & globigerinas_brachycranic; depravers_unequitableness = & laryngeating_furrowlike; pharmacopeial_elum = & depravers_unequitableness; hwelon_basirhinal = & pharmacopeial_elum; condimental_chopstick = & hwelon_basirhinal; horsefettler_enwiden = & condimental_chopstick; hangfires_slinkskin = & horsefettler_enwiden; camatina_unrecreating ( vulgarest_prokopyevsk , hangfires_slinkskin ); void camatina_unrecreating(int ceil_upsloping,char ***********uruguaiana_haemocyte) ceil_upsloping --; if ( ceil_upsloping > 0 ) camatina_unrecreating ( ceil_upsloping , uruguaiana_haemocyte ); void camatina_unrecreating(int ceil_upsloping,char ***********uruguaiana_haemocyte) ceil_upsloping --; if ( ceil_upsloping > 0 ) camatina_unrecreating ( ceil_upsloping , uruguaiana_haemocyte ); void camatina_unrecreating(int ceil_upsloping,char ***********uruguaiana_haemocyte) size_t stonesoup_taint_size ; ceil_upsloping --; if ( ceil_upsloping > 0 ) warmongers_divided = ( ( char * ) ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * uruguaiana_haemocyte ) ) ) ) ) ) ) ) ) ) ); stonesoup_taint_size = strlen ( warmongers_divided ); if ( stonesoup_taint_size >= 1600 ) stonesoup_taint_size = 1599U; stonesoup_malloced_buff = malloc ( stonesoup_taint_size * sizeof ( char * ) ); tracepoint ( stonesoup_trace , variable_address , "stonesoup_malloced_buff" , stonesoup_malloced_buff , "INTIAL-STATE" ); if ( stonesoup_malloced_buff != 0 ) stonesoup_malloced_buff [ stonesoup_ss_i ] = malloc ( stonesoup_taint_size * stonesoup_taint_size * sizeof ( char ) ); tracepoint ( stonesoup_trace , variable_signed_integral , "stonesoup_ss_i" , stonesoup_ss_i , & stonesoup_ss_i , "CROSSOVER-STATE" ); tracepoint ( stonesoup_trace , variable_address , "stonesoup_malloced_buff[stonesoup_ss_i]" , stonesoup_malloced_buff [ stonesoup_ss_i ] , "CROSSOVER-STATE" ); if ( stonesoup_malloced_buff [ stonesoup_ss_i ] == 0 && errno == 12 ) if ( stonesoup_malloced_buff [ stonesoup_ss_i ] != 0 ) memcpy ( stonesoup_malloced_buff [ stonesoup_ss_i ] + stonesoup_ss_j * stonesoup_taint_size , warmongers_divided , stonesoup_taint_size ); if ( stonesoup_malloced_buff [ stonesoup_ss_i ] != 0 ) free ( stonesoup_malloced_buff [ stonesoup_ss_i ] ); tracepoint ( stonesoup_trace , variable_address , "stonesoup_malloced_buff[stonesoup_ss_i]" , stonesoup_malloced_buff [ stonesoup_ss_i ] , "CROSSOVER-STATE: Free" ); free ( stonesoup_malloced_buff );
152157/mux.c
SARD
29
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) baseObject . action ( data );
79190/CWE134_Uncontrolled_Format_String__char_connect_socket_printf_81a.cpp
SARD
0