func
stringlengths
181
23.6k
path
stringlengths
12
123
source
stringclasses
2 values
label
int64
0
40
static void goodG2B() list < wchar_t * > dataList ; goodG2BSink ( dataList ); void goodG2BSink(list<wchar_t *> dataList) wchar_t * data = dataList . back ( ) ; 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 )
63468/CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_alloca_cpy_73b.cpp
SARD
0
void CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_memcpy_31_bad() wchar_t * data ; data = ( wchar_t * ) malloc ( 10 * sizeof ( wchar_t ) ); wchar_t * dataCopy = data ; wchar_t * data = dataCopy ; memcpy ( data , source , ( wcslen ( source ) + 1 ) * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data );
71092/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_memcpy_31.c
SARD
3
static void add_utf8_anychar() const unsigned int n = ( sizeof ( utf8_classes ) / sizeof ( utf8_classes [ 0 ] ) ) ; unsigned int i ; if ( dfa -> utf8_anychar_classes [ 0 ] == 0 ) for (i = 0; i < n; i++) charclass c ; dfa -> utf8_anychar_classes [ i ] = ( CSET + charclass_index ( c ) ); static size_t charclass_index(const int s[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) size_t i ; for (i = 0; i < dfa -> cindex; ++i) if ( equal ( s , dfa -> charclasses [ i ] ) ) if ( dfa -> calloc <= dfa -> cindex + 1 ) size_t new_n_alloc = dfa -> cindex + 1 + ( ! dfa -> charclasses ) ; dfa -> charclasses = ( x2nrealloc ( ( dfa -> charclasses ) , & new_n_alloc , sizeof ( ( * dfa -> charclasses ) ) ) ); dfa -> calloc = new_n_alloc; while ( 0 ) copyset ( s , dfa -> charclasses [ i ] ); static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) );
150157/dfa.c
SARD
0
static int handle_message(struct skinny_req *req, struct skinnysession *s) struct skinny_speeddial * sd ; struct skinny_device * d = s -> device ; if ( ( ! s -> device ) && ( letohl ( req -> e ) != REGISTER_MESSAGE && letohl ( req -> e ) != ALARM_MESSAGE ) ) switch ( letohl ( req -> e ) ) if ( sd = find_speeddial_by_instance ( s -> device , letohl ( req -> data . speeddialreq . speedDialNumber ) , 0 ) ) static struct skinny_speeddial *find_speeddial_by_instance(struct skinny_device *d, int instance, int isHint) struct skinny_speeddial * sd ; return sd ; transmit_speeddialstatres ( d , sd ); static void transmit_speeddialstatres(struct skinny_device *d, struct skinny_speeddial *sd) struct skinny_req * req ; if ( ! ( req = req_alloc ( sizeof ( struct speed_dial_stat_res_message ) , SPEED_DIAL_STAT_RES_MESSAGE ) ) ) static struct skinny_req *req_alloc(size_t size, int response_message) struct skinny_req * req ; if ( ! ( req = ast_calloc ( 1 , skinny_header_size + size + 4 ) ) ) return NULL ; req -> len = htolel ( size + 4 ); req -> e = htolel ( response_message ); return req ; req -> data . speeddialreq . speedDialNumber = htolel ( sd -> instance ); 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 ) );
148809/chan_skinny.c
SARD
2
static void goodB2G2() int data ; data = - 1; if ( 5 == 5 ) data = 10; if ( 5 == 5 ) int i ; int * buffer = ( int * ) malloc ( 10 * sizeof ( int ) ) ; for (i = 0; i < 10; i++) buffer [ i ] = 0; if ( data >= 0 && data < ( 10 ) ) buffer [ data ] = 1; free ( buffer );
70594/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_large_03.c
SARD
0
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_connect_socket_32_bad() char * data ; char * * dataPtr1 = & data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; char * data = * dataPtr1 ; 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 ) * dataPtr1 = data; for (; *data != '\0'; data++) if ( * data == SEARCH_CHAR ) free ( data );
112540/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_connect_socket_32.c
SARD
1
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfaanalyze ( d , searchflag ); void dfaanalyze(struct dfa *d,int searchflag) int * nullable ; size_t * nfirstpos ; position * firstpos ; size_t * nlastpos ; position * lastpos ; position_set merged ; position * o_firstpos ; position * o_lastpos ; size_t i ; size_t j ; position * pos ; d -> searchflag = searchflag; nullable = ( ( sizeof ( ( * nullable ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nullable ) ) ) ) ); while ( 0 ) nfirstpos = ( ( sizeof ( ( * nfirstpos ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nfirstpos ) ) ) ) ); while ( 0 ) firstpos = ( ( sizeof ( ( * firstpos ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * firstpos ) ) ) ) ); while ( 0 ) o_firstpos = firstpos , firstpos += d -> nleaves; nlastpos = ( ( sizeof ( ( * nlastpos ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nlastpos ) ) ) ) ); while ( 0 ) lastpos = ( ( sizeof ( ( * lastpos ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * lastpos ) ) ) ) ); while ( 0 ) o_lastpos = lastpos , lastpos += d -> nleaves; d -> follows = ( ( sizeof ( ( * d -> follows ) ) == 1 ? xzalloc ( d -> tindex ) : xcalloc ( d -> tindex , sizeof ( ( * d -> follows ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> tindex; ++i) switch ( d -> tokens [ i ] ) * ( nullable ++ ) = 1; * ( nfirstpos ++ ) = * ( nlastpos ++ ) = 0; pos = lastpos; for (j = 0; j < nlastpos[- 1]; ++j) copy ( ( & merged ) , & d -> follows [ pos [ j ] . index ] ); if ( d -> tokens [ i ] != PLUS ) nullable [ - 1 ] = 1; pos = lastpos + nlastpos [ - 1 ]; if ( nullable [ - 2 ] ) nfirstpos [ - 2 ] += nfirstpos [ - 1 ]; firstpos += nfirstpos [ - 1 ]; if ( nullable [ - 1 ] ) nlastpos [ - 2 ] += nlastpos [ - 1 ]; pos = lastpos + nlastpos [ - 2 ]; for (j = nlastpos[- 1]; j-- > 0; ) pos [ j ] = lastpos [ j ]; lastpos += nlastpos [ - 2 ]; nlastpos [ - 2 ] = nlastpos [ - 1 ]; nullable [ - 2 ] = nullable [ - 1 ] && nullable [ - 2 ]; nfirstpos [ - 2 ] += nfirstpos [ - 1 ]; nlastpos [ - 2 ] += nlastpos [ - 1 ]; nullable [ - 2 ] = nullable [ - 1 ] || nullable [ - 2 ]; * ( nullable ++ ) = d -> tokens [ i ] == BACKREF; * ( nfirstpos ++ ) = * ( nlastpos ++ ) = 1; firstpos -> index = lastpos -> index = i; firstpos -> constraint = lastpos -> constraint = 0x777;
153579/dfa.c
SARD
0
static void build_state_zero(struct dfa *d) d -> tralloc = 1; d -> trcount = 0; d -> realtrans = ( ( sizeof ( ( * d -> realtrans ) ) == 1 ? xzalloc ( ( d -> tralloc + 1 ) ) : xcalloc ( ( d -> tralloc + 1 ) , sizeof ( ( * d -> realtrans ) ) ) ) ); while ( 0 ) d -> trans = d -> realtrans + 1; d -> fails = ( ( sizeof ( ( * d -> fails ) ) == 1 ? xzalloc ( ( d -> tralloc ) ) : xcalloc ( ( d -> tralloc ) , sizeof ( ( * d -> fails ) ) ) ) ); while ( 0 ) d -> success = ( ( sizeof ( ( * d -> success ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> success ) ) ) ) ); while ( 0 ) d -> newlines = ( ( sizeof ( ( * d -> newlines ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> newlines ) ) ) ) ); while ( 0 ) build_state ( 0 , d ); static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) leaf_set * grps ; charclass * labels ; size_t ngrps = 0 ; position pos ; charclass matches ; int matchesf ; charclass intersect ; int intersectf ; charclass leftovers ; int leftoversf ; size_t i ; size_t j ; size_t k ; grps = ( ( sizeof ( ( * grps ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * grps ) ) ) ) ); while ( 0 ) labels = ( ( sizeof ( ( * labels ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * labels ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . elems . nelem; ++i) pos = d -> states [ s ] . elems . elems [ i ]; if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) ) if ( d -> tokens [ pos . index ] >= CSET ) if ( pos . constraint != 0x777 ) if ( ! ( ( ( ( 4 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~newline [ j ]; if ( ! ( ( ( ( 2 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~letters [ j ]; if ( ! ( ( ( ( 1 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= letters [ j ] | newline [ j ]; if ( j == ( ( 1 << 8 ) + 8 * sizeof ( int ) - 1 ) / ( 8 * sizeof ( int ) ) ) for (j = 0; j < ngrps; ++j) if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) && ! tstbit ( d -> tokens [ pos . index ] , labels [ j ] ) ) static int tstbit(unsigned int b,const int c[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) return c [ b / ( 8 * sizeof ( int ) ) ] & 1 << b % ( 8 * sizeof ( int ) ) ; intersectf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) ( intersect [ k ] = matches [ k ] & labels [ j ] [ k ] ) ? ( intersectf = 1 ) : 0; if ( ! intersectf ) leftoversf = matchesf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) int match = matches [ k ] ; int label = labels [ j ] [ k ] ; ( leftovers [ k ] = ~match & label ) ? ( leftoversf = 1 ) : 0; ( matches [ k ] = match & ~label ) ? ( matchesf = 1 ) : 0; if ( leftoversf ) grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = grps [ j ] . nelem; grps [ j ] . elems [ grps [ j ] . nelem ++ ] = pos . index; if ( ! matchesf ) if ( j == ngrps ) copyset ( matches , labels [ ngrps ] ); grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = 1; grps [ ngrps ] . elems [ 0 ] = pos . index; static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) );
149301/dfa.c
SARD
0
void CWE114_Process_Control__w32_char_listen_socket_32_bad() char * data ; char * * dataPtr1 = & data ; char * * dataPtr2 = & data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; char * data = * dataPtr1 ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; while ( 0 ) char * data = * dataPtr2 ; HMODULE hModule ; hModule = LoadLibraryA ( data ); if ( hModule != NULL ) FreeLibrary ( hModule );
62153/CWE114_Process_Control__w32_char_listen_socket_32.c
SARD
14
void CWE127_Buffer_Underread__char_alloca_loop_64b_badSink(void * dataVoidPtr) char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; dest [ i ] = data [ i ]; dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
77312/CWE127_Buffer_Underread__char_alloca_loop_64b.c
SARD
3
static void goodG2B() wchar_t * dataBuffer = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; if ( dataBuffer == NULL ) data = dataBuffer; CWE590_Free_Memory_Not_on_Heap__free_wchar_t_alloca_63b_goodG2BSink ( & data ); void CWE590_Free_Memory_Not_on_Heap__free_wchar_t_alloca_63b_goodG2BSink(wchar_t * * dataPtr) wchar_t * data = * dataPtr ; printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data );
108725/CWE590_Free_Memory_Not_on_Heap__free_wchar_t_alloca_63a.c
SARD
0
apr_array_header_t *svn_cstring_split(const char *input,const char *sep_chars,svn_boolean_t chop_whitespace,apr_pool_t *pool) apr_array_header_t * a = apr_array_make ( pool , 5 , ( sizeof ( input ) ) ) ; svn_cstring_split_append ( a , input , sep_chars , chop_whitespace , pool ); void svn_cstring_split_append(apr_array_header_t *array,const char *input,const char *sep_chars,svn_boolean_t chop_whitespace,apr_pool_t *pool) char * pats ; char * p ; pats = apr_pstrdup ( pool , input ); p = svn_cstring_tokenize ( sep_chars , & pats ); while ( p ) p = svn_cstring_tokenize ( sep_chars , & pats ); char *svn_cstring_tokenize(const char *sep,char **str) char * token ; const char * next ; char csep ; if ( sep == ( ( void * ) 0 ) || str == ( ( void * ) 0 ) || * str == ( ( void * ) 0 ) ) csep = * sep; if ( csep == '\0' || sep [ 1 ] != '\0' ) token = * str; if ( ! ( * token ) ) next = ( strchr ( token , csep ) ); if ( next == ( ( void * ) 0 ) ) * str = token + strlen ( token );
152932/string.c
SARD
0
static int stonesoup_ev_handler(struct mg_connection *conn, enum mg_event ev) char * ifmatch_header ; char * stonesoup_tainted_buff ; int buffer_size = 1000 ; if ( ev == MG_REQUEST ) ifmatch_header = ( char * ) mg_get_header ( conn , "if-match" ); if ( strcmp ( ifmatch_header , "weak_taint_source_value" ) == 0 ) while ( 1 ) stonesoup_tainted_buff = ( char * ) malloc ( buffer_size * sizeof ( char ) ); data_size = mg_get_var ( conn , "data" , stonesoup_tainted_buff , buffer_size * sizeof ( char ) ); if ( data_size < buffer_size ) buffer_size = buffer_size * 2; stonesoup_handle_taint ( stonesoup_tainted_buff ); void stonesoup_handle_taint(char *seldomcy_gweducks) int stereomonoscope_vinomethylic = 7 ; if ( seldomcy_gweducks != 0 ) antisudoral_unswept = ( ( void * ) seldomcy_gweducks ); balai_hotpot = vulpinite_diseconomy ( antisudoral_unswept ); void *vulpinite_diseconomy(void *cytissorus_brutalising) return cytissorus_brutalising ; monotrochal_unannoyingly ( stereomonoscope_vinomethylic , balai_hotpot ); void monotrochal_unannoyingly(int unpumpable_uspoke,void *beflatter_dunarea) int stonesoup_size = 0 ; unpumpable_uspoke --; if ( unpumpable_uspoke > 0 ) cosmosophy_membranously = ( ( char * ) ( ( char * ) beflatter_dunarea ) ); if ( stonesoup_size != strlen ( cosmosophy_membranously ) )
149794/utils.c
SARD
0
static int transcode() int ret ; int64_t timer_start ; ret = transcode_init ( ); static int transcode_init() int ret = 0 ; int i ; int j ; AVFormatContext * oc ; AVCodecContext * codec ; OutputStream * ost ; InputStream * ist ; char error [ 1024 ] ; for (i = 0; i < nb_input_files; i++) InputFile * ifile = input_files [ i ] ; if ( ifile -> rate_emu ) for (j = 0; j < ifile -> nb_streams; j++) input_streams [ j + ifile -> ist_index ] -> start = av_gettime ( ); for (i = 0; i < nb_output_files; i++) oc = output_files [ i ] -> ctx; if ( ! oc -> nb_streams && ! ( oc -> oformat -> flags & 0x1000 ) ) return - 22 ; for (i = 0; i < nb_filtergraphs; i++) if ( ( ret = avfilter_graph_config ( filtergraphs [ i ] -> graph , ( ( void * ) 0 ) ) ) < 0 ) return ret ; for (i = 0; i < nb_output_streams; i++) AVCodecContext * icodec = ( ( void * ) 0 ) ; ost = output_streams [ i ]; oc = output_files [ ost -> file_index ] -> ctx; ist = get_input_stream ( ost ); static InputStream *get_input_stream(OutputStream *ost) if ( ost -> source_index >= 0 ) return input_streams [ ost -> source_index ] ; return ( ( void * ) 0 ) ; if ( ost -> attachment_filename ) codec = ost -> st -> codec; if ( ist ) icodec = ist -> st -> codec; ost -> st -> disposition = ist -> st -> disposition; codec -> bits_per_raw_sample = icodec -> bits_per_raw_sample; codec -> chroma_sample_location = icodec -> chroma_sample_location; if ( ost -> stream_copy ) uint64_t extra_size ; extra_size = ( ( uint64_t ) ( icodec -> extradata_size ) ) + 16; if ( extra_size > 2147483647 ) return - 22 ; codec -> codec_id = icodec -> codec_id; codec -> codec_type = icodec -> codec_type; if ( ! codec -> codec_tag ) unsigned int codec_tag ; if ( ! oc -> oformat -> codec_tag || ( av_codec_get_id ( oc -> oformat -> codec_tag , icodec -> codec_tag ) ) == ( codec -> codec_id ) || ! av_codec_get_tag2 ( oc -> oformat -> codec_tag , icodec -> codec_id , & codec_tag ) ) codec -> codec_tag = icodec -> codec_tag; codec -> bit_rate = icodec -> bit_rate; codec -> rc_max_rate = icodec -> rc_max_rate; codec -> rc_buffer_size = icodec -> rc_buffer_size; codec -> field_order = icodec -> field_order; codec -> extradata = ( av_mallocz ( extra_size ) ); if ( ! codec -> extradata ) return - 12 ; memcpy ( ( codec -> extradata ) , ( icodec -> extradata ) , ( icodec -> extradata_size ) ); codec -> extradata_size = icodec -> extradata_size; codec -> bits_per_coded_sample = icodec -> bits_per_coded_sample; codec -> time_base = ist -> st -> time_base; if ( ! strcmp ( oc -> oformat -> name , "avi" ) ) if ( copy_tb < 0 && av_q2d ( ist -> st -> r_frame_rate ) >= av_q2d ( ist -> st -> avg_frame_rate ) && 0.5 / av_q2d ( ist -> st -> r_frame_rate ) > av_q2d ( ist -> st -> time_base ) && 0.5 / av_q2d ( ist -> st -> r_frame_rate ) > av_q2d ( icodec -> time_base ) && av_q2d ( ist -> st -> time_base ) < 1.0 / 500 && av_q2d ( icodec -> time_base ) < 1.0 / 500 || copy_tb == 2 ) codec -> time_base . num = ist -> st -> r_frame_rate . den; codec -> time_base . den = 2 * ist -> st -> r_frame_rate . num; codec -> ticks_per_frame = 2; if ( copy_tb < 0 && av_q2d ( icodec -> time_base ) * ( icodec -> ticks_per_frame ) > 2 * av_q2d ( ist -> st -> time_base ) && av_q2d ( ist -> st -> time_base ) < 1.0 / 500 || copy_tb == 0 ) codec -> time_base = icodec -> time_base; codec -> time_base . num *= icodec -> ticks_per_frame; codec -> time_base . den *= 2; codec -> ticks_per_frame = 2; if ( ! ( oc -> oformat -> flags & 0002000 ) && strcmp ( oc -> oformat -> name , "mov" ) && strcmp ( oc -> oformat -> name , "mp4" ) && strcmp ( oc -> oformat -> name , "3gp" ) && strcmp ( oc -> oformat -> name , "3g2" ) && strcmp ( oc -> oformat -> name , "psp" ) && strcmp ( oc -> oformat -> name , "ipod" ) && strcmp ( oc -> oformat -> name , "f4v" ) ) if ( copy_tb < 0 && icodec -> time_base . den && av_q2d ( icodec -> time_base ) * ( icodec -> ticks_per_frame ) > av_q2d ( ist -> st -> time_base ) && av_q2d ( ist -> st -> time_base ) < 1.0 / 500 || copy_tb == 0 ) codec -> time_base = icodec -> time_base; codec -> time_base . num *= icodec -> ticks_per_frame; codec -> time_base = icodec -> time_base; if ( ost -> frame_rate . num ) codec -> time_base = av_inv_q ( ost -> frame_rate ); switch ( codec -> codec_type ) codec -> channel_layout = icodec -> channel_layout; codec -> sample_rate = icodec -> sample_rate; codec -> channels = icodec -> channels; codec -> frame_size = icodec -> frame_size; codec -> audio_service_type = icodec -> audio_service_type; codec -> block_align = icodec -> block_align; if ( ( codec -> block_align == 1 || codec -> block_align == 1152 || codec -> block_align == 576 ) && ( codec -> codec_id ) == AV_CODEC_ID_MP3 ) codec -> block_align = 0; if ( ( codec -> codec_id ) == AV_CODEC_ID_AC3 ) codec -> block_align = 0; codec -> pix_fmt = icodec -> pix_fmt; codec -> width = icodec -> width; codec -> height = icodec -> height; codec -> has_b_frames = icodec -> has_b_frames; if ( ! codec -> sample_aspect_ratio . num ) codec -> sample_aspect_ratio = ost -> st -> sample_aspect_ratio = ( ist -> st -> sample_aspect_ratio . num ? ist -> st -> sample_aspect_ratio : ( ( ist -> st -> codec -> sample_aspect_ratio . num ? ist -> st -> codec -> sample_aspect_ratio : ( ( AVRational ) ( 0 ) , ( 1 ) ) ) ) ) ost -> st -> avg_frame_rate = ist -> st -> avg_frame_rate; codec -> width = icodec -> width; codec -> height = icodec -> height; if ( ! ost -> enc ) ost -> enc = avcodec_find_encoder ( codec -> codec_id ); if ( ! ost -> enc ) ret = - 22; if ( ist ) ist -> decoding_needed ++; ost -> encoding_needed = 1; if ( ( codec -> codec_type ) == AVMEDIA_TYPE_VIDEO ) if ( ost -> filter && ! ost -> frame_rate . num ) ost -> frame_rate = av_buffersink_get_frame_rate ( ost -> filter -> filter ); if ( ist && ! ost -> frame_rate . num ) ost -> frame_rate = ist -> framerate; if ( ist && ! ost -> frame_rate . num ) ost -> frame_rate = ( ist -> st -> r_frame_rate . num ? ist -> st -> r_frame_rate : ( ( AVRational ) ( 25 ) , ( 1 ) ) ) if ( ost -> enc && ost -> enc -> supported_framerates && ! ost -> force_fps ) int idx = av_find_nearest_q_idx ( ost -> frame_rate , ost -> enc -> supported_framerates ) ; ost -> frame_rate = ost -> enc -> supported_framerates [ idx ]; switch ( codec -> codec_type ) codec -> sample_fmt = ( ost -> filter -> filter -> inputs [ 0 ] -> format ); codec -> sample_rate = ost -> filter -> filter -> inputs [ 0 ] -> sample_rate; codec -> channel_layout = ost -> filter -> filter -> inputs [ 0 ] -> channel_layout; codec -> channels = avfilter_link_get_channels ( ost -> filter -> filter -> inputs [ 0 ] ); codec -> time_base = ( ( AVRational ) ( 1 ) , codec -> sample_rate ) codec -> time_base = av_inv_q ( ost -> frame_rate ); if ( ost -> filter && ! ( codec -> time_base . num && codec -> time_base . den ) ) codec -> time_base = ost -> filter -> filter -> inputs [ 0 ] -> time_base; codec -> width = ost -> filter -> filter -> inputs [ 0 ] -> w; codec -> height = ost -> filter -> filter -> inputs [ 0 ] -> h; codec -> sample_aspect_ratio = ost -> st -> sample_aspect_ratio = ( ost -> frame_aspect_ratio ? av_d2q ( ( ost -> frame_aspect_ratio * ( codec -> height ) / ( codec -> width ) ) , 255 ) : ost -> filter -> filter -> inputs [ 0 ] -> sample_aspect_ratio ); codec -> pix_fmt = ( ost -> filter -> filter -> inputs [ 0 ] -> format ); if ( ! icodec || codec -> width != icodec -> width || codec -> height != icodec -> height || ( codec -> pix_fmt ) != ( icodec -> pix_fmt ) ) codec -> bits_per_raw_sample = frame_bits_per_raw_sample; if ( ost -> forced_keyframes ) if ( ! strncmp ( ( ost -> forced_keyframes ) , "expr:" , 5 ) ) ret = av_expr_parse ( & ost -> forced_keyframes_pexpr , ( ost -> forced_keyframes + 5 ) , forced_keyframes_const_names , ( ( void * ) 0 ) , ( ( void * ) 0 ) , ( ( void * ) 0 ) , ( ( void * ) 0 ) , 0 , ( ( void * ) 0 ) ); if ( ret < 0 ) return ret ; ost -> forced_keyframes_expr_const_values [ FKF_N ] = 0; ost -> forced_keyframes_expr_const_values [ FKF_N_FORCED ] = 0; ost -> forced_keyframes_expr_const_values [ FKF_PREV_FORCED_N ] = ( __builtin_nanf ( "" ) ); ost -> forced_keyframes_expr_const_values [ FKF_PREV_FORCED_T ] = ( __builtin_nanf ( "" ) ); codec -> time_base = ( ( AVRational ) ( 1 ) , ( 1000 ) ) if ( ! codec -> width ) codec -> width = input_streams [ ost -> source_index ] -> st -> codec -> width; codec -> height = input_streams [ ost -> source_index ] -> st -> codec -> height; if ( codec -> flags & ( 0x0200 | 0002000 ) ) char logfilename [ 1024 ] ; FILE * f ; snprintf ( logfilename , sizeof ( logfilename ) , "%s-%d.log" , ( ost -> logfile_prefix ? ost -> logfile_prefix : "ffmpeg2pass" ) , i ); if ( ! strcmp ( ost -> enc -> name , "libx264" ) ) if ( codec -> flags & 0002000 ) char * logbuffer ; codec -> stats_in = logbuffer; if ( codec -> flags & 0x0200 ) f = fopen ( logfilename , "wb" ); ost -> logfile = f; for (i = 0; i < nb_output_streams; i++) ost = output_streams [ i ]; if ( ost -> encoding_needed ) AVCodec * codec = ost -> enc ; AVCodecContext * dec = ( ( void * ) 0 ) ; if ( ist = get_input_stream ( ost ) ) static InputStream *get_input_stream(OutputStream *ost) if ( ost -> source_index >= 0 ) return input_streams [ ost -> source_index ] ; return ( ( void * ) 0 ) ; dec = ist -> st -> codec; if ( dec && dec -> subtitle_header ) ost -> st -> codec -> subtitle_header = ( av_mallocz ( ( dec -> subtitle_header_size + 1 ) ) ); if ( ! ost -> st -> codec -> subtitle_header ) ret = - 12; memcpy ( ( ost -> st -> codec -> subtitle_header ) , ( dec -> subtitle_header ) , ( dec -> subtitle_header_size ) ); ost -> st -> codec -> subtitle_header_size = dec -> subtitle_header_size; if ( ( ret = avcodec_open2 ( ost -> st -> codec , codec , & ost -> opts ) ) < 0 ) for (i = 0; i < nb_input_streams; i++) if ( ( ret = init_input_stream ( i , error , ( sizeof ( error ) ) ) ) < 0 ) static int init_input_stream(int ist_index,char *error,int error_len) int ret ; InputStream * ist = input_streams [ ist_index ] ; if ( ist -> decoding_needed ) AVCodec * codec = ist -> dec ; if ( ! codec ) return - 22 ; ist -> dr1 = codec -> capabilities & 0000002 && ! ( '6' < 56 && do_deinterlace ); if ( ( codec -> type ) == AVMEDIA_TYPE_VIDEO && ist -> dr1 ) ist -> st -> codec -> get_buffer = codec_get_buffer; ist -> st -> codec -> release_buffer = codec_release_buffer; ist -> st -> codec -> opaque = ( & ist -> buffer_pool ); if ( ( ret = avcodec_open2 ( ist -> st -> codec , codec , & ist -> opts ) ) < 0 ) return ret ; return 0 ; for (i = 0; i < nb_input_files; i++) for (i = 0; i < nb_output_files; i++) oc = output_files [ i ] -> ctx; oc -> interrupt_callback = int_cb; if ( ( ret = avformat_write_header ( oc , & output_files [ i ] -> opts ) ) < 0 ) ret = - 22; if ( ret ) return ret ; return 0 ; if ( ret < 0 ) timer_start = av_gettime ( ); if ( ( ret = init_input_threads ( ) ) < 0 ) static int init_input_threads() int i ; int ret ; if ( nb_input_files == 1 ) return 0 ; for (i = 0; i < nb_input_files; i++) InputFile * f = input_files [ i ] ; if ( ! ( f -> fifo = av_fifo_alloc ( ( 8 * sizeof ( AVPacket ) ) ) ) ) return - 12 ; if ( ret = pthread_create ( & f -> thread , ( ( void * ) 0 ) , input_thread , f ) ) return - ret ; return 0 ; print_report ( 1 , timer_start , av_gettime ( ) ); static void print_report(int is_last_report,int64_t timer_start,int64_t cur_time) char buf [ 1024 ] ; OutputStream * ost ; AVFormatContext * oc ; int64_t total_size ; int i ; double bitrate ; int64_t pts = - 9223372036854775807L - 1 ; static int64_t last_time = ( - 1 ) ; int hours ; int mins ; int secs ; int us ; if ( ! print_stats && ! is_last_report && ! progress_avio ) if ( ! is_last_report ) if ( last_time == ( - 1 ) ) if ( cur_time - last_time < 500000 ) oc = output_files [ 0 ] -> ctx; total_size = avio_size ( oc -> pb ); if ( total_size <= 0 ) total_size = avio_tell ( oc -> pb ); for (i = 0; i < nb_output_streams; i++) ost = output_streams [ i ]; if ( ( is_last_report || ! ost -> finished ) && ost -> st -> pts . val != ( ( int64_t ) 0x8000000000000000UL ) ) pts = ( pts > av_rescale_q ( ost -> st -> pts . val , ost -> st -> time_base , ( ( AVRational ) ( 1 ) , ( 1000000 ) ) ) ? pts : av_rescale_q ( ost -> st -> pts . val , ost -> st -> time_base , ( ( AVRational ) ( 1 ) , ( 1000000 ) ) ) ) secs = ( pts / 1000000 ); us = ( pts % 1000000 ); mins = secs / 60; secs %= 60; hours = mins / 60; mins %= 60; bitrate = ( pts && total_size >= 0 ? ( total_size * 8 ) / ( pts / 1000.0 ) : ( - 1 ) ); if ( total_size < 0 ) snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , "size=%8.0fkB time=" , total_size / 1024.0 ); snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , "%02d:%02d:%02d.%02d " , hours , mins , secs , 100 * us / 1000000 ); if ( bitrate < 0 ) snprintf ( buf + strlen ( buf ) , sizeof ( buf ) - strlen ( buf ) , "bitrate=N/A" );
151062/ffmpeg.c
SARD
0
static void good2() if ( STATIC_CONST_TRUE ) wchar_t * password = ( wchar_t * ) malloc ( 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' password = realloc ( password , 200 * sizeof ( wchar_t ) ); wcscpy ( password , L "Nothing to see here" ) printWLine ( password ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( password );
92055/CWE244_Heap_Inspection__w32_wchar_t_realloc_04.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 = atoi ( inputBuffer ); while ( 0 ) dataArray [ 2 ] = data; CWE190_Integer_Overflow__int_connect_socket_multiply_66b_goodB2GSink ( dataArray ); void CWE190_Integer_Overflow__int_connect_socket_multiply_66b_goodB2GSink(int dataArray[]) int data = dataArray [ 2 ] ; if ( data > 0 ) if ( data < ( INT_MAX / 2 ) ) int result = data * 2 ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber );
83060/CWE190_Integer_Overflow__int_connect_socket_multiply_66a.c
SARD
0
static void goodG2B() char * data ; data = NULL; data = new char [ 100 ]; memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; goodG2BSink ( data ); void goodG2BSink(char * data) memmove ( dest , data , strlen ( dest ) * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] data
76647/CWE126_Buffer_Overread__new_char_memmove_51a.cpp
SARD
0
void bad() if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; char * dataBuffer = new char [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; data [ i ] = source [ i ]; data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
74777/CWE124_Buffer_Underwrite__new_char_loop_12.cpp
SARD
3
void goodG2BSink() size_t data = goodG2BData ; char * myString ; if ( data > strlen ( HELLO_STRING ) ) myString = new char [ data ]; strcpy ( myString , HELLO_STRING ); printLine ( myString ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] myString
117503/CWE789_Uncontrolled_Mem_Alloc__new_char_connect_socket_68b.cpp
SARD
0
void CWE124_Buffer_Underwrite__wchar_t_declare_cpy_01_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer - 8; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcscpy ( data , source ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line )
75398/CWE124_Buffer_Underwrite__wchar_t_declare_cpy_01.c
SARD
3
static void goodG2B() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; wcscpy ( data , L "C:\\Windows\\System32\\winsrv.dll" ) CWE114_Process_Control__w32_wchar_t_connect_socket_52b_goodG2BSink ( data ); void CWE114_Process_Control__w32_wchar_t_connect_socket_52b_goodG2BSink(wchar_t * data) CWE114_Process_Control__w32_wchar_t_connect_socket_52c_goodG2BSink ( data ); void CWE114_Process_Control__w32_wchar_t_connect_socket_52c_goodG2BSink(wchar_t * data) HMODULE hModule ; hModule = LoadLibraryW ( data ); if ( hModule != NULL ) FreeLibrary ( hModule );
62258/CWE114_Process_Control__w32_wchar_t_connect_socket_52c.c
SARD
0
void CWE666_Operation_on_Resource_in_Wrong_Phase_of_Lifetime__listen_accept_bind_05_bad() if ( staticTrue ) 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 );
110003/CWE666_Operation_on_Resource_in_Wrong_Phase_of_Lifetime__listen_accept_bind_05.c
SARD
0
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfaoptimize ( d ); static void dfaoptimize(struct dfa *d) size_t i ; if ( ! 1 || ! using_utf8 ( ) ) inline static int using_utf8() static int utf8 = - 1 ; if ( utf8 == - 1 ) utf8 = strcmp ( ( nl_langinfo ( CODESET ) ) , "UTF-8" ) == 0; return utf8 ; for (i = 0; i < d -> tindex; ++i) switch ( d -> tokens [ i ] ) free_mbdata ( d ); static void free_mbdata(struct dfa *d) size_t i ; d -> multibyte_prop = ( ( void * ) 0 ); for (i = 0; i < d -> nmbcsets; ++i) size_t j ; struct mb_char_classes * p = & d -> mbcsets [ i ] ; for (j = 0; j < p -> ncoll_elems; ++j) free ( p -> coll_elems [ j ] );
153579/dfa.c
SARD
0
static void goodG2B() int data ; data = - 1; data = 20; int * intPointer ; intPointer = ( int * ) malloc ( data * sizeof ( int ) ); intPointer [ i ] = 0; printIntLine ( intPointer [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( intPointer );
110521/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_listen_socket_18.c
SARD
0
static void goodB2G2() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; size_t dataLen = wcslen ( data ) ; recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 )
109369/CWE606_Unchecked_Loop_Condition__wchar_t_listen_socket_08.c
SARD
0
static void goodG2B() char * data ; char dataBuffer [ 100 ] ; data = dataBuffer; memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_ncat_54b_goodG2BSink ( data ); void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_ncat_54b_goodG2BSink(char * data) CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_ncat_54c_goodG2BSink ( data ); void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_ncat_54c_goodG2BSink(char * data) CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_ncat_54d_goodG2BSink ( data ); void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_ncat_54d_goodG2BSink(char * data) CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_ncat_54e_goodG2BSink ( data ); void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_ncat_54e_goodG2BSink(char * data) strncat ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
65976/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_ncat_54a.c
SARD
0
static void badSink() void * data = CWE121_Stack_Based_Buffer_Overflow__CWE135_45_badData ; size_t dataLen = strlen ( ( char * ) data ) ; void * dest = ( void * ) calloc ( dataLen + 1 , 1 ) ; memcpy ( dest , data , ( dataLen + 1 ) ); printLine ( ( char * ) dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( dest );
62976/CWE121_Stack_Based_Buffer_Overflow__CWE135_45.c
SARD
3
void CWE124_Buffer_Underwrite__char_alloca_memcpy_53_bad() char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer - 8; CWE124_Buffer_Underwrite__char_alloca_memcpy_53b_badSink ( data ); void CWE124_Buffer_Underwrite__char_alloca_memcpy_53b_badSink(char * data) CWE124_Buffer_Underwrite__char_alloca_memcpy_53c_badSink ( data ); void CWE124_Buffer_Underwrite__char_alloca_memcpy_53c_badSink(char * data) CWE124_Buffer_Underwrite__char_alloca_memcpy_53d_badSink ( data ); void CWE124_Buffer_Underwrite__char_alloca_memcpy_53d_badSink(char * data) memcpy ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
73849/CWE124_Buffer_Underwrite__char_alloca_memcpy_53a.c
SARD
0
static void goodG2B1() int data ; data = - 1; if ( 0 ) data = 20; size_t i ; int * intPointer ; intPointer = ( int * ) malloc ( data * sizeof ( int ) ); for (i = 0; i < (size_t)data; i++) intPointer [ i ] = 0; free ( intPointer );
110409/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fixed_02.c
SARD
0
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_22_bad() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_22_badSink ( data ); void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_22_badSink(char * data) for (; *data != '\0'; data++) if ( * data == SEARCH_CHAR ) free ( data );
112682/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_22a.c
SARD
0
static void goodG2B2() short data ; data = 0; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; data = 100 - 1; 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 );
87016/CWE194_Unexpected_Sign_Extension__listen_socket_strncpy_11.c
SARD
0
static void goodG2B1() if ( staticReturnsFalse ( ) ) static int staticReturnsFalse() return 0 ; wchar_t * dataBuffer = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; data = dataBuffer; wcsncpy ( data , source , 100 - 1 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line )
74677/CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_08.c
SARD
0
static token lex() unsigned int c ; int backslash = 0 ; charclass ccl ; int i ; for (i = 0; i < 2; ++i) if ( __ctype_get_mb_cur_max ( ) > 1 ) if ( ! lexleft ) if ( ( ( void * ) 0 ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) wctok = ( c = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wctok = _wc; c = ( wctob ( wctok ) ); while ( 0 ) if ( ( ( int ) c ) == - 1 ) wint_t wc ; if ( ! lexleft ) if ( ( ( void * ) 0 ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) wc = c = ( to_uchar ( * ( lexptr ++ ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc = _wc; c = ( wctob ( wc ) ); while ( 0 ) while ( 0 ) switch ( c ) if ( backslash ) backslash = 1; if ( backslash ) if ( __ctype_get_mb_cur_max ( ) > 1 ) return lasttok = ( CSET + charclass_index ( ccl ) ) ; static size_t charclass_index(const int s[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) size_t i ; for (i = 0; i < dfa -> cindex; ++i) if ( equal ( s , dfa -> charclasses [ i ] ) ) 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 ;
153750/dfa.c
SARD
0
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( 5 == 5 ) 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'; goodB2G2VaSinkG ( data , data ); static void goodB2G2VaSinkG(char * data, ...) va_start ( args , data );
80204/CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_03.c
SARD
0
AVDictionary **setup_find_stream_info_opts(AVFormatContext *s,AVDictionary *codec_opts) union palaeolithy_canaled spretty_lusterlessness ; char * insnarement_inflammatory ; if ( __sync_bool_compare_and_swap ( & altometer_paleoethnology , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) insnarement_inflammatory = getenv ( "DISSOLUTELY_UNCHASTELY" ); if ( insnarement_inflammatory != 0 ) spretty_lusterlessness . aphanozygous_biometry = insnarement_inflammatory; kismats_qadi = ( ( char * ) spretty_lusterlessness . aphanozygous_biometry ); stonesoup_global_str = malloc ( sizeof ( char ) * strlen ( kismats_qadi ) + 1 ); strcpy ( stonesoup_global_str , kismats_qadi );
150222/cmdutils.c
SARD
0
static void goodG2B1() int data ; data = - 1; if ( STATIC_CONST_FIVE != 5 ) data = 20; size_t i ; int * intPointer ; intPointer = ( int * ) malloc ( data * sizeof ( int ) ); for (i = 0; i < (size_t)data; i++) intPointer [ i ] = 0; free ( intPointer );
110317/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_06.c
SARD
0
conversation_t *find_or_create_conversation(packet_info *pinfo) if ( ( conv = find_conversation ( pinfo -> fd -> num , ( & pinfo -> src ) , ( & pinfo -> dst ) , pinfo -> ptype , pinfo -> srcport , pinfo -> destport , 0 ) ) == ( ( void * ) 0 ) ) conversation_t *find_conversation(const guint32 frame_num,const address *addr_a,const address *addr_b,const port_type ptype,const guint32 port_a,const guint32 port_b,const guint options) conversation_t * conversation ; if ( ! ( options & ( 0x01 | 0x02 ) ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( conversation -> options & 0x01 ) && ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , addr_b , 0 ); static conversation_t *conversation_create_from_template(conversation_t *conversation,const address *addr2,const guint32 port2) if ( conversation -> options & 0x08 && ( conversation -> key_ptr -> ptype ) != PT_UDP ) conversation_t * new_conversation_from_template ; guint options = conversation -> options & ( ~ ( 0x08 | 0x01 | 0x02 ) ) ; if ( conversation -> options & 0x01 && conversation -> options & 0x02 ) if ( conversation -> options & 0x02 ) if ( conversation -> options & 0x01 ) new_conversation_from_template = conversation_new ( conversation -> setup_frame , ( & conversation -> key_ptr -> addr1 ) , addr2 , conversation -> key_ptr -> ptype , conversation -> key_ptr -> port1 , conversation -> key_ptr -> port2 , options ); conversation_t *conversation_new(const guint32 setup_frame,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2,const guint options) guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr1 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr1 -> data , ( addr1 -> len ) ); guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr2 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr2 -> data , ( addr2 -> len ) ); ( & new_key -> addr2 ) -> data = SE_COPY_ADDRESS_data; new_key -> ptype = ptype; new_key -> port1 = port1; new_key -> port2 = port2; conversation -> key_ptr = new_key; conversation_insert_into_hashtable ( hashtable , conversation ); return conversation ;
150083/conversation.c
SARD
0
static void goodB2G() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; while ( 0 ) CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_listen_socket_82_base * baseObject = new CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_listen_socket_82_goodB2G baseObject -> action ( data ); void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_listen_socket_82_goodB2G::action(char * data) size_t i ; for (i=0; i < strlen(data); i++) if ( data [ i ] == SEARCH_CHAR )
112804/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_listen_socket_82_goodB2G.cpp
SARD
0
static void goodB2G1() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) data [ dataLen ] = '\0'; if ( STATIC_CONST_FIVE != 5 ) free ( data );
112572/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_console_06.c
SARD
0
const char *svn_config_find_group(svn_config_t *cfg,const char *key,const char *master_section,apr_pool_t *pool) struct search_groups_baton gb ; gb . key = key; gb . match = ( ( void * ) 0 ); gb . pool = pool; ( void ) ( svn_config_enumerate2 ( cfg , master_section , search_groups , ( & gb ) , pool ) ); int svn_config_enumerate2(svn_config_t *cfg,const char *section,svn_config_enumerator2_t callback,void *baton,apr_pool_t *pool) cfg_section_t * sec ; apr_hash_index_t * opt_ndx ; apr_pool_t * iteration_pool ; if ( sec == ( ( void * ) 0 ) ) iteration_pool = svn_pool_create_ex ( pool , ( ( void * ) 0 ) ); for (opt_ndx = apr_hash_first(pool,sec -> options); opt_ndx != ((void *)0); opt_ndx = apr_hash_next(opt_ndx)) void * opt_ptr ; cfg_option_t * opt ; const char * temp_value ; opt = opt_ptr; make_string_from_option ( & temp_value , cfg , sec , opt , ( ( void * ) 0 ) ); if ( ! callback ( opt -> name , temp_value , baton , iteration_pool ) ) 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;
150890/config.c
SARD
0
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 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 ) myStruct . structFirst = data; badSink ( myStruct ); void badSink(structType myStruct) char * data = myStruct . structFirst ; inputFile . open ( ( char * ) data );
96585/CWE36_Absolute_Path_Traversal__char_listen_socket_ifstream_67a.cpp
SARD
0
void CWE617_Reachable_Assertion__fgets_66_bad() int data ; int dataArray [ 5 ] ; data = - 1; char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); dataArray [ 2 ] = data; CWE617_Reachable_Assertion__fgets_66b_badSink ( dataArray ); void CWE617_Reachable_Assertion__fgets_66b_badSink(int dataArray[]) int data = dataArray [ 2 ] ; assert ( data > ASSERT_VALUE );
109514/CWE617_Reachable_Assertion__fgets_66b.c
SARD
5
static void goodG2B1() char * data ; char dataBuffer [ 100 ] ; data = dataBuffer; if ( GLOBAL_CONST_FALSE ) memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; char dest [ 50 ] = "" ; memmove ( dest , data , strlen ( data ) * sizeof ( char ) ); dest [ 50 - 1 ] = '\0';
65904/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_memmove_09.c
SARD
0
static void goodG2B() char * data ; char * * dataPtr1 = & data ; char * * dataPtr2 = & data ; char dataBuffer [ 100 ] ; data = dataBuffer; char * data = * dataPtr1 ; data [ 0 ] = '\0'; char * data = * dataPtr2 ; size_t sourceLen ; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; sourceLen = strlen ( source ); strncat ( data , source , sourceLen ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
109821/CWE665_Improper_Initialization__char_ncat_32.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 ) goodB2GSink_b ( data ); void goodB2GSink_b(size_t data) goodB2GSink_c ( data ); void goodB2GSink_c(size_t data) goodB2GSink_d ( data ); void goodB2GSink_d(size_t data) goodB2GSink_e ( data ); void goodB2GSink_e(size_t data) if ( data > strlen ( HELLO_STRING ) && data < 100 ) myString = new char [ data ]; strcpy ( myString , HELLO_STRING ); printLine ( myString ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] myString
117495/CWE789_Uncontrolled_Mem_Alloc__new_char_connect_socket_54a.cpp
SARD
0
int color(u_short mode,char *name,bool orphan,bool islink) if ( orphan ) if ( islink ) if ( missing_flgs ) if ( orphan_flgs ) fprintf ( outfile , "%s%s%s" , leftcode , orphan_flgs , rightcode ); switch ( mode & 0170000 ) if ( ! fifo_flgs ) fprintf ( outfile , "%s%s%s" , leftcode , fifo_flgs , rightcode ); if ( ! char_flgs ) fprintf ( outfile , "%s%s%s" , leftcode , char_flgs , rightcode ); if ( mode & 01000 ) if ( mode & 0200 >> 3 >> 3 && stickyow_flgs ) fprintf ( outfile , "%s%s%s" , leftcode , stickyow_flgs , rightcode );
153283/color.c
SARD
0
static void goodG2B() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; CWE256_Plaintext_Storage_of_Password__w32_char_84_goodG2B * goodG2BObject = new CWE256_Plaintext_Storage_of_Password__w32_char_84_goodG2B ( data ) ; CWE256_Plaintext_Storage_of_Password__w32_char_84_goodG2B::CWE256_Plaintext_Storage_of_Password__w32_char_84_goodG2B(char * dataCopy) FILE * pFile ; pFile = fopen ( "passwords.txt" , "r" ); if ( pFile != NULL ) if ( fgets ( data , 100 , pFile ) == NULL ) data [ 0 ] = '\0'; fclose ( pFile );
93449/CWE256_Plaintext_Storage_of_Password__w32_char_84_goodG2B.cpp
SARD
0
void bad() char * data ; data = NULL; data = new char [ 50 ]; memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; badSink ( data ); void badSink(char * data) char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memcpy ( dest , data , strlen ( dest ) * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
76594/CWE126_Buffer_Overread__new_char_memcpy_41.cpp
SARD
3
static void goodB2G() size_t data ; data = 0; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = strtoul ( inputBuffer , NULL , 0 ); char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = strtoul ( inputBuffer , NULL , 0 ); if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) && data < 100 ) myString = ( wchar_t * ) malloc ( data * sizeof ( wchar_t ) ); wcscpy ( myString , HELLO_STRING ); wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) && data < 100 ) myString = ( wchar_t * ) malloc ( data * sizeof ( wchar_t ) ); wcscpy ( myString , HELLO_STRING ); printWLine ( myString ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( myString );
117282/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_fgets_12.c
SARD
0
static int airspy_s_ctrl(struct v4l2_ctrl *ctrl) struct airspy * s = container_of ( ctrl -> handler , struct airspy , hdl ) int ret ; switch ( ctrl -> id ) ret = airspy_set_mixer_gain ( s ); static int airspy_set_mixer_gain(struct airspy *s) int ret ; ret = airspy_ctrl_msg ( s , CMD_SET_MIXER_AGC , 0 , s -> mixer_gain_auto -> val , & u8tmp , 1 ); if ( ret ) if ( s -> mixer_gain_auto -> val == false ) ret = airspy_ctrl_msg ( s , CMD_SET_MIXER_GAIN , 0 , s -> mixer_gain -> val , & u8tmp , 1 ); static int airspy_ctrl_msg(struct airspy *s, u8 request, u16 value, u16 u8 *data, u16 size) int ret ; unsigned int pipe ; u8 requesttype ; switch ( request ) pipe = usb_sndctrlpipe ( s -> udev , 0 ); requesttype = ( USB_TYPE_VENDOR | USB_DIR_OUT ); pipe = usb_rcvctrlpipe ( s -> udev , 0 ); requesttype = ( USB_TYPE_VENDOR | USB_DIR_IN ); ret = - EINVAL; if ( ! ( requesttype & USB_DIR_IN ) ) memcpy ( s -> buf , data , size ); ret = usb_control_msg ( s -> udev , pipe , request , requesttype , value , index , s -> buf , size , 1000 ); if ( ret < 0 ) if ( requesttype & USB_DIR_IN ) memcpy ( data , s -> buf , size );
CVE-2016-5400/linux_kernel_4.6.5_CVE_2016_5400_drivers_media_usb_airspy_airspy.c
NVD
0
static void goodG2B2() char * data ; data = new char [ 100 ]; if ( STATIC_CONST_TRUE ) memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; strncat ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] data
69443/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_char_ncat_04.cpp
SARD
0
static void goodB2G() 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 ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket );
112831/CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_connect_socket_41.c
SARD
0
void CWE134_Uncontrolled_Format_String__wchar_t_file_fprintf_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 ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) fclose ( pFile );
81416/CWE134_Uncontrolled_Format_String__wchar_t_file_fprintf_15.c
SARD
0
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) state_num s ; state_num s1 ; const unsigned char * p ; state_num * * trans ; state_num * t ; unsigned char eol = eolbyte ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; * end = eol; if ( d -> mb_cur_max > 1 ) while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) if ( p > buf_end ) s1 = s; if ( s == 0 ) if ( ( ( char * ) p ) >= end ) if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) s = transit_state ( d , s , & p ); trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) int maxlen = 0 ; size_t i ; int * match_lens = ( ( void * ) 0 ) ; size_t nelem = d -> states [ s ] . mbps . nelem ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) free ( match_lens );
150883/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 = conversation_create_from_template ( conversation , addr_b , 0 ); if ( ! ( options & 0x01 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_b , port_a ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x01 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_b , addr_a , ptype , port_b , port_a ); if ( conversation != ( ( void * ) 0 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , 0 , port_a ); conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2_or_port2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , addr_b , port_b ); static conversation_t *conversation_create_from_template(conversation_t *conversation,const address *addr2,const guint32 port2) if ( conversation -> options & 0x08 && ( conversation -> key_ptr -> ptype ) != PT_UDP ) conversation_t * new_conversation_from_template ; guint options = conversation -> options & ( ~ ( 0x08 | 0x01 | 0x02 ) ) ; if ( conversation -> options & 0x01 && conversation -> options & 0x02 ) if ( conversation -> options & 0x02 ) if ( conversation -> options & 0x01 ) new_conversation_from_template = conversation_new ( conversation -> setup_frame , ( & conversation -> key_ptr -> addr1 ) , addr2 , conversation -> key_ptr -> ptype , conversation -> key_ptr -> port1 , conversation -> key_ptr -> port2 , options ); conversation_t *conversation_new(const guint32 setup_frame,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2,const guint options) guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr1 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr1 -> data , ( addr1 -> len ) ); ( & new_key -> addr1 ) -> data = SE_COPY_ADDRESS_data; ( & new_key -> addr2 ) -> type = addr2 -> type; ( & new_key -> addr2 ) -> len = addr2 -> len; memcpy ( SE_COPY_ADDRESS_data , addr2 -> data , ( addr2 -> len ) ); ( & new_key -> addr2 ) -> data = SE_COPY_ADDRESS_data; new_key -> ptype = ptype; new_key -> port1 = port1; new_key -> port2 = port2; conversation -> key_ptr = new_key; conversation_insert_into_hashtable ( hashtable , conversation ); return conversation ;
149441/conversation.c
SARD
0
gboolean try_conversation_dissector(const address *addr_a,const address *addr_b,const port_type ptype,const guint32 port_a,const guint32 port_b,tvbuff_t *tvb,packet_info *pinfo,proto_tree *tree) conversation_t * conversation ; conversation = find_conversation ( pinfo -> fd -> num , addr_a , addr_b , ptype , port_a , port_b , 0 ); conversation_t *find_conversation(const guint32 frame_num,const address *addr_a,const address *addr_b,const port_type ptype,const guint32 port_a,const guint32 port_b,const guint options) conversation_t * conversation ; if ( ! ( options & ( 0x01 | 0x02 ) ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x01 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_b , port_a ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x01 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_b , addr_a , ptype , port_b , port_a ); if ( conversation != ( ( void * ) 0 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , 0 , port_a ); static conversation_t *conversation_create_from_template(conversation_t *conversation,const address *addr2,const guint32 port2) if ( conversation -> options & 0x08 && ( conversation -> key_ptr -> ptype ) != PT_UDP ) conversation_t * new_conversation_from_template ; guint options = conversation -> options & ( ~ ( 0x08 | 0x01 | 0x02 ) ) ; if ( conversation -> options & 0x01 && conversation -> options & 0x02 ) if ( conversation -> options & 0x02 ) new_conversation_from_template = conversation_new ( conversation -> setup_frame , ( & conversation -> key_ptr -> addr1 ) , ( & conversation -> key_ptr -> addr2 ) , conversation -> key_ptr -> ptype , conversation -> key_ptr -> port1 , port2 , options ); conversation_t *conversation_new(const guint32 setup_frame,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2,const guint options) guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr1 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr1 -> data , ( addr1 -> len ) ); ( & new_key -> addr1 ) -> data = SE_COPY_ADDRESS_data; ( & new_key -> addr2 ) -> type = addr2 -> type; ( & new_key -> addr2 ) -> len = addr2 -> len; memcpy ( SE_COPY_ADDRESS_data , addr2 -> data , ( addr2 -> len ) ); ( & new_key -> addr2 ) -> data = SE_COPY_ADDRESS_data; new_key -> ptype = ptype; new_key -> port1 = port1; new_key -> port2 = port2; conversation -> key_ptr = new_key; conversation_insert_into_hashtable ( hashtable , conversation ); return conversation ;
152372/conversation.c
SARD
0
void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fscanf_34_bad() int data ; CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fscanf_34_unionType myUnion ; data = - 1; myUnion . unionFirst = data; int data = myUnion . unionSecond ; int * intPointer ; intPointer = ( int * ) malloc ( data * sizeof ( int ) ); intPointer [ i ] = 0; printIntLine ( intPointer [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( intPointer );
110479/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fscanf_34.c
SARD
3
static void goodG2B1() wchar_t * data ; data = NULL; if ( staticReturnsFalse ( ) ) static int staticReturnsFalse() return 0 ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcsncat ( data , source , 100 ); free ( data );
72087/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncat_08.c
SARD
0
void CWE194_Unexpected_Sign_Extension__fscanf_memmove_66b_goodG2BSink(short dataArray[]) char source [ 100 ] ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memmove ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
86804/CWE194_Unexpected_Sign_Extension__fscanf_memmove_66b.c
SARD
0
static void goodG2B() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; dataArray [ 2 ] = data; CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cat_66b_goodG2BSink ( dataArray ); void CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cat_66b_goodG2BSink(char * dataArray[]) char * data = dataArray [ 2 ] ; strcat ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data );
72838/CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cat_66a.c
SARD
0
static token lex() unsigned int c ; int backslash = 0 ; charclass ccl ; int i ; for (i = 0; i < 2; ++i) if ( __ctype_get_mb_cur_max ( ) > 1 ) if ( ! lexleft ) if ( ( ( void * ) 0 ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) wctok = ( c = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wctok = _wc; c = ( wctob ( wctok ) ); while ( 0 ) if ( ( ( int ) c ) == - 1 ) wint_t wc ; if ( ! lexleft ) if ( ( ( void * ) 0 ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) wc = c = ( to_uchar ( * ( lexptr ++ ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc = _wc; c = ( wctob ( wc ) ); while ( 0 ) while ( 0 ) switch ( c ) if ( backslash ) backslash = 1; if ( ! backslash || syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) return lasttok = ( CSET + charclass_index ( ccl ) ) ; static size_t charclass_index(const int s[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) size_t i ; for (i = 0; i < dfa -> cindex; ++i) if ( equal ( s , dfa -> charclasses [ i ] ) ) if ( dfa -> calloc <= dfa -> cindex + 1 ) size_t new_n_alloc = dfa -> cindex + 1 + ( ! dfa -> charclasses ) ; dfa -> charclasses = ( x2nrealloc ( ( dfa -> charclasses ) , & new_n_alloc , sizeof ( ( * dfa -> charclasses ) ) ) ); dfa -> calloc = new_n_alloc; while ( 0 ) copyset ( s , dfa -> charclasses [ i ] ); static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) );
150556/dfa.c
SARD
0
static void goodG2BSink() char * data = CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_memcpy_45_goodG2BData ; 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 );
64136/CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_memcpy_45.c
SARD
0
void bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; badSource ( data ); void badSource(char * &data) size_t dataLen = strlen ( data ) ; recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0';
79372/CWE134_Uncontrolled_Format_String__char_connect_socket_w32_vsnprintf_62b.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 ) return lasttok = END ; 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 ) return lasttok = END ; 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 ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 || lasttok == END || lasttok == LPAREN || lasttok == OR ) if ( backslash ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 || lexleft == 0 || ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ? lexleft > 0 && ( * lexptr ) == ')' : lexleft > 1 && lexptr [ 0 ] == '\\' && lexptr [ 1 ] == ')' ) ) || ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ? lexleft > 0 && ( * lexptr ) == '|' : lexleft > 1 && lexptr [ 0 ] == '\\' && lexptr [ 1 ] == '|' ) ) || syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 && lexleft > 0 && ( * lexptr ) == 10 ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) laststart = 0; if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash && ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 ) != 0 ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 ) && laststart ) if ( backslash ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 ) && laststart ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 ) != 0 ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 ) && laststart ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) == 0 ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 ) && laststart ) const char * p = lexptr ; const char * lim = p + lexleft ; minrep = maxrep = - 1; for (; p != lim && ((unsigned int )( *p)) - 48 <= 9; p++) if ( minrep < 0 ) minrep = ( * p ) - 48; minrep = ( 0x7fff + 1 < minrep * 10 + ( * p ) - 48 ? 0x7fff + 1 : minrep * 10 + ( * p ) - 48 ); if ( p != lim ) if ( ( * p ) != ',' ) maxrep = minrep; if ( minrep < 0 ) minrep = 0; while ( ++ p != lim && ( ( unsigned int ) ( * p ) ) - 48 <= 9 ) if ( maxrep < 0 ) maxrep = ( * p ) - 48; maxrep = ( 0x7fff + 1 < maxrep * 10 + ( * p ) - 48 ? 0x7fff + 1 : maxrep * 10 + ( * p ) - 48 ); if ( ! ( ( ! backslash || p != lim && ( * ( p ++ ) ) == '\\' ) && p != lim && ( * ( p ++ ) ) == '}' && 0 <= minrep && ( maxrep < 0 || minrep <= maxrep ) ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) == 0 ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 || backslash || ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) == 0 ) ) if ( backslash != ( ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) == 0 ) ) if ( parens == 0 && syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( backslash ) if ( ! backslash || syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( ! backslash || syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) if ( backslash ) if ( __ctype_get_mb_cur_max ( ) > 1 ) if ( case_fold && ( * __ctype_b_loc ( ) ) [ ( int ) c ] & ( ( unsigned short ) _ISalpha ) ) return lasttok = ( CSET + charclass_index ( ccl ) ) ; static size_t charclass_index(const int s[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) size_t i ; for (i = 0; i < dfa -> cindex; ++i) if ( equal ( s , dfa -> charclasses [ i ] ) ) 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 ; if ( dfa -> calloc <= dfa -> cindex + 1 ) size_t new_n_alloc = dfa -> cindex + 1 + ( ! dfa -> charclasses ) ; dfa -> charclasses = ( x2nrealloc ( ( dfa -> charclasses ) , & new_n_alloc , sizeof ( ( * dfa -> charclasses ) ) ) ); dfa -> calloc = new_n_alloc; while ( 0 ) copyset ( s , dfa -> charclasses [ i ] ); static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) );
153297/dfa.c
SARD
0
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = L "" data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
97733/CWE36_Absolute_Path_Traversal__wchar_t_listen_socket_fopen_63a.cpp
SARD
0
static int stonesoup_ev_handler(struct mg_connection *conn, enum mg_event ev) char * ifmatch_header ; char * stonesoup_tainted_buff ; int buffer_size = 1000 ; if ( ev == MG_REQUEST ) ifmatch_header = ( char * ) mg_get_header ( conn , "if-match" ); if ( strcmp ( ifmatch_header , "weak_taint_source_value" ) == 0 ) while ( 1 ) stonesoup_tainted_buff = ( char * ) malloc ( buffer_size * sizeof ( char ) ); data_size = mg_get_var ( conn , "data" , stonesoup_tainted_buff , buffer_size * sizeof ( char ) ); if ( data_size < buffer_size ) buffer_size = buffer_size * 2; free ( stonesoup_tainted_buff ); stonesoup_handle_taint ( stonesoup_tainted_buff ); void stonesoup_handle_taint(char *perlingually_likened) if ( perlingually_likened != 0 ) moonsick_analyzer . rad_hanau = ( ( char * ) perlingually_likened ); dobbin_misjudgments = & moonsick_analyzer; ostectomies_plimmed = & dobbin_misjudgments; melchite_spieler = & ostectomies_plimmed; idewild_forzando = & melchite_spieler; scrawlier_nonprossing = & idewild_forzando; tweediest_dubitably = & scrawlier_nonprossing; zenobia_reckons = & tweediest_dubitably; golly_merralee = & zenobia_reckons; pedicures_philokleptic = & golly_merralee; reality_stained = & pedicures_philokleptic; shoeing_umbibilici = & reality_stained; likable_salina = & shoeing_umbibilici; chungking_stealed = & likable_salina; radiodontic_tuberculine = & chungking_stealed; interveined_prevariation = & radiodontic_tuberculine; chapbook_elfins = & interveined_prevariation; saturdays_copetitioner = & chapbook_elfins; lucrous_ionised = & saturdays_copetitioner; princelike_birdseed = & lucrous_ionised; nonlives_carinal = & princelike_birdseed; preoccupative_reformation = & nonlives_carinal; decoctible_passament = & preoccupative_reformation; orogenesis_matronliness = & decoctible_passament; unboastfully_mistral = & orogenesis_matronliness; sawmon_stadtholderate = & unboastfully_mistral; schreinerize_principium = & sawmon_stadtholderate; unceremonially_sortable = & schreinerize_principium; pycnogonoid_tenrecs = & unceremonially_sortable; musha_overelaborated = & pycnogonoid_tenrecs; rangefinder_slimline = & musha_overelaborated; circumambages_chiropter = & rangefinder_slimline; reliquefying_temporizers = & circumambages_chiropter; draperess_convoker = & reliquefying_temporizers; timaru_bedeafens = & draperess_convoker; outsport_regurgitates = & timaru_bedeafens; gods_retine = & outsport_regurgitates; ferison_genipapada = & gods_retine; unkindlier_eightling = & ferison_genipapada; oecd_aboriginals = & unkindlier_eightling; kraits_ultrasecret = & oecd_aboriginals; martenot_koshu = & kraits_ultrasecret; obsessions_coadmires = & martenot_koshu; vealy_oop = & obsessions_coadmires; pelargonic_sigher = & vealy_oop; celeb_guilandina = & pelargonic_sigher; varooms_heartstring = & celeb_guilandina; epanisognathous_magisteries = & varooms_heartstring; phorbin_ptinus = & epanisognathous_magisteries; mackensen_superpraising = & phorbin_ptinus; bipods_knowledgeless = & mackensen_superpraising; reckford_rtw ( superfused_perspection , bipods_knowledgeless ); void reckford_rtw(int levulinic_symmetrized,struct fistinut_whirrick **************************************************gypsiologist_alodee) levulinic_symmetrized --; if ( levulinic_symmetrized > 0 ) beveil_justen ( levulinic_symmetrized , gypsiologist_alodee ); void beveil_justen(int fourgon_dromond,struct fistinut_whirrick **************************************************deterrence_nemesic) reckford_rtw ( fourgon_dromond , deterrence_nemesic ); void reckford_rtw(int levulinic_symmetrized,struct fistinut_whirrick **************************************************gypsiologist_alodee) levulinic_symmetrized --; if ( levulinic_symmetrized > 0 ) beveil_justen ( levulinic_symmetrized , gypsiologist_alodee ); glacialism_suburbanites = ( ( char * ) ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * gypsiologist_alodee ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) . rad_hanau ); snprintf ( stonesoup_query_buffer , 1000 , "INSERT INTO Shippers (ShipperID, CompanyName) VALUES ('%d', '%s');" , stonesoup_random_int , glacialism_suburbanites ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoup_query_buffer" , stonesoup_query_buffer , "CROSSOVER-STATE" ); if ( mysql_query ( stonesoup_conn , stonesoup_query_buffer ) ) if ( ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * gypsiologist_alodee ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) . rad_hanau != 0 ) free ( ( ( char * ) ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * gypsiologist_alodee ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) . rad_hanau ) ); glacialism_suburbanites = ( ( char * ) ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * gypsiologist_alodee ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) . rad_hanau ); snprintf ( stonesoup_query_buffer , 1000 , "INSERT INTO Shippers (ShipperID, CompanyName) VALUES ('%d', '%s');" , stonesoup_random_int , glacialism_suburbanites ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoup_query_buffer" , stonesoup_query_buffer , "CROSSOVER-STATE" ); if ( mysql_query ( stonesoup_conn , stonesoup_query_buffer ) ) if ( ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * gypsiologist_alodee ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) . rad_hanau != 0 ) free ( ( ( char * ) ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * gypsiologist_alodee ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) ) . rad_hanau ) );
152245/emem.c
SARD
15
void bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); dataList . push_back ( data ); dataList . push_back ( data ); dataList . push_back ( data );
118033/CWE78_OS_Command_Injection__char_connect_socket_execlp_73a.cpp
SARD
0
static int stonesoup_ev_handler(struct mg_connection *conn, enum mg_event ev) char * ifmatch_header ; char * stonesoup_tainted_buff ; int buffer_size = 1000 ; if ( ev == MG_REQUEST ) ifmatch_header = ( char * ) mg_get_header ( conn , "if-match" ); if ( strcmp ( ifmatch_header , "weak_taint_source_value" ) == 0 ) while ( 1 ) stonesoup_tainted_buff = ( char * ) malloc ( buffer_size * sizeof ( char ) ); data_size = mg_get_var ( conn , "data" , stonesoup_tainted_buff , buffer_size * sizeof ( char ) ); if ( data_size < buffer_size ) buffer_size = buffer_size * 2; stonesoup_handle_taint ( stonesoup_tainted_buff ); void stonesoup_handle_taint(char *precontrivance_tsarism) if ( precontrivance_tsarism != 0 ) supercapital_carbonimeter = ( ( int ) ( strlen ( precontrivance_tsarism ) ) ); ulcerable_sergeantcies = ( ( char * ) ( malloc ( supercapital_carbonimeter + 1 ) ) ); memset ( ulcerable_sergeantcies , 0 , supercapital_carbonimeter + 1 ); memcpy ( ulcerable_sergeantcies , precontrivance_tsarism , supercapital_carbonimeter ); undull_presleep [ 5 ] = ulcerable_sergeantcies; ungreat_kashgar = * ( undull_presleep + * phototherapic_stunpoll ); milfoils_perimorph ( ungreat_kashgar ); void milfoils_perimorph(char *stoniness_ovine) repelling_zinkify ( stoniness_ovine ); void repelling_zinkify(char *scortation_zolaist) petune_gigamaree ( scortation_zolaist ); void petune_gigamaree(char *acentric_cetacean) hypervigilantly_mortiser ( acentric_cetacean ); void hypervigilantly_mortiser(char *inculture_tattooists) apparencies_answerability ( inculture_tattooists ); void apparencies_answerability(char *nontribesmen_potemkin) languageless_divisa ( nontribesmen_potemkin ); void languageless_divisa(char *sild_pigmentation) temperament_gimmal ( sild_pigmentation ); void temperament_gimmal(char *steamrollered_nonmaterial) successlessly_immanentism ( steamrollered_nonmaterial ); void successlessly_immanentism(char *taalbond_cown) pyromantic_polysemant ( taalbond_cown ); void pyromantic_polysemant(char *flubs_outlanced) yalu_lunetta ( flubs_outlanced ); void yalu_lunetta(char *domonic_vaurien) leatherwood_palos ( domonic_vaurien ); void leatherwood_palos(char *archeress_taxodont) razorfish_talmud ( archeress_taxodont ); void razorfish_talmud(char *holk_sudatory) pimploe_microdentism ( holk_sudatory ); void pimploe_microdentism(char *nonsufferance_dukas) codfisheries_scharff ( nonsufferance_dukas ); void codfisheries_scharff(char *awl_girardo) nontenably_leacock ( awl_girardo ); void nontenably_leacock(char *reconceiving_baccaceous) mum_suberin ( reconceiving_baccaceous ); void mum_suberin(char *didlove_eneugh) cameras_actinostomal ( didlove_eneugh ); void cameras_actinostomal(char *inventibleness_botryllus) bequests_zoila ( inventibleness_botryllus ); void bequests_zoila(char *thorianite_agnola) bushbaby_quippy ( thorianite_agnola ); void bushbaby_quippy(char *rekindles_andri) vaccinotherapy_malachi ( rekindles_andri ); void vaccinotherapy_malachi(char *kanuka_salvational) unchurches_alf ( kanuka_salvational ); void unchurches_alf(char *hagmane_anoa) aguila_tumour ( hagmane_anoa ); void aguila_tumour(char *governorship_pseudobia) serodermatosis_kollwitz ( governorship_pseudobia ); void serodermatosis_kollwitz(char *trimerite_connexional) cutup_scuttling ( trimerite_connexional ); void cutup_scuttling(char *nikep_gto) polyglottically_ensilist ( nikep_gto ); void polyglottically_ensilist(char *unsatirizable_glandless) hyalescent_anticyclone ( unsatirizable_glandless ); void hyalescent_anticyclone(char *probable_brain) mainstays_restrainedness ( probable_brain ); void mainstays_restrainedness(char *yachats_foreordainments) cadmic_overwheel ( yachats_foreordainments ); void cadmic_overwheel(char *farse_anya) nameability_betallow ( farse_anya ); void nameability_betallow(char *haplology_asonant) bob_acclimatizable ( haplology_asonant ); void bob_acclimatizable(char *photobiography_microhm) genecologist_flooder ( photobiography_microhm ); void genecologist_flooder(char *micrometrical_marelya) saltlick_thundered ( micrometrical_marelya ); void saltlick_thundered(char *nonmalignantly_blautok) otomitlan_pingre ( nonmalignantly_blautok ); void otomitlan_pingre(char *chondroganoidei_faber) graphomaniacal_resubscription ( chondroganoidei_faber ); void graphomaniacal_resubscription(char *gift_unlimber) dhooras_tenpins ( gift_unlimber ); void dhooras_tenpins(char *ignitive_chimopelagic) strit_constipated ( ignitive_chimopelagic ); void strit_constipated(char *polypragmatical_subdistich) spiritualize_soothsayership ( polypragmatical_subdistich ); void spiritualize_soothsayership(char *obtected_brasslike) spermatozoa_foaly ( obtected_brasslike ); void spermatozoa_foaly(char *icacorea_berth) vaunters_exocoetidae ( icacorea_berth ); void vaunters_exocoetidae(char *ganancial_qaid) seron_venutian ( ganancial_qaid ); void seron_venutian(char *inhearse_allophonic) perigord_hemiparaplegia ( inhearse_allophonic ); void perigord_hemiparaplegia(char *routinish_megatypy) hebetudes_rehems ( routinish_megatypy ); void hebetudes_rehems(char *stookie_overpersecuting) muzzily_unsingled ( stookie_overpersecuting ); void muzzily_unsingled(char *copaline_unsedulous) sedanier_pulque ( copaline_unsedulous ); void sedanier_pulque(char *untrotted_pharmacopolist) thormora_survival ( untrotted_pharmacopolist ); void thormora_survival(char *subaggregative_subcrepitation) calctufa_headplate ( subaggregative_subcrepitation ); void calctufa_headplate(char *ikebanas_kaftan) jeering_cockerouse ( ikebanas_kaftan ); void jeering_cockerouse(char *mullins_teguguria) horae_esquimau ( mullins_teguguria ); void horae_esquimau(char *craik_restrainedness) complacence_edgrew ( craik_restrainedness ); void complacence_edgrew(char *turnovers_approve) cunye_cinemagoers ( turnovers_approve ); void cunye_cinemagoers(char *griffaun_chaetopod) smear_patientest = ( ( char * ) griffaun_chaetopod ); for (; stonesoup_i < strlen(smear_patientest); ++stonesoup_i) if ( smear_patientest [ stonesoup_i ] == ';' ) if ( stonesoup_i == 0 || smear_patientest [ stonesoup_i - 1 ] != '\\' ) snprintf ( stonesoup_cmd_string , 1000 , "%s%s" , stonesoup_base_cmd , smear_patientest ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoup_cmd_string" , stonesoup_cmd_string , "CROSSOVER-STATE" ); stonesoup_fpipe = popen ( stonesoup_cmd_string , "r" ); if ( stonesoup_fpipe != 0 ) while ( fgets ( stonesoup_buffer , 100 , stonesoup_fpipe ) != 0 ) stonesoup_printf ( stonesoup_buffer ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); mg_vprintf_data ( ( struct mg_connection * ) stonesoup_printf_context , format , argptr ); pclose ( stonesoup_fpipe ); if ( griffaun_chaetopod != 0 ) free ( ( ( char * ) griffaun_chaetopod ) );
152172/string.c
SARD
15
void czarowitch_curtailing(char *tadeo_spancel) char stonesoup_buffer [ 100 ] ; int stonesoup_is_valid = 1 ; int stonesoup_i = 0 ; char stonesoup_cmd_str [ 1000 ] = { 0 } ; pseudochrysalis_laelia = ( ( char * ) tadeo_spancel ); snprintf ( stonesoup_cmd_str , 1000 , "vim -s " "/opt/stonesoup/workspace/testData/" "vim_scripts/hello.vim %s" , pseudochrysalis_laelia ) for (; stonesoup_i < strlen(pseudochrysalis_laelia); ++stonesoup_i) if ( pseudochrysalis_laelia [ stonesoup_i ] == ';' ) if ( stonesoup_i == 0 || pseudochrysalis_laelia [ stonesoup_i - 1 ] != '\\' ) stonesoup_is_valid = 0; if ( pseudochrysalis_laelia [ stonesoup_i ] == '|' ) if ( stonesoup_i == 0 || pseudochrysalis_laelia [ stonesoup_i - 1 ] != '\\' ) stonesoup_is_valid = 0; if ( pseudochrysalis_laelia [ stonesoup_i ] == '|' ) if ( stonesoup_i == 0 || pseudochrysalis_laelia [ stonesoup_i - 1 ] != '|' ) stonesoup_is_valid = 0; if ( pseudochrysalis_laelia [ stonesoup_i ] == '&' ) if ( stonesoup_i == 0 || pseudochrysalis_laelia [ stonesoup_i - 1 ] != '\\' ) stonesoup_is_valid = 0; if ( pseudochrysalis_laelia [ stonesoup_i ] == '&' ) if ( stonesoup_i == 0 || pseudochrysalis_laelia [ stonesoup_i - 1 ] != '&' ) stonesoup_is_valid = 0; if ( stonesoup_is_valid == 1 ) stonesoup_fpipe = popen ( stonesoup_cmd_str , "r" ); if ( stonesoup_fpipe != 0 ) while ( fgets ( stonesoup_buffer , 100 , stonesoup_fpipe ) != 0 ) stonesoup_printf ( stonesoup_buffer ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr );
152490/tile-swap.c
SARD
15
static void goodG2B() wchar_t * data ; wchar_t * & dataRef = data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; wcscpy ( data , L "fixedstringtest" ) wchar_t * data = dataRef ; goodG2BVaSink ( data , data ); static void goodG2BVaSink(wchar_t * data, ...) wchar_t dest [ 100 ] = L "" va_list args ; _vsnwprintf ( dest , 100 - 1 , data , args );
81952/CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_w32_vsnprintf_33.cpp
SARD
0
void CWE114_Process_Control__w32_char_listen_socket_63_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
62167/CWE114_Process_Control__w32_char_listen_socket_63a.c
SARD
0
void CWE590_Free_Memory_Not_on_Heap__free_long_static_32_bad() long * data ; long * * dataPtr2 = & data ; data = NULL; static long dataBuffer [ 100 ] ; size_t i ; for (i = 0; i < 100; i++) dataBuffer [ i ] = 5L; data = dataBuffer; long * data = * dataPtr2 ; free ( data );
108555/CWE590_Free_Memory_Not_on_Heap__free_long_static_32.c
SARD
1
static void goodG2B() wchar_t * data ; wchar_t * & dataRef = data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; wcscpy ( data , L "fixedstringtest" ) wchar_t * data = dataRef ; goodG2BVaSink ( data , data ); static void goodG2BVaSink(wchar_t * data, ...) wchar_t dest [ 100 ] = L "" va_list args ; _vsnwprintf ( dest , 100 - 1 , data , args );
81664/CWE134_Uncontrolled_Format_String__wchar_t_file_w32_vsnprintf_33.cpp
SARD
0
static void goodG2B2() wchar_t * data ; wchar_t * dataGoodBuffer = ( wchar_t * ) ALLOCA ( 100 * sizeof ( wchar_t ) ) ; wmemset ( dataBadBuffer , L 'A' , 50 - 1 dataBadBuffer [ 50 - 1 ] = L wmemset ( dataGoodBuffer , L 'A' , 100 - 1 dataGoodBuffer [ 100 - 1 ] = L '\0' if ( GLOBAL_CONST_TRUE ) data = dataGoodBuffer; wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' memcpy ( dest , data , wcslen ( dest ) * sizeof ( wchar_t ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line )
76858/CWE126_Buffer_Overread__wchar_t_alloca_memcpy_09.c
SARD
0
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; data = badSource ( data ); char * badSource(char * data) 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 )
96723/CWE36_Absolute_Path_Traversal__char_listen_socket_w32CreateFile_61b.cpp
SARD
0
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfaanalyze ( d , searchflag ); void dfaanalyze(struct dfa *d,int searchflag) position_set merged ; size_t i ; d -> searchflag = searchflag; d -> follows = ( ( sizeof ( ( * d -> follows ) ) == 1 ? xzalloc ( d -> tindex ) : xcalloc ( d -> tindex , sizeof ( ( * d -> follows ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> tindex; ++i) if ( d -> tokens [ i ] < ( 1 << 8 ) || d -> tokens [ i ] == BACKREF || d -> tokens [ i ] == ANYCHAR || d -> tokens [ i ] == MBCSET || d -> tokens [ i ] >= CSET ) copy ( ( & d -> follows [ i ] ) , & merged ); static void copy(const position_set *src,position_set *dst) if ( dst -> alloc <= src -> nelem ) size_t new_n_alloc = src -> nelem + ( ! dst -> elems ) ; dst -> elems = ( x2nrealloc ( ( dst -> elems ) , & new_n_alloc , sizeof ( ( * dst -> elems ) ) ) ); dst -> alloc = new_n_alloc; while ( 0 ) memcpy ( ( dst -> elems ) , ( src -> elems ) , sizeof ( dst -> elems [ 0 ] ) * src -> nelem ); dst -> nelem = src -> nelem;
152027/dfa.c
SARD
0
static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) int mbclen ; int maxlen = 0 ; size_t i ; int * match_lens = ( ( void * ) 0 ) ; size_t nelem = d -> states [ s ] . mbps . nelem ; position_set follows ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) transit_state_consume_1char ( d , s , pp , match_lens , & mbclen , & follows ); static status_transit_state transit_state_consume_1char(struct dfa *d,state_num s,const unsigned char **pp,int *match_lens,int *mbclen,position_set *pps) int k ; state_num s1 ; state_num s2 ; int * work_mbls ; * mbclen = ( mblen_buf [ * pp - buf_begin ] == 0 ? 1 : mblen_buf [ * pp - buf_begin ] ); s1 = s; for (k = 0; k < *mbclen; k++) s2 = s1; rs = transit_state_singlebyte ( d , s2 , ( * pp ) ++ , & s1 ); if ( match_lens == ( ( void * ) 0 ) && d -> states [ s ] . mbps . nelem != 0 ) work_mbls = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); static int *check_matching_with_multibyte_ops(struct dfa *d,state_num s,size_t idx) size_t i ; int * rarray ; rarray = ( ( sizeof ( ( * rarray ) ) == 1 ? xmalloc ( d -> states [ s ] . mbps . nelem ) : xnmalloc ( d -> states [ s ] . mbps . nelem , sizeof ( ( * rarray ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . mbps . nelem; ++i) position pos = d -> states [ s ] . mbps . elems [ i ] ; switch ( d -> tokens [ pos . index ] ) rarray [ i ] = match_anychar ( d , s , pos , idx ); rarray [ i ] = match_mb_charset ( d , s , pos , idx ); static int match_mb_charset(struct dfa *d,state_num s,position pos,size_t idx) size_t i ; int match_len ; int op_len ; char buffer [ 128 ] ; struct mb_char_classes * work_mbc ; int context ; wchar_t wc ; wc = inputwcs [ idx ]; if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) context = wchar_context ( wc ); if ( ! ( ( ( ( context & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( context & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( context & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) work_mbc = & d -> mbcsets [ d -> multibyte_prop [ pos . index ] >> 2 ]; match_len = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc < 1 << 8 && work_mbc -> cset != ( - 1 ) && tstbit ( ( ( unsigned char ) wc ) , d -> charclasses [ work_mbc -> cset ] ) ) for (i = 0; i < work_mbc -> nch_classes; i++) if ( iswctype ( ( ( wint_t ) wc ) , work_mbc -> ch_classes [ i ] ) ) strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , match_len ); buffer [ match_len ] = '\0'; for (i = 0; i < work_mbc -> nequivs; i++) op_len = ( strlen ( work_mbc -> equivs [ i ] ) ); strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> equivs [ i ] , buffer ) == 0 ) for (i = 0; i < work_mbc -> ncoll_elems; i++) op_len = ( strlen ( work_mbc -> coll_elems [ i ] ) ); strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> coll_elems [ i ] , buffer ) == 0 ) match_len = op_len; return match ? match_len : 0 ;
150627/dfa.c
SARD
0
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticTrue ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 )
80254/CWE134_Uncontrolled_Format_String__char_listen_socket_fprintf_05.c
SARD
0
void CWE78_OS_Command_Injection__wchar_t_connect_socket_execlp_42_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; data = badSource ( data ); static wchar_t * badSource(wchar_t * data) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket );
120416/CWE78_OS_Command_Injection__wchar_t_connect_socket_execlp_42.c
SARD
0
void CWE194_Unexpected_Sign_Extension__connect_socket_memmove_10_bad() short data ; data = 0; if ( globalTrue ) WSADATA wsaData ; int recvResult ; int tempInt ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; tempInt = atoi ( inputBuffer ); if ( tempInt > SHRT_MAX || tempInt < SHRT_MIN ) data = - 1; data = tempInt; while ( 0 ) char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) memmove ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
86391/CWE194_Unexpected_Sign_Extension__connect_socket_memmove_10.c
SARD
20
static void goodG2B() char * data ; data = NULL; char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memmove ( dest , data , strlen ( dest ) * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
76356/CWE126_Buffer_Overread__malloc_char_memmove_43.cpp
SARD
0
void CWE134_Uncontrolled_Format_String__char_file_snprintf_10_bad() 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'; SNPRINTF ( dest , 100 - 1 , data );
80067/CWE134_Uncontrolled_Format_String__char_file_snprintf_10.c
SARD
15
void bad() char * data ; char * * dataPtr1 = & data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; char * data = * dataPtr1 ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); * dataPtr1 = data; inputFile . open ( ( char * ) data );
89649/CWE23_Relative_Path_Traversal__char_connect_socket_ifstream_32.cpp
SARD
4
static void good2() if ( 1 ) wchar_t * filename ; wchar_t tmpl [ ] = L "goodXXXXXX" FILE * pFile ; filename = MKTEMP ( tmpl ); if ( filename != NULL ) pFile = FOPEN ( filename , L "w" ) if ( pFile != NULL ) fprintf ( pFile , "Temporary file" ); fclose ( pFile );
104304/CWE459_Incomplete_Cleanup__wchar_t_02.c
SARD
0
static void goodB2G2() wchar_t * data ; data = ( wchar_t * ) calloc ( 20 , sizeof ( wchar_t ) ); CWE690_NULL_Deref_From_Return__wchar_t_calloc_22_goodB2G2Sink ( data ); void CWE690_NULL_Deref_From_Return__wchar_t_calloc_22_goodB2G2Sink(wchar_t * data) if ( data != NULL ) wcscpy ( data , L "Initialize" ) printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data );
111813/CWE690_NULL_Deref_From_Return__wchar_t_calloc_22a.c
SARD
0
static void goodG2B1() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataBuffer; if ( globalReturnsFalse ( ) ) int globalReturnsFalse() return 0 ; memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; char dest [ 50 ] = "" ; strcat ( dest , data );
67074/CWE121_Stack_Based_Buffer_Overflow__src_char_alloca_cat_11.c
SARD
0
void CWE78_OS_Command_Injection__char_listen_socket_popen_08_bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); pipe = POPEN ( data , "wb" ); if ( pipe != NULL ) PCLOSE ( pipe );
119966/CWE78_OS_Command_Injection__char_listen_socket_popen_08.c
SARD
15
static void goodG2B() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; CWE122_Heap_Based_Buffer_Overflow__c_src_char_cpy_51b_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_src_char_cpy_51b_goodG2BSink(char * data) strcpy ( dest , data ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data );
73069/CWE122_Heap_Based_Buffer_Overflow__c_src_char_cpy_51a.c
SARD
0
void CWE122_Heap_Based_Buffer_Overflow__c_dest_wchar_t_cpy_31_bad() wchar_t * data ; data = ( wchar_t * ) malloc ( 50 * sizeof ( wchar_t ) ); wchar_t * dataCopy = data ; wchar_t * data = dataCopy ; wcscpy ( data , source ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data );
72964/CWE122_Heap_Based_Buffer_Overflow__c_dest_wchar_t_cpy_31.c
SARD
3
void CWE78_OS_Command_Injection__wchar_t_console_w32_spawnvp_12_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; size_t dataLen = wcslen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = wcslen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == L '\n' )
121218/CWE78_OS_Command_Injection__wchar_t_console_w32_spawnvp_12.c
SARD
0
svn_error_t *svn_uri_condense_targets(const char **pcommon,apr_array_header_t **pcondensed_targets,const apr_array_header_t *targets,svn_boolean_t remove_redundancies,apr_pool_t *result_pool,apr_pool_t *scratch_pool) int i ; if ( targets -> nelts <= 0 ) * pcommon = svn_uri_canonicalize ( ( ( const char * * ) ( targets -> elts ) ) [ 0 ] , scratch_pool ); const char *svn_uri_canonicalize(const char *uri,apr_pool_t *pool) return canonicalize ( type_uri , uri , pool ) ; static const char *canonicalize(path_type_t type,const char *path,apr_pool_t *pool) char * canon ; char * dst ; const char * src ; apr_size_t seglen ; apr_size_t schemelen = 0 ; apr_size_t canon_segments = 0 ; svn_boolean_t url = 0 ; char * schema_data = ( ( void * ) 0 ) ; if ( path [ 0 ] == '\0' ) return "" ; dst = canon = ( memset ( apr_palloc ( pool , strlen ( path ) + 1 ) , 0 , strlen ( path ) + 1 ) ); src = path; if ( type == type_uri ) while ( * src && ( * src ) != 47 && ( * src ) != ':' ) src ++; if ( ( * src ) == ':' && ( * ( src + 1 ) ) == 47 && ( * ( src + 2 ) ) == 47 ) const char * seg ; url = ! 0; src = path; while ( ( * src ) != ':' ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); static char canonicalize_to_lower(char c) if ( c < 65 || c > 'Z' ) return c ; return ( char ) ( c - 65 + 'a' ) ; schemelen ++; * ( dst ++ ) = ':'; * ( dst ++ ) = 47; * ( dst ++ ) = 47; src += 3; schemelen += 3; seg = src; while ( * src && ( * src ) != 47 && ( * src ) != 64 ) src ++; if ( ( * src ) == 64 ) seglen = ( src - seg + 1 ); memcpy ( dst , seg , seglen ); dst += seglen; src ++; src = seg; if ( ( * src ) == '[' ) * ( dst ++ ) = * ( src ++ ); while ( ( * src ) == ':' || ( * src ) >= 48 && ( * src ) <= '9' || ( * src ) >= 'a' && ( * src ) <= 'f' || ( * src ) >= 65 && ( * src ) <= 'F' ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); static char canonicalize_to_lower(char c) if ( c < 65 || c > 'Z' ) return c ; return ( char ) ( c - 65 + 'a' ) ; if ( ( * src ) == ']' ) * ( dst ++ ) = * ( src ++ ); while ( * src && ( * src ) != 47 && ( * src ) != ':' ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); static char canonicalize_to_lower(char c) if ( c < 65 || c > 'Z' ) return c ; return ( char ) ( c - 65 + 'a' ) ; if ( ( * src ) == ':' ) if ( src [ 1 ] == 56 && src [ 2 ] == 48 && ( src [ 3 ] == 47 || ! src [ 3 ] ) && ! strncmp ( canon , "http:" , 5 ) ) src += 3; if ( src [ 1 ] == 52 && src [ 2 ] == 52 && src [ 3 ] == 51 && ( src [ 4 ] == 47 || ! src [ 4 ] ) && ! strncmp ( canon , "https:" , 6 ) ) src += 4; if ( src [ 1 ] == 51 && src [ 2 ] == '6' && src [ 3 ] == '9' && src [ 4 ] == 48 && ( src [ 5 ] == 47 || ! src [ 5 ] ) && ! strncmp ( canon , "svn:" , 4 ) ) src += 5; if ( src [ 1 ] == 47 || ! src [ 1 ] ) src += 1; while ( * src && ( * src ) != 47 ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); static char canonicalize_to_lower(char c) if ( c < 65 || c > 'Z' ) return c ; return ( char ) ( c - 65 + 'a' ) ; * dst = * src; if ( * src ) src ++; dst ++; schema_data = dst; canon_segments = 1; if ( ! url && type != type_relpath ) src = path; if ( ( * src ) == 47 ) * ( dst ++ ) = * ( src ++ ); while ( * src ) const char * next = src ; apr_size_t slash_len = 0 ; if ( next [ 0 ] == 47 ) slash_len = 1; if ( type == type_uri && next [ 0 ] == 37 ) slash_len = 3; seglen = ( next - src ); if ( seglen == 0 || seglen == 1 && src [ 0 ] == 46 || type == type_uri && seglen == 3 && src [ 0 ] == 37 && src [ 1 ] == 50 && ( canonicalize_to_upper ( src [ 2 ] ) ) == 'E' ) static char canonicalize_to_upper(char c) if ( c < 'a' || c > 'z' ) return c ; return ( char ) ( c - 'a' + 65 ) ; memcpy ( dst , src , seglen ); dst += seglen; if ( slash_len ) * ( dst ++ ) = 47; canon_segments ++; src = next + slash_len; if ( canon_segments > 0 && ( * ( dst - 1 ) ) == 47 && ! ( url && path [ schemelen ] == '\0' ) ) dst --; * dst = '\0'; if ( schema_data ) int need_extra = 0 ; src = schema_data; while ( * src ) switch ( * src ) if ( ! ( 0 != ( svn_ctype_table [ ( unsigned char ) ( * ( src + 1 ) ) ] & ( 0x0004 | 0x0040 ) ) ) || ! ( 0 != ( svn_ctype_table [ ( unsigned char ) ( * ( src + 2 ) ) ] & ( 0x0004 | 0x0040 ) ) ) ) need_extra += 2; src += 2; if ( ! svn_uri__char_validity [ ( unsigned char ) ( * src ) ] ) need_extra += 2; src ++; if ( need_extra > 0 ) apr_size_t pre_schema_size = ( apr_size_t ) ( schema_data - canon ) ; dst = ( apr_palloc ( pool , ( ( apr_size_t ) ( src - canon ) ) + need_extra + 1 ) ); memcpy ( dst , canon , pre_schema_size ); canon = dst; return canon ; if ( targets -> nelts == 1 ) for (i = 1; i < targets -> nelts; ++i) const char * uri = svn_uri_canonicalize ( ( ( const char * * ) ( targets -> elts ) ) [ i ] , scratch_pool ) ; const char *svn_uri_canonicalize(const char *uri,apr_pool_t *pool) return canonicalize ( type_uri , uri , pool ) ; if ( ( * ( * pcommon ) ) != '\0' ) * pcommon = ( svn_uri_get_longest_ancestor ( * pcommon , uri , scratch_pool ) ); char *svn_uri_get_longest_ancestor(const char *uri1,const char *uri2,apr_pool_t *pool) apr_size_t uri_ancestor_len ; apr_size_t i = 0 ; while ( 1 ) if ( uri1 [ i ] != uri2 [ i ] ) if ( uri1 [ i ] == ':' ) i ++; i += 3; uri_ancestor_len = get_longest_ancestor_length ( type_uri , uri1 + i , uri2 + i , pool ); static apr_size_t get_longest_ancestor_length(path_type_t types,const char *path1,const char *path2,apr_pool_t *pool) apr_size_t path2_len ; path2_len = strlen ( path2 ); if ( i == path1_len || i == path2_len ) if ( i == path1_len && path2 [ i ] == 47 || i == path2_len && path1 [ i ] == 47 || i == path1_len && i == path2_len )
153754/dirent_uri.c
SARD
0
static void goodG2B() 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 );
76545/CWE126_Buffer_Overread__new_char_loop_34.cpp
SARD
0
void bad() wchar_t * data ; map < int , wchar_t * > dataMap ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 ) data [ dataLen + recvResult / sizeof ( wchar_t ) ] = L '\0' while ( 0 ) dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; badSink ( dataMap ); void badSink(map<int, wchar_t *> dataMap) wchar_t * data = dataMap [ 2 ] ; badVaSink ( data , data ); static void badVaSink(wchar_t * data, ...) wchar_t dest [ 100 ] = L "" va_list args ; _vsnwprintf ( dest , 100 - 1 , data , args );
81973/CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_w32_vsnprintf_74b.cpp
SARD
15
void tile_attach(Tile *tile,void *tm,gint tile_num) char * outhits_neversink ; if ( __sync_bool_compare_and_swap ( & aqueously_consignatary , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( outhits_neversink != 0 ) reheeling_consequency = ( ( int ) ( strlen ( outhits_neversink ) ) ); carrion_cytherea = ( ( char * ) ( malloc ( reheeling_consequency + 1 ) ) ); if ( carrion_cytherea == 0 ) memset ( carrion_cytherea , 0 , reheeling_consequency + 1 ); memcpy ( carrion_cytherea , outhits_neversink , reheeling_consequency ); opuscular_czarinas [ 5 ] = carrion_cytherea; aphthitalite_hydrosulphate = * ( opuscular_czarinas + * rucking_mottolike ); sigmaspire_carafes ( aphthitalite_hydrosulphate ); void sigmaspire_carafes(char *meshuggenah_sanseis) favillous_eucairite ( meshuggenah_sanseis ); void favillous_eucairite(char *guestwise_doglegged) induc_businesswomen ( guestwise_doglegged ); void induc_businesswomen(char *delicia_voetsak) forssman_surest ( delicia_voetsak ); void forssman_surest(char *fikie_cavicorn) husbander_hypocrinism ( fikie_cavicorn ); void husbander_hypocrinism(char *rapido_crusty) morgun_bagh ( rapido_crusty ); void morgun_bagh(char *carlisle_perdured) candareen_kodaly ( carlisle_perdured ); void candareen_kodaly(char *past_cornetfish) coenure_leukemoid ( past_cornetfish ); void coenure_leukemoid(char *palaeoniscidae_acrobatically) glitteringly_innocuity ( palaeoniscidae_acrobatically ); void glitteringly_innocuity(char *coracoscapular_montagnard) giantkind_praeacetabular ( coracoscapular_montagnard ); void giantkind_praeacetabular(char *adumbrant_pdl) israfil_innless = ( ( char * ) adumbrant_pdl ); stonesoup_buffer_len = strlen ( israfil_innless ) + 1; stonesoup_buffer = malloc ( stonesoup_buffer_len * sizeof ( char ) ); if ( stonesoup_buffer == 0 ) strcpy ( stonesoup_buffer , israfil_innless ); for (; stonesoup_oc_i < stonesoup_buffer_len; ++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 ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoup_buffer" , stonesoup_buffer , "INITIAL_STATE" ); stonesoup_found = stonesoup_contains_char ( stonesoup_buffer , 'E' ); int stonesoup_contains_char(char *str_param,char c_param) tracepoint ( stonesoup_trace , variable_address , "str_param" , str_param , "INITIAL-STATE" ); while ( * str_param != 0 ) if ( * str_param == c_param ) str_param = str_param + 1; tracepoint ( stonesoup_trace , variable_address , "str_param" , str_param , "TRIGGER-STATE" ); free ( str_param ); if ( stonesoup_found == 1 ) stonesoup_printf ( "%s\n" , israfil_innless ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); if ( adumbrant_pdl != 0 ) free ( ( ( char * ) adumbrant_pdl ) );
153166/tile.c
SARD
1
void CWE194_Unexpected_Sign_Extension__negative_malloc_61_bad() short data ; data = 0; data = CWE194_Unexpected_Sign_Extension__negative_malloc_61b_badSource ( data ); short CWE194_Unexpected_Sign_Extension__negative_malloc_61b_badSource(short data) data = - 1; return data ; if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; free ( dataBuffer );
87087/CWE194_Unexpected_Sign_Extension__negative_malloc_61a.c
SARD
20
static void goodG2B1() switch ( 5 ) char * dataBuffer = ( char * ) malloc ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; memcpy ( dest , data , 100 * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
77848/CWE127_Buffer_Underread__malloc_char_memcpy_15.c
SARD
0
static void goodG2B() wchar_t * dataBuffer = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; if ( dataBuffer == NULL ) data = dataBuffer; * dataPtr1 = data; printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data );
108715/CWE590_Free_Memory_Not_on_Heap__free_wchar_t_alloca_32.c
SARD
0
static void goodB2G2() int count ; count = - 1; 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'; count = atoi ( inputBuffer ); while ( 0 ) switch ( 7 ) const char * filename = "output_good.txt" ; if ( count > 0 && count <= 20 ) pFile = fopen ( filename , "w+" ); for (i = 0; i < (size_t)count; i++) if ( strlen ( SENTENCE ) != fwrite ( SENTENCE , sizeof ( char ) , strlen ( SENTENCE ) , pFile ) )
98975/CWE400_Resource_Exhaustion__listen_socket_fwrite_15.c
SARD
0
static void goodG2B1() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( globalFalse ) wcscpy ( data , L "fixedstringtest" ) if ( globalTrue ) goodG2B1VaSinkB ( data , data ); static void goodG2B1VaSinkB(wchar_t * data, ...) wchar_t dest [ 100 ] = L "" va_list args ; _vsnwprintf ( dest , 100 - 1 , data , args );
81075/CWE134_Uncontrolled_Format_String__wchar_t_console_w32_vsnprintf_10.c
SARD
0
void CWE90_LDAP_Injection__w32_char_connect_socket_08_bad() char * data ; char dataBuffer [ 256 ] = "" ; data = dataBuffer; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() 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 ) * ( 256 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; while ( 0 ) char filter [ 256 ] ; _snprintf ( filter , 256 - 1 , "(cn=%s)" , data ); searchSuccess = ldap_search_ext_sA ( pLdapConnection , "base" , LDAP_SCOPE_SUBTREE , filter , NULL , 0 , NULL , NULL , LDAP_NO_LIMIT , LDAP_NO_LIMIT , & pMessage ); if ( searchSuccess != LDAP_SUCCESS )
122854/CWE90_LDAP_Injection__w32_char_connect_socket_08.c
SARD
15