func
stringlengths
181
23.6k
path
stringlengths
12
123
source
stringclasses
2 values
label
int64
0
40
static void goodG2B2() wchar_t * data ; data = NULL; if ( GLOBAL_CONST_TRUE ) 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 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data );
72088/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncat_09.c
SARD
0
void CWE665_Improper_Initialization__char_cat_10_bad() char * data ; char dataBuffer [ 100 ] ; data = dataBuffer; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcat ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
109761/CWE665_Improper_Initialization__char_cat_10.c
SARD
0
cgiFormResultType cgiCookies(char ***result) char * * stringArray ; int i ; int total = 0 ; char * p ; char * n ; p = cgiCookie; while ( * p ) if ( * p == '=' ) total ++; p ++; stringArray = ( char * * ) malloc ( sizeof ( char * ) * ( total + 1 ) ); if ( ! stringArray ) for (i=0; (i <= total); i++) stringArray [ i ] = 0; i = 0; p = cgiCookie; while ( * p ) while ( * p && isspace ( * p ) ) p ++; n = p; while ( * p && ( * p != '=' ) ) p ++; if ( p != n ) stringArray [ i ] = ( char * ) malloc ( ( p - n ) + 1 ); if ( ! stringArray [ i ] ) cgiStringArrayFree ( stringArray ); void cgiStringArrayFree(char **stringArray) char * * arrayItself = stringArray ; p = * stringArray; while ( p ) free ( p ); stringArray ++; p = * stringArray; free ( arrayItself ); memcpy ( stringArray [ i ] , n , p - n ); stringArray [ i ] [ p - n ] = '\0'; i ++; while ( * p && ( * p != ';' ) ) p ++; if ( ! * p ) if ( * p == ';' ) p ++; * result = stringArray;
149093/cgic.c
SARD
0
void bad() int i , j ; for(i = 0; i < 1; i++) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); 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
117479/CWE789_Uncontrolled_Mem_Alloc__new_char_connect_socket_17.cpp
SARD
10
void CWE197_Numeric_Truncation_Error__short_listen_socket_16_bad() while ( 1 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = ( short ) atoi ( inputBuffer ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); char charData = ( char ) data ; printHexCharLine ( charData ); void printHexCharLine (char charHex) printf ( "%02x\n" , charHex );
89391/CWE197_Numeric_Truncation_Error__short_listen_socket_16.c
SARD
20
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; data = goodB2GSource ( data ); static char * goodB2GSource(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 ) * ( 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 ); return data ;
80467/CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_42.c
SARD
0
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalFive == 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'; fclose ( pFile ); goodB2G2VaSinkG ( data , data ); static void goodB2G2VaSinkG(char * data, ...) va_start ( args , data );
80215/CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_14.c
SARD
0
svn_error_t *svn_cmdline__parse_config_option(apr_array_header_t *config_options,const char *opt_arg,apr_pool_t *pool) const char * first_colon ; if ( ( first_colon = ( strchr ( opt_arg , ':' ) ) ) && first_colon != opt_arg ) if ( ( second_colon = ( strchr ( first_colon + 1 , ':' ) ) ) && second_colon != first_colon + 1 ) if ( ( equals_sign = ( strchr ( second_colon + 1 , '=' ) ) ) && equals_sign != second_colon + 1 ) config_option -> file = ( apr_pstrndup ( pool , opt_arg , ( first_colon - opt_arg ) ) ); config_option -> section = ( apr_pstrndup ( pool , first_colon + 1 , ( second_colon - first_colon - 1 ) ) ); config_option -> option = ( apr_pstrndup ( pool , second_colon + 1 , ( equals_sign - second_colon - 1 ) ) ); if ( ! strchr ( config_option -> option , ':' ) ) config_option -> value = ( apr_pstrndup ( pool , equals_sign + 1 , ( opt_arg + len - equals_sign - 1 ) ) ); * ( ( svn_cmdline__config_argument_t * * ) ( apr_array_push ( config_options ) ) ) = config_option;
152703/cmdline.c
SARD
0
void CWE124_Buffer_Underwrite__char_declare_memcpy_13_bad() char dataBuffer [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer - 8; memcpy ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
74034/CWE124_Buffer_Underwrite__char_declare_memcpy_13.c
SARD
3
static void goodB2G() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
83430/CWE190_Integer_Overflow__int_listen_socket_add_41.c
SARD
0
void CWE78_OS_Command_Injection__wchar_t_environment_w32_spawnvp_53_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; size_t dataLen = wcslen ( data ) ; wcsncat ( data + dataLen , environment , 100 - dataLen - 1 ); CWE78_OS_Command_Injection__wchar_t_environment_w32_spawnvp_53b_badSink ( data ); void CWE78_OS_Command_Injection__wchar_t_environment_w32_spawnvp_53b_badSink(wchar_t * data) CWE78_OS_Command_Injection__wchar_t_environment_w32_spawnvp_53c_badSink ( data ); void CWE78_OS_Command_Injection__wchar_t_environment_w32_spawnvp_53c_badSink(wchar_t * data) CWE78_OS_Command_Injection__wchar_t_environment_w32_spawnvp_53d_badSink ( data ); void CWE78_OS_Command_Injection__wchar_t_environment_w32_spawnvp_53d_badSink(wchar_t * data)
121718/CWE78_OS_Command_Injection__wchar_t_environment_w32_spawnvp_53a.c
SARD
0
void badSink(map<int, char *> dataMap) 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 ); delete [ ] data
68379/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_memcpy_74b.cpp
SARD
3
static cgiParseResultType cgiParsePostMultipartInput() cgiParseResultType result ; int got ; char tfileName [ 1024 ] ; mpStreamPtr mpp = & mp ; if ( ! cgiContentLength ) result = afterNextBoundary ( mpp , 0 , 0 , 0 , 1 ); cgiParseResultType afterNextBoundary(mpStreamPtr mpp, FILE *outf, char int *bodyLengthP, int first) int outSpace = 256 ; cgiParseResultType result ; int boffset ; int got ; char d [ 2 ] ; char workingBoundaryData [ 1024 ] ; char * workingBoundary = workingBoundaryData ; int workingBoundaryLength ; if ( ( ! outf ) && ( outP ) ) out = ( char * ) malloc ( outSpace ); if ( ! out ) boffset = 0; sprintf ( workingBoundaryData , "\r\n--%s" , cgiMultipartBoundary ); if ( first ) workingBoundary = workingBoundaryData + 2; workingBoundaryLength = strlen ( workingBoundary ); while ( 1 ) got = mpRead ( mpp , d , 1 ); int mpRead(mpStreamPtr mpp, char *buffer, int len) int ilen = len ; int got = 0 ; if ( len > ( cgiContentLength - mpp -> offset ) ) len = cgiContentLength - mpp -> offset; while ( len ) if ( mpp -> readPos != mpp -> writePos ) * buffer ++ = mpp -> putback [ mpp -> readPos ++ ]; mpp -> readPos %= sizeof ( mpp -> putback ); got ++; len --; if ( len ) int fgot = fread ( buffer , 1 , len , cgiIn ) ; if ( fgot >= 0 ) return got + fgot ; if ( got > 0 ) return got ; return fgot ; if ( got ) return got ; if ( ilen ) return EOF ; return 0 ; if ( got != 1 ) result = cgiParseIO; if ( d [ 0 ] == workingBoundary [ boffset ] ) boffset ++; if ( boffset == workingBoundaryLength ) if ( boffset > 0 ) boffset = 0; got = mpRead ( mpp , d , 2 ); int mpRead(mpStreamPtr mpp, char *buffer, int len) int ilen = len ; int got = 0 ; if ( len > ( cgiContentLength - mpp -> offset ) ) len = cgiContentLength - mpp -> offset; while ( len ) if ( mpp -> readPos != mpp -> writePos ) * buffer ++ = mpp -> putback [ mpp -> readPos ++ ]; mpp -> readPos %= sizeof ( mpp -> putback ); got ++; len --; if ( len ) int fgot = fread ( buffer , 1 , len , cgiIn ) ; if ( fgot >= 0 ) return got + fgot ; if ( got > 0 ) return got ; return fgot ; if ( got ) return got ; if ( ilen ) return EOF ; return 0 ; if ( got != 2 ) result = cgiParseIO; return cgiParseSuccess ; result = cgiParseMemory; return result ; if ( result == cgiParseIO ) if ( result != cgiParseSuccess ) while ( 1 ) char d [ 1024 ] ; char fvalue [ 1024 ] ; char fname [ 1024 ] ; int bodyLength = 0 ; char ffileName [ 1024 ] ; char fcontentType [ 1024 ] ; out = 0; got = mpRead ( mpp , d , 2 ); int mpRead(mpStreamPtr mpp, char *buffer, int len) int ilen = len ; int got = 0 ; if ( len > ( cgiContentLength - mpp -> offset ) ) len = cgiContentLength - mpp -> offset; while ( len ) if ( mpp -> readPos != mpp -> writePos ) * buffer ++ = mpp -> putback [ mpp -> readPos ++ ]; mpp -> readPos %= sizeof ( mpp -> putback ); got ++; len --; if ( len ) int fgot = fread ( buffer , 1 , len , cgiIn ) ; if ( fgot >= 0 ) return got + fgot ; if ( got > 0 ) return got ; return fgot ; if ( got ) return got ; if ( ilen ) return EOF ; return 0 ; if ( got < 2 ) if ( ( d [ 0 ] == '-' ) && ( d [ 1 ] == '-' ) ) if ( ! cgiStrEqNc ( fvalue , "form-data" ) ) static int cgiStrEqNc(char *s1, char *s2) while ( 1 ) if ( ! ( * s1 ) ) if ( ! ( * s2 ) ) return 1 ; return 0 ; if ( ! ( * s2 ) ) return 0 ; if ( isalpha ( * s1 ) ) if ( tolower ( * s1 ) != tolower ( * s2 ) ) return 0 ; if ( ( * s1 ) != ( * s2 ) ) return 0 ; s1 ++; s2 ++; result = afterNextBoundary ( mpp , 0 , 0 , 0 , 0 ); cgiParseResultType afterNextBoundary(mpStreamPtr mpp, FILE *outf, char int *bodyLengthP, int first) int outSpace = 256 ; cgiParseResultType result ; int boffset ; int got ; char d [ 2 ] ; char workingBoundaryData [ 1024 ] ; char * workingBoundary = workingBoundaryData ; int workingBoundaryLength ; if ( ( ! outf ) && ( outP ) ) out = ( char * ) malloc ( outSpace ); if ( ! out ) boffset = 0; sprintf ( workingBoundaryData , "\r\n--%s" , cgiMultipartBoundary ); if ( first ) workingBoundary = workingBoundaryData + 2; workingBoundaryLength = strlen ( workingBoundary ); while ( 1 ) got = mpRead ( mpp , d , 1 ); if ( got != 1 ) result = cgiParseIO; if ( d [ 0 ] == workingBoundary [ boffset ] ) boffset ++; if ( boffset == workingBoundaryLength ) if ( boffset > 0 ) boffset = 0; got = mpRead ( mpp , d , 2 ); if ( got != 2 ) result = cgiParseIO; return cgiParseSuccess ; result = cgiParseMemory; return result ; if ( result != cgiParseSuccess ) if ( strlen ( ffileName ) ) if ( getTempFileName ( tfileName ) != cgiParseSuccess ) outf = fopen ( tfileName , "w+b" ); outf = 0; tfileName [ 0 ] = '\0'; result = afterNextBoundary ( mpp , outf , & out , & bodyLength , 0 ); cgiParseResultType afterNextBoundary(mpStreamPtr mpp, FILE *outf, char int *bodyLengthP, int first) int outSpace = 256 ; cgiParseResultType result ; int boffset ; int got ; char d [ 2 ] ; char workingBoundaryData [ 1024 ] ; char * workingBoundary = workingBoundaryData ; int workingBoundaryLength ; if ( ( ! outf ) && ( outP ) ) out = ( char * ) malloc ( outSpace ); if ( ! out ) boffset = 0; sprintf ( workingBoundaryData , "\r\n--%s" , cgiMultipartBoundary ); if ( first ) workingBoundary = workingBoundaryData + 2; workingBoundaryLength = strlen ( workingBoundary ); while ( 1 ) got = mpRead ( mpp , d , 1 ); if ( got != 1 ) result = cgiParseIO; if ( d [ 0 ] == workingBoundary [ boffset ] ) boffset ++; if ( boffset == workingBoundaryLength ) if ( boffset > 0 ) boffset = 0; got = mpRead ( mpp , d , 2 ); if ( got != 2 ) result = cgiParseIO; return cgiParseSuccess ; result = cgiParseMemory; return result ; if ( result != cgiParseSuccess ) n = ( cgiFormEntry * ) malloc ( sizeof ( cgiFormEntry ) ); if ( ! n ) memset ( n , 0 , sizeof ( cgiFormEntry ) ); n -> attr = ( char * ) malloc ( strlen ( fname ) + 1 ); if ( ! n -> attr ) if ( out ) if ( outf ) n -> value = ( char * ) malloc ( 1 ); if ( ! n -> value ) n -> value [ 0 ] = '\0'; n -> valueLength = bodyLength; n -> next = 0; n -> fileName = ( char * ) malloc ( strlen ( ffileName ) + 1 ); if ( ! n -> fileName ) strcpy ( n -> fileName , ffileName ); n -> contentType = ( char * ) malloc ( strlen ( fcontentType ) + 1 ); if ( ! n -> contentType ) strcpy ( n -> contentType , fcontentType ); n -> tfileName = ( char * ) malloc ( strlen ( tfileName ) + 1 ); if ( ! n -> tfileName ) static cgiParseResultType getTempFileName(char *tfileName) int outfd ; strcpy ( tfileName , cgicTempDir "/cgicXXXXXX" ) outfd = mkstemp ( tfileName ); if ( outfd == - 1 ) close ( outfd );
149093/cgic.c
SARD
0
static void goodG2B() wchar_t * data ; map < int , wchar_t * > dataMap ; data = NULL; wchar_t * dataBuffer = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer; dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; goodG2BSink ( dataMap ); void goodG2BSink(map<int, wchar_t *> dataMap) wchar_t * data = dataMap [ 2 ] ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcsncpy ( data , source , 100 - 1 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line )
74713/CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_74b.cpp
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 ); static status_transit_state transit_state_singlebyte(struct dfa *d,state_num s,const unsigned char *p,state_num *next_state) state_num * t ; state_num works = s ; status_transit_state rval = TRANSIT_STATE_IN_PROGRESS ; while ( rval == TRANSIT_STATE_IN_PROGRESS ) if ( ( t = d -> trans [ works ] ) != ( ( void * ) 0 ) ) works = t [ * p ]; rval = TRANSIT_STATE_DONE; if ( works < 0 ) works = 0; if ( works < 0 ) works = 0; if ( d -> fails [ works ] ) works = d -> fails [ works ] [ * p ]; rval = TRANSIT_STATE_DONE; return rval ; 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 ) strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> coll_elems [ i ] , buffer ) == 0 )
150042/dfa.c
SARD
0
void bad() int * data ; int * * dataPtr2 = & data ; data = NULL; data = new int [ 50 ]; int * data = * dataPtr2 ; int source [ 100 ] = { 0 } ; memcpy ( data , source , 100 * sizeof ( int ) ); printIntLine ( data [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); delete [ ] data
68933/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_int_memcpy_32.cpp
SARD
3
void CWE134_Uncontrolled_Format_String__char_listen_socket_w32_vsnprintf_17_bad() int i , j ; char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; for(i = 0; i < 1; i++) 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 ) for(j = 0; j < 1; j++) badVaSinkB ( data , data ); static void badVaSinkB(char * data, ...) char dest [ 100 ] = "" ; va_list args ; vsnprintf ( dest , 100 - 1 , data , args ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
80506/CWE134_Uncontrolled_Format_String__char_listen_socket_w32_vsnprintf_17.c
SARD
15
static void goodG2B() twoIntsStruct * data ; data = NULL; data = ( twoIntsStruct * ) malloc ( 100 * sizeof ( twoIntsStruct ) ); CWE122_Heap_Based_Buffer_Overflow__c_CWE805_struct_memcpy_53b_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_struct_memcpy_53b_goodG2BSink(twoIntsStruct * data) CWE122_Heap_Based_Buffer_Overflow__c_CWE805_struct_memcpy_53c_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_struct_memcpy_53c_goodG2BSink(twoIntsStruct * data) CWE122_Heap_Based_Buffer_Overflow__c_CWE805_struct_memcpy_53d_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_struct_memcpy_53d_goodG2BSink(twoIntsStruct * data) twoIntsStruct source [ 100 ] ; size_t i ; for (i = 0; i < 100; i++) source [ i ] . intOne = 0; source [ i ] . intTwo = 0; memcpy ( data , source , 100 * sizeof ( twoIntsStruct ) ); printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); free ( data );
71871/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_struct_memcpy_53d.c
SARD
0
static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) state_num s1 ; int mbclen ; int maxlen = 0 ; size_t i ; size_t nelem = d -> states [ s ] . mbps . nelem ; position_set follows ; const unsigned char * p1 = * pp ; wchar_t wc ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; int constraint ; state_num i ; state_num j ; for (i = 0; i < s -> nelem; ++i) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; for (i = 0; i < d -> sindex; ++i) if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( j == s -> nelem ) return i ; if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; while ( 0 ) d -> states [ i ] . hash = hash; d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; if ( 1 ) d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); for (j = 0; j < s -> nelem; ++j) if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; return i ; while ( * pp - p1 < maxlen ) transit_state_consume_1char ( d , s1 , pp , ( ( void * ) 0 ) , & mbclen , & follows ); wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; int constraint ; state_num i ; state_num j ; hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( j == s -> nelem ) return i ; if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; while ( 0 ) d -> states [ i ] . hash = hash; d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; if ( 1 ) d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; return i ; 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 ; 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'; strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> equivs [ i ] , buffer ) == 0 )
151282/dfa.c
SARD
0
static void goodG2B1() char dataBuffer [ 100 ] ; 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 );
77532/CWE127_Buffer_Underread__char_declare_memcpy_11.c
SARD
0
static void goodG2B() wchar_t * data ; wchar_t * dataBuffer = ( wchar_t * ) ALLOCA ( 100 * sizeof ( wchar_t ) ) ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer; CWE124_Buffer_Underwrite__wchar_t_alloca_memmove_63b_goodG2BSink ( & data ); void CWE124_Buffer_Underwrite__wchar_t_alloca_memmove_63b_goodG2BSink(wchar_t * * dataPtr) wchar_t * data = * dataPtr ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memmove ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line )
75347/CWE124_Buffer_Underwrite__wchar_t_alloca_memmove_63b.c
SARD
0
void CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memmove_16_bad() int data ; data = - 1; while ( 1 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) 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 );
88125/CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memmove_16.c
SARD
20
void velveted_johnsonville(union napping_malpraxis cushlamochree_ord) ogdon_melbeta = ( ( char * ) cushlamochree_ord . vatful_metaline ); stonesoup_random_data = fopen ( "/dev/urandom" , "r" ); if ( stonesoup_random_data != NULL ) stonesoup_num = strtoull ( ogdon_melbeta , NULL , 10 ); if ( stonesoup_num > ( unsigned long long ) 0 ) if ( stonesoup_num > ( unsigned long long ) 100 ) stonesoup_num = ( unsigned long long ) 100; stonesoup_buff = malloc ( ( stonesoup_num - ( unsigned long long ) 10 ) * sizeof ( char * ) ); for(stonesoup_i = 0; stonesoup_i < stonesoup_num - (unsigned long long) 10; stonesoup_i++) stonesoup_buff [ stonesoup_i ] = fgetc ( stonesoup_random_data ); stonesoup_printf ( "data is: %s" , stonesoup_buff ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); mg_vprintf_data ( ( struct mg_connection * ) stonesoup_printf_context , format , argptr ); if ( stonesoup_buff != NULL ) free ( stonesoup_buff );
151060/tile-swap.c
SARD
17
void CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_ncpy_15_bad() wchar_t * data ; data = NULL; switch ( 6 ) data = ( wchar_t * ) malloc ( 10 * sizeof ( wchar_t ) ); wchar_t source [ 10 + 1 ] = SRC_STRING ; wcsncpy ( data , source , wcslen ( source ) + 1 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data );
71182/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_ncpy_15.c
SARD
3
void CWE606_Unchecked_Loop_Condition__char_environment_13_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( GLOBAL_CONST_FIVE == 5 ) size_t dataLen = strlen ( data ) ; char * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) strncat ( data + dataLen , environment , 100 - dataLen - 1 ); if ( sscanf ( data , "%d" , & n ) == 1 )
109038/CWE606_Unchecked_Loop_Condition__char_environment_13.c
SARD
0
void CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memmove_41_badSink(int data) 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 );
87750/CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memmove_41.c
SARD
20
void CWE197_Numeric_Truncation_Error__short_connect_socket_15_bad() switch ( 6 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
89198/CWE197_Numeric_Truncation_Error__short_connect_socket_15.c
SARD
0
static void goodB2G1() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( STATIC_CONST_TRUE ) size_t dataLen = wcslen ( data ) ; wchar_t * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) wcsncat ( data + dataLen , environment , 100 - dataLen - 1 ); wprintf ( L "%s\n" , data )
81165/CWE134_Uncontrolled_Format_String__wchar_t_environment_printf_04.c
SARD
0
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfamust ( d ); static void dfamust(struct dfa *d) must * musts ; must * mp ; size_t ri ; size_t i ; token t ; static must must0 ; musts = ( ( sizeof ( ( * musts ) ) == 1 ? xmalloc ( d -> tindex + 1 ) : xnmalloc ( d -> tindex + 1 , sizeof ( ( * musts ) ) ) ) ); while ( 0 ) mp = musts; for (i = 0; i <= d -> tindex; ++i) mp [ i ] = must0; for (i = 0; i <= d -> tindex; ++i) mp [ i ] . in = ( xmalloc ( sizeof ( ( * mp [ i ] . in ) ) ) ); mp [ i ] . left = ( xmalloc ( 2 ) ); mp [ i ] . right = ( xmalloc ( 2 ) ); mp [ i ] . is = ( xmalloc ( 2 ) ); mp [ i ] . left [ 0 ] = mp [ i ] . right [ 0 ] = mp [ i ] . is [ 0 ] = '\0'; mp [ i ] . in [ 0 ] = ( ( void * ) 0 ); for (ri = 0; ri < d -> tindex; ++ri) switch ( t = d -> tokens [ ri ] ) resetmust ( mp ); must * lmp ; must * rmp ; size_t j ; size_t ln ; rmp = -- mp; lmp = -- mp; if ( ! ( strcmp ( ( lmp -> is ) , ( rmp -> is ) ) == 0 ) ) lmp -> is [ 0 ] = '\0'; i = 0; lmp -> left [ i ] = '\0'; ln = strlen ( ( lmp -> right ) ); for (j = 0; j < i; ++j) lmp -> right [ j ] = lmp -> right [ ln - i + j ]; lmp -> right [ j ] = '\0'; mp -> is [ 0 ] = '\0'; must * lmp ; must * rmp ; rmp = -- mp; lmp = -- mp; lmp -> in = addlists ( lmp -> in , rmp -> in ); if ( lmp -> in == ( ( void * ) 0 ) ) if ( lmp -> right [ 0 ] != '\0' && rmp -> left [ 0 ] != '\0' ) char * tp ; tp = icpyalloc ( ( lmp -> right ) ); tp = icatalloc ( tp , ( rmp -> left ) ); lmp -> in = enlist ( lmp -> in , tp , strlen ( tp ) ); if ( lmp -> in == ( ( void * ) 0 ) ) if ( lmp -> is [ 0 ] != '\0' ) lmp -> left = icatalloc ( lmp -> left , ( rmp -> left ) ); if ( lmp -> left == ( ( void * ) 0 ) ) if ( rmp -> is [ 0 ] == '\0' ) lmp -> right [ 0 ] = '\0'; lmp -> right = icatalloc ( lmp -> right , ( rmp -> right ) ); if ( lmp -> right == ( ( void * ) 0 ) ) if ( lmp -> is [ 0 ] != '\0' && rmp -> is [ 0 ] != '\0' ) lmp -> is = icatalloc ( lmp -> is , ( rmp -> is ) ); if ( lmp -> is == ( ( void * ) 0 ) ) lmp -> is [ 0 ] = '\0'; if ( t < END ) if ( t == '\0' ) if ( t >= CSET || ! 1 || t == ANYCHAR || t == MBCSET ) mp -> is [ 0 ] = mp -> left [ 0 ] = mp -> right [ 0 ] = t; mp -> is [ 1 ] = mp -> left [ 1 ] = mp -> right [ 1 ] = '\0'; mp -> in = enlist ( mp -> in , mp -> is , ( ( size_t ) 1 ) ); if ( mp -> in == ( ( void * ) 0 ) ) static void resetmust(must *mp) mp -> left [ 0 ] = mp -> right [ 0 ] = mp -> is [ 0 ] = '\0'; freelist ( mp -> in ); static void freelist(char **cpp) size_t i ; if ( cpp == ( ( void * ) 0 ) ) for (i = 0; cpp[i] != ((void *)0); ++i) free ( cpp [ i ] ); cpp [ i ] = ( ( void * ) 0 );
152020/dfa.c
SARD
0
void CWE606_Unchecked_Loop_Condition__char_console_42_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; data = badSource ( data ); static char * badSource(char * data) size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; data [ dataLen ] = '\0'; return data ;
109003/CWE606_Unchecked_Loop_Condition__char_console_42.c
SARD
0
static void goodB2G2() void * data ; data = NULL; if ( GLOBAL_CONST_TRUE ) data = ( void * ) WIDE_STRING; if ( GLOBAL_CONST_TRUE ) size_t dataLen = wcslen ( ( wchar_t * ) data ) ; void * dest = ( void * ) calloc ( dataLen + 1 , sizeof ( wchar_t ) ) ; memcpy ( dest , data , ( dataLen + 1 ) * sizeof ( wchar_t ) ); printWLine ( ( wchar_t * ) dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( dest );
62956/CWE121_Stack_Based_Buffer_Overflow__CWE135_09.c
SARD
0
void CWE121_Stack_Based_Buffer_Overflow__CWE193_char_declare_cpy_08_bad() char * data ; char dataBadBuffer [ 10 ] ; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; data = dataBadBuffer; data [ 0 ] = '\0'; char source [ 10 + 1 ] = SRC_STRING ; strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
63239/CWE121_Stack_Based_Buffer_Overflow__CWE193_char_declare_cpy_08.c
SARD
3
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) if ( ! d -> tralloc ) build_state_zero ( d ); static void build_state_zero(struct dfa *d) d -> tralloc = 1; d -> trcount = 0; d -> realtrans = ( ( sizeof ( ( * d -> realtrans ) ) == 1 ? xzalloc ( ( d -> tralloc + 1 ) ) : xcalloc ( ( d -> tralloc + 1 ) , sizeof ( ( * d -> realtrans ) ) ) ) ); while ( 0 ) d -> trans = d -> realtrans + 1; d -> fails = ( ( sizeof ( ( * d -> fails ) ) == 1 ? xzalloc ( ( d -> tralloc ) ) : xcalloc ( ( d -> tralloc ) , sizeof ( ( * d -> fails ) ) ) ) ); while ( 0 ) d -> success = ( ( sizeof ( ( * d -> success ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> success ) ) ) ) ); while ( 0 ) d -> newlines = ( ( sizeof ( ( * d -> newlines ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> newlines ) ) ) ) ); while ( 0 ) build_state ( 0 , d ); static void build_state(state_num s,struct dfa *d) state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) free ( d -> trans [ i ] ); d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 );
152027/dfa.c
SARD
0
void bad() wchar_t * data ; unionType myUnion ; data = NULL; wchar_t * dataBuffer = new wchar_t [ 100 ] ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer - 8; myUnion . unionFirst = data; wchar_t * data = myUnion . unionSecond ; 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 )
74981/CWE124_Buffer_Underwrite__new_wchar_t_cpy_34.cpp
SARD
3
static void goodB2G2() if ( globalFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); 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
117620/CWE789_Uncontrolled_Mem_Alloc__new_char_listen_socket_14.cpp
SARD
0
void bad() size_t data ; data = 0; char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = strtoul ( inputBuffer , NULL , 0 ); badSink_b ( data ); void badSink_b(size_t data) badSink_c ( data ); void badSink_c(size_t data) 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
117541/CWE789_Uncontrolled_Mem_Alloc__new_char_fgets_52c.cpp
SARD
10
static void goodB2G() int i , k ; for(i = 0; i < 1; i++) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = ( float ) atof ( inputBuffer ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); if ( fabs ( data ) > 0.000001 ) int result = ( int ) ( 100.0 / data ) ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber );
94834/CWE369_Divide_by_Zero__float_listenSocket_17.c
SARD
0
static void goodG2B2() int data ; data = - 1; if ( STATIC_CONST_TRUE ) 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 );
88161/CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_strncpy_04.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 ) ) 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 ( ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2_or_port2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2_or_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_set_port2 ( conversation , port_a ); void conversation_set_port2(conversation_t *conv,const guint32 port) ( void ) ( ! ( conv -> options & 0x08 ) ? ( ( void ) 0 ) : ( ( getenv ( "WIRESHARK_ABORT_ON_DISSECTOR_BUG" ) != ( ( void * ) 0 ) ? abort ( ) : except_throw ( 1 , 4 , ( ep_strdup_printf ( "%s:%u: failed assertion \"%s\" (%s)" , "conversation.c" , 680 , "!(conv->options & 0x08)" , "Use the conversation_create_from_template function when the CONVERSATION_TEMPLATE bit is set in the options mask" ) ) ) ) ) );
149895/conversation.c
SARD
0
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 )
80318/CWE134_Uncontrolled_Format_String__char_listen_socket_printf_31.c
SARD
0
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; 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 );
80212/CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_11.c
SARD
0
int avcodec_decode_audio3(AVCodecContext *avctx,int16_t *samples,int *frame_size_ptr,AVPacket *avpkt) int ret ; if ( avctx -> get_buffer != avcodec_default_get_buffer ) avctx -> get_buffer = avcodec_default_get_buffer; avctx -> release_buffer = avcodec_default_release_buffer; ret = avcodec_decode_audio4 ( avctx , & frame , & got_frame , avpkt ); int avcodec_decode_audio4(AVCodecContext *avctx,AVFrame *frame,int *got_frame_ptr,const AVPacket *avpkt) if ( ! avpkt -> data && avpkt -> size ) if ( ( avctx -> codec -> type ) != AVMEDIA_TYPE_AUDIO ) avcodec_get_frame_defaults ( frame ); void avcodec_get_frame_defaults(AVFrame *frame) memset ( frame , 0 , sizeof ( AVFrame ) ); frame -> pts = frame -> pkt_dts = frame -> pkt_pts = ( ( int64_t ) 0x8000000000000000UL ); av_frame_set_best_effort_timestamp ( frame , ( ( int64_t ) 0x8000000000000000UL ) ); av_frame_set_pkt_duration ( frame , 0 ); av_frame_set_pkt_pos ( frame , ( - 1 ) ); av_frame_set_pkt_size ( frame , - 1 ); frame -> key_frame = 1; frame -> format = - 1; frame -> extended_data = frame -> data;
149785/utils.c
SARD
0
void contradictorily_versemen(char **symmelian_precautiousness) char query [ 1000 ] ; transliterates_soldiery = ( ( char * ) symmelian_precautiousness [ 54 ] ); dbhost = getenv ( "DBPGHOST" ); dbuser = getenv ( "DBPGUSER" ); dbpassword = getenv ( "DBPGPASSWORD" ); dbport = getenv ( "DBPGPORT" ); dbdatabase = getenv ( "SS_DBPGDATABASE" ); if ( dbhost != 0 && dbport != 0 && dbuser != 0 && dbpassword != 0 && dbdatabase != 0 ) snprintf ( query , 1000 , "SELECT * FROM customers WHERE \"country\" = '%s';" , transliterates_soldiery ); tracepoint ( stonesoup_trace , variable_buffer , "query" , query , "CROSSOVER-STATE" ); res = PQexec ( conn , query ); if ( PQresultStatus ( res ) != 2 ) PQclear ( res ); stonesoup_nFields = PQnfields ( res ); for (stonesoup_i = 0; stonesoup_i < stonesoup_nFields; stonesoup_i++) stonesoup_printf ( "%-15s" , PQfname ( res , stonesoup_i ) ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); for (stonesoup_i = 0; stonesoup_i < PQntuples(res); stonesoup_i++) for (stonesoup_j = 0; stonesoup_j < stonesoup_nFields; stonesoup_j++) stonesoup_printf ( "%-15s" , PQgetvalue ( res , stonesoup_i , stonesoup_j ) ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); PQclear ( res );
152243/gimpcontext.c
SARD
15
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( STATIC_CONST_FIVE == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( sscanf ( data , "%d" , & n ) == 1 )
108935/CWE606_Unchecked_Loop_Condition__char_connect_socket_06.c
SARD
0
void CWE121_Stack_Based_Buffer_Overflow__CWE805_int_alloca_memcpy_31_bad() int * data ; int * dataBadBuffer = ( int * ) ALLOCA ( 50 * sizeof ( int ) ) ; data = dataBadBuffer; int * dataCopy = data ; int * data = dataCopy ; int source [ 100 ] = { 0 } ; memcpy ( data , source , 100 * sizeof ( int ) ); printIntLine ( data [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber );
64610/CWE121_Stack_Based_Buffer_Overflow__CWE805_int_alloca_memcpy_31.c
SARD
3
status_t MPEG4Extractor::parseMetaData(off64_t offset, size_t size) if ( size < 4 ) uint8_t * buffer = new uint8_t [ size + 1 ] ; if ( mDataSource -> readAt ( offset , buffer , size ) != ( ssize_t ) size ) buffer = NULL; uint32_t flags = U32_AT ( buffer ) ; uint32_t metadataKey = 0 ; metadataKey = kKeyAlbum; metadataKey = kKeyArtist; metadataKey = kKeyAlbumArtist; metadataKey = kKeyYear; metadataKey = kKeyTitle; metadataKey = kKeyWriter; metadataKey = kKeyAlbumArt; metadataKey = kKeyGenre; metadataKey = kKeyGenre; buffer [ size ] = '\0'; if ( size >= 8 && metadataKey ) if ( metadataKey == kKeyAlbumArt ) if ( metadataKey == kKeyGenre ) if ( flags == 0 ) int genrecode = ( int ) buffer [ size - 1 ] ; genrecode --; if ( genrecode < 0 ) genrecode = 255; char genre [ 10 ] ; sprintf ( genre , "%d" , genrecode ); mFileMetaData -> setCString ( metadataKey , genre );
CVE-2015-0829/Firefox_35.0b8_CVE_2015_0829_media_libstagefright_frameworks_av_media_libstagefright_MPEG4Extractor.cpp
NVD
0
void CWE134_Uncontrolled_Format_String__wchar_t_environment_vprintf_53_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; size_t dataLen = wcslen ( data ) ; wchar_t * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) wcsncat ( data + dataLen , environment , 100 - dataLen - 1 ); CWE134_Uncontrolled_Format_String__wchar_t_environment_vprintf_53b_badSink ( data ); void CWE134_Uncontrolled_Format_String__wchar_t_environment_vprintf_53b_badSink(wchar_t * data) CWE134_Uncontrolled_Format_String__wchar_t_environment_vprintf_53c_badSink ( data ); void CWE134_Uncontrolled_Format_String__wchar_t_environment_vprintf_53c_badSink(wchar_t * data) CWE134_Uncontrolled_Format_String__wchar_t_environment_vprintf_53d_badSink ( data ); void CWE134_Uncontrolled_Format_String__wchar_t_environment_vprintf_53d_badSink(wchar_t * data) badVaSink ( data , data ); static void badVaSink(wchar_t * data, ...) va_start ( args , data ); vwprintf ( data , args );
81337/CWE134_Uncontrolled_Format_String__wchar_t_environment_vprintf_53a.c
SARD
0
static int init_input(AVFormatContext *s,const char *filename,AVDictionary **options) if ( s -> pb ) s -> flags |= 0x80; if ( ! s -> iformat ) return av_probe_input_buffer ( s -> pb , & s -> iformat , filename , s , 0 , s -> probesize ) ; int av_probe_input_buffer(AVIOContext *pb,AVInputFormat **fmt,const char *filename,void *logctx,unsigned int offset,unsigned int max_probe_size) uint8_t * mime_type ; if ( ! max_probe_size ) max_probe_size = ( 1 << 20 ); if ( max_probe_size > ( 1 << 20 ) ) max_probe_size = ( 1 << 20 ); if ( max_probe_size < 2048 ) if ( offset >= max_probe_size ) if ( ! ( * fmt ) && pb -> av_class && av_opt_get ( pb , "mime_type" , 0x1 , & mime_type ) >= 0 && mime_type ) if ( ! av_strcasecmp ( mime_type , "audio/aacp" ) ) * fmt = av_find_input_format ( "aac" ); AVInputFormat *av_find_input_format(const char *short_name) AVInputFormat * fmt = ( ( void * ) 0 ) ; while ( fmt = av_iformat_next ( fmt ) ) if ( match_format ( short_name , fmt -> name ) ) static int match_format(const char *name,const char *names) int namelen ; if ( ! name || ! names ) namelen = ( strlen ( name ) ); len = ( ( p - names > namelen ? p - names : namelen ) ); if ( ! av_strncasecmp ( name , names , len ) )
152151/utils.c
SARD
0
static int xhci_complete_packet(XHCITransfer *xfer) if ( xfer -> packet . status == USB_RET_ASYNC ) if ( xfer -> packet . status == USB_RET_NAK ) xfer -> running_async = 0; xfer -> running_retry = 0; xfer -> complete = 1; if ( xfer -> packet . status == USB_RET_SUCCESS ) xfer -> status = CC_SUCCESS; switch ( xfer -> packet . status ) xfer -> status = CC_STALL_ERROR; xhci_stall_ep ( xfer ); static void xhci_stall_ep(XHCITransfer *xfer) XHCIState * xhci = xfer -> xhci ; XHCISlot * slot = & xhci -> slots [ xfer -> slotid - 1 ] ; XHCIEPContext * epctx = slot -> eps [ xfer -> epid - 1 ] ; XHCIStreamContext * sctx ; if ( epctx -> nr_pstreams ) sctx = xhci_find_stream ( epctx , xfer -> streamid , & err ); static XHCIStreamContext *xhci_find_stream(XHCIEPContext unsigned int uint32_t *cc_error) XHCIStreamContext * sctx ; uint32_t ctx [ 2 ] , sct ; if ( epctx -> lsa ) if ( streamid >= epctx -> nr_pstreams ) sctx = epctx -> pstreams + streamid; if ( sctx -> sct == - 1 ) xhci_dma_read_u32s ( epctx -> xhci , sctx -> pctx , ctx , sizeof ( ctx ) ); static inline void xhci_dma_read_u32s(XHCIState *xhci, dma_addr_t uint32_t *buf, size_t len) assert ( ( len % sizeof ( uint32_t ) ) == 0 );
CVE-2016-7466/qemu_2.3.0_CVE-2016-7466_hcd-xhci.c
NVD
0
void hemoclasis_fidley(char *hedgehogs_confustication) long stonesoup_number ; unthroaty_relocating = ( ( char * ) hedgehogs_confustication ); stonesoup_number = strtol ( unthroaty_relocating , 0U , 10 ); if ( stonesoup_number > 0 ) stonesoup_data = stonesoup_init_data ( stonesoup_number ); struct stonesoup_struct_data *stonesoup_init_data(long number_param) init_data_ptr = ( ( struct stonesoup_struct_data * ) ( malloc ( sizeof ( struct stonesoup_struct_data ) ) ) ); if ( init_data_ptr == 0 ) init_data_ptr -> size_member = 0; init_data_ptr -> size_member = number_param; init_data_ptr -> buffer_member = ( ( char * ) ( malloc ( sizeof ( char ) * init_data_ptr -> size_member ) ) ); if ( init_data_ptr -> buffer_member == 0 ) free ( init_data_ptr );
150880/hashfn.c
SARD
0
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfamust ( d ); static void dfamust(struct dfa *d) must * musts ; must * mp ; char * result ; size_t ri ; size_t i ; int exact ; token t ; static must must0 ; struct dfamust * dm ; static char empty_string [ ] = "" ; result = empty_string; exact = 0; musts = ( ( sizeof ( ( * musts ) ) == 1 ? xmalloc ( d -> tindex + 1 ) : xnmalloc ( d -> tindex + 1 , sizeof ( ( * musts ) ) ) ) ); while ( 0 ) mp = musts; for (i = 0; i <= d -> tindex; ++i) mp [ i ] = must0; for (i = 0; i <= d -> tindex; ++i) mp [ i ] . in = ( xmalloc ( sizeof ( ( * mp [ i ] . in ) ) ) ); mp [ i ] . left = ( xmalloc ( 2 ) ); mp [ i ] . right = ( xmalloc ( 2 ) ); mp [ i ] . is = ( xmalloc ( 2 ) ); mp [ i ] . left [ 0 ] = mp [ i ] . right [ 0 ] = mp [ i ] . is [ 0 ] = '\0'; mp [ i ] . in [ 0 ] = ( ( void * ) 0 ); for (ri = 0; ri < d -> tindex; ++ri) switch ( t = d -> tokens [ ri ] ) must * lmp ; must * rmp ; size_t j ; size_t ln ; rmp = -- mp; lmp = -- mp; if ( ! ( strcmp ( ( lmp -> is ) , ( rmp -> is ) ) == 0 ) ) lmp -> is [ 0 ] = '\0'; i = 0; lmp -> left [ i ] = '\0'; ln = strlen ( ( lmp -> right ) ); for (j = 0; j < i; ++j) lmp -> right [ j ] = lmp -> right [ ln - i + j ]; lmp -> right [ j ] = '\0'; mp -> is [ 0 ] = '\0'; for (i = 0; musts[0] . in[i] != ((void *)0); ++i) if ( strlen ( musts [ 0 ] . in [ i ] ) > strlen ( result ) ) result = musts [ 0 ] . in [ i ]; if ( strcmp ( result , musts [ 0 ] . is ) == 0 ) exact = 1; must * lmp ; must * rmp ; rmp = -- mp; lmp = -- mp; lmp -> in = addlists ( lmp -> in , rmp -> in ); if ( lmp -> in == ( ( void * ) 0 ) ) if ( lmp -> right [ 0 ] != '\0' && rmp -> left [ 0 ] != '\0' ) char * tp ; tp = icpyalloc ( ( lmp -> right ) ); static char *icpyalloc(const char *string) return icatalloc ( ( ( void * ) 0 ) , string ) ; tp = icatalloc ( tp , ( rmp -> left ) ); lmp -> in = enlist ( lmp -> in , tp , strlen ( tp ) ); if ( lmp -> in == ( ( void * ) 0 ) ) if ( lmp -> is [ 0 ] != '\0' ) lmp -> left = icatalloc ( lmp -> left , ( rmp -> left ) ); if ( lmp -> left == ( ( void * ) 0 ) ) if ( rmp -> is [ 0 ] == '\0' ) lmp -> right [ 0 ] = '\0'; lmp -> right = icatalloc ( lmp -> right , ( rmp -> right ) ); if ( lmp -> right == ( ( void * ) 0 ) ) if ( lmp -> is [ 0 ] != '\0' && rmp -> is [ 0 ] != '\0' ) lmp -> is = icatalloc ( lmp -> is , ( rmp -> is ) ); if ( lmp -> is == ( ( void * ) 0 ) ) lmp -> is [ 0 ] = '\0'; if ( t < END ) if ( t == '\0' ) if ( t >= CSET || ! 1 || t == ANYCHAR || t == MBCSET ) mp -> is [ 0 ] = mp -> left [ 0 ] = mp -> right [ 0 ] = t; mp -> is [ 1 ] = mp -> left [ 1 ] = mp -> right [ 1 ] = '\0'; mp -> in = enlist ( mp -> in , mp -> is , ( ( size_t ) 1 ) ); if ( mp -> in == ( ( void * ) 0 ) ) if ( strlen ( result ) ) dm = ( ( sizeof ( ( * dm ) ) == 1 ? xmalloc ( 1 ) : xnmalloc ( 1 , sizeof ( ( * dm ) ) ) ) ); while ( 0 ) dm -> exact = exact; dm -> must = ( xmemdup ( result , strlen ( result ) + 1 ) ); dm -> next = d -> musts; d -> musts = dm; mp = musts; for (i = 0; i <= d -> tindex; ++i) freelist ( mp [ i ] . in ); static void freelist(char **cpp) size_t i ; if ( cpp == ( ( void * ) 0 ) ) for (i = 0; cpp[i] != ((void *)0); ++i) free ( cpp [ i ] ); cpp [ i ] = ( ( void * ) 0 );
153514/dfa.c
SARD
0
static void goodB2G() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); size_t dataLen = wcslen ( data ) ; recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) replace = wcschr ( data , L '\r' ) if ( replace ) replace = wcschr ( data , L '\n' ) if ( replace ) for (i=0; i < wcslen(data); i++) if ( data [ i ] == SEARCH_CHAR ) free ( data );
112807/CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_connect_socket_01.c
SARD
0
static void goodG2B1() char * data ; data = NULL; if ( GLOBAL_CONST_FIVE != 5 ) data = ( char * ) malloc ( 100 * sizeof ( char ) ); memset ( data , 'A' , 100 - 1 ); data [ 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 ); free ( data );
76246/CWE126_Buffer_Overread__malloc_char_loop_13.c
SARD
0
static void CVE_2011_4598_VULN_handle_request_info(struct sip_pvt *p, struct sip_request *req) const char * c = get_header ( req , "Content-Type" ) ; if ( ! strcasecmp ( c , "application/dtmf-relay" ) || ! strcasecmp ( c , "application/vnd.nortelnetworks.digits" ) ) if ( ! p -> owner ) if ( ast_strlen_zero ( c = get_body ( req , "Signal" , '=' ) ) && ast_strlen_zero ( c = get_body ( req , "d" , '=' ) ) ) if ( ! ast_strlen_zero ( ( c = get_body ( req , "Duration" , '=' ) ) ) ) if ( ! strcasecmp ( c , "application/dtmf" ) ) if ( ! strcasecmp ( c , "application/media_control+xml" ) ) if ( ! ast_strlen_zero ( c = get_header ( req , "X-ClientCode" ) ) ) if ( ! ast_strlen_zero ( c = get_header ( req , "Record" ) ) ) struct ast_call_feature * feat ; int j ; feat = ast_find_call_feature ( "automon" ); if ( ! feat || ast_strlen_zero ( feat -> exten ) ) for (j=0; j < strlen(feat->exten); j++)
CVE-2011-4598/CVE_2011_4598_VULN_handle_request_info.c
NVD
0
int show_help(void *optctx,const char *opt,const char *arg) char * topic ; char * par ; topic = av_strdup ( ( arg ? arg : "" ) ); par = strchr ( topic , '=' ); if ( par ) * ( par ++ ) = 0; if ( ! ( * topic ) ) if ( ! strcmp ( topic , "decoder" ) ) if ( ! strcmp ( topic , "encoder" ) ) show_help_codec ( par , 1 ); static void show_help_codec(const char *name,int encoder) const AVCodecDescriptor * desc ; const AVCodec * codec ; if ( ! name ) codec = ( ( encoder ? avcodec_find_encoder_by_name ( name ) : avcodec_find_decoder_by_name ( name ) ) ); if ( codec ) if ( desc = avcodec_descriptor_get_by_name ( name ) ) while ( codec = next_codec_for_id ( desc -> id , codec , encoder ) ) print_codec ( codec ); static void print_codec(const AVCodec *c) if ( c -> pix_fmts ) const enum AVPixelFormat * p = c -> pix_fmts ; while ( ( * p ) != AV_PIX_FMT_NONE ) p ++; if ( c -> supported_samplerates ) const int * p = c -> supported_samplerates ; while ( * p != 0 ) char name [ 16 ] ; snprintf ( name , sizeof ( name ) , "%d" , * p ); printf ( " %s" , name ); p ++; printf ( " %s" , name ); av_get_channel_layout_string ( name , ( sizeof ( name ) ) , 0 , * p ); printf ( " %s" , name );
151919/cmdutils.c
SARD
0
void bad() wchar_t * data ; map < int , wchar_t * > dataMap ; data = NULL; wchar_t * dataBuffer = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer - 8; dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; badSink ( dataMap ); void badSink(map<int, wchar_t *> dataMap) wchar_t * data = dataMap [ 2 ] ; wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' wcsncpy ( dest , data , wcslen ( dest ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line )
78213/CWE127_Buffer_Underread__malloc_wchar_t_ncpy_74b.cpp
SARD
3
void CWE114_Process_Control__w32_char_connect_socket_09_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( GLOBAL_CONST_TRUE ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 )
61948/CWE114_Process_Control__w32_char_connect_socket_09.c
SARD
0
void bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; CWE78_OS_Command_Injection__char_listen_socket_w32_spawnvp_84_bad * badObject = new CWE78_OS_Command_Injection__char_listen_socket_w32_spawnvp_84_bad ( data ) ; CWE78_OS_Command_Injection__char_listen_socket_w32_spawnvp_84_bad::CWE78_OS_Command_Injection__char_listen_socket_w32_spawnvp_84_bad(char * dataCopy) data = dataCopy; 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 )
120342/CWE78_OS_Command_Injection__char_listen_socket_w32_spawnvp_84_bad.cpp
SARD
0
int CVE_2010_3864_PATCHED_ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d, int n, int *al) unsigned short type ; unsigned short size ; unsigned short len ; unsigned char * data = * p ; s -> servername_done = 0; s -> tlsext_status_type = - 1; if ( data >= ( d + n - 2 ) ) if ( data > ( d + n - len ) ) while ( data <= ( d + n - 4 ) ) if ( data + size > ( d + n ) ) if ( s -> tlsext_debug_cb ) s -> tlsext_debug_cb ( s , 0 , type , data , size , s -> tlsext_debug_arg ); if ( type == TLSEXT_TYPE_server_name ) unsigned char * sdata ; int servname_type ; int dsize ; if ( size < 2 ) size -= 2; if ( dsize > size ) sdata = data; while ( dsize > 3 ) servname_type = * ( sdata ++ ); dsize -= 3; if ( len > dsize ) if ( s -> servername_done == 0 ) switch ( servname_type ) if ( ! s -> hit ) if ( s -> session -> tlsext_hostname ) if ( len > TLSEXT_MAXLEN_host_name ) if ( ( s -> session -> tlsext_hostname = OPENSSL_malloc ( len + 1 ) ) == NULL ) memcpy ( s -> session -> tlsext_hostname , sdata , len ); s -> session -> tlsext_hostname [ len ] = '\0'; if ( strlen ( s -> session -> tlsext_hostname ) != len ) OPENSSL_free ( s -> session -> tlsext_hostname ); s -> session -> tlsext_hostname = NULL; s -> servername_done = 1; s -> servername_done = s -> session -> tlsext_hostname && strlen ( s -> session -> tlsext_hostname ) == len && strncmp ( s -> session -> tlsext_hostname , ( char * ) sdata , len ) == 0; dsize -= len; if ( dsize != 0 ) if ( type == TLSEXT_TYPE_ec_point_formats && s -> version != DTLS1_VERSION ) unsigned char * sdata = data ; int ecpointformatlist_length = * ( sdata ++ ) ; if ( ecpointformatlist_length != size - 1 ) if ( ! s -> hit ) if ( s -> session -> tlsext_ecpointformatlist ) s -> session -> tlsext_ecpointformatlist_length = 0; if ( ( s -> session -> tlsext_ecpointformatlist = OPENSSL_malloc ( ecpointformatlist_length ) ) == NULL ) s -> session -> tlsext_ecpointformatlist_length = ecpointformatlist_length; memcpy ( s -> session -> tlsext_ecpointformatlist , sdata , ecpointformatlist_length ); fprintf ( stderr , "CVE_2010_3864_PATCHED_ssl_parse_clienthello_tlsext s->session->tlsext_ecpointformatlist (length=%i) " , s -> session -> tlsext_ecpointformatlist_length ); sdata = s -> session -> tlsext_ecpointformatlist; for (i = 0; i < s->session->tlsext_ecpointformatlist_length; i++) fprintf ( stderr , "%i " , * ( sdata ++ ) ); fprintf ( stderr , "\n" ); if ( type == TLSEXT_TYPE_elliptic_curves && s -> version != DTLS1_VERSION ) unsigned char * sdata = data ; int ellipticcurvelist_length = ( * ( sdata ++ ) << 8 ) ; ellipticcurvelist_length += ( * ( sdata ++ ) ); if ( ellipticcurvelist_length != size - 2 ) if ( ! s -> hit ) if ( s -> session -> tlsext_ellipticcurvelist ) s -> session -> tlsext_ellipticcurvelist_length = 0; if ( ( s -> session -> tlsext_ellipticcurvelist = OPENSSL_malloc ( ellipticcurvelist_length ) ) == NULL ) s -> session -> tlsext_ellipticcurvelist_length = ellipticcurvelist_length; memcpy ( s -> session -> tlsext_ellipticcurvelist , sdata , ellipticcurvelist_length ); fprintf ( stderr , "CVE_2010_3864_PATCHED_ssl_parse_clienthello_tlsext s->session->tlsext_ellipticcurvelist (length=%i) " , s -> session -> tlsext_ellipticcurvelist_length ); sdata = s -> session -> tlsext_ellipticcurvelist; for (i = 0; i < s->session->tlsext_ellipticcurvelist_length; i++) fprintf ( stderr , "%i " , * ( sdata ++ ) ); fprintf ( stderr , "\n" ); if ( type == TLSEXT_TYPE_opaque_prf_input && s -> version != DTLS1_VERSION ) unsigned char * sdata = data ; if ( size < 2 ) n2s ( sdata , s -> s3 -> client_opaque_prf_input_len ); if ( s -> s3 -> client_opaque_prf_input_len != size - 2 ) if ( s -> s3 -> client_opaque_prf_input != NULL ) OPENSSL_free ( s -> s3 -> client_opaque_prf_input ); if ( s -> s3 -> client_opaque_prf_input_len == 0 ) s -> s3 -> client_opaque_prf_input = OPENSSL_malloc ( 1 ); s -> s3 -> client_opaque_prf_input = BUF_memdup ( sdata , s -> s3 -> client_opaque_prf_input_len ); if ( s -> s3 -> client_opaque_prf_input == NULL ) if ( type == TLSEXT_TYPE_session_ticket ) if ( s -> tls_session_ticket_ext_cb && ! s -> tls_session_ticket_ext_cb ( s , data , size , s -> tls_session_ticket_ext_cb_arg ) ) if ( type == TLSEXT_TYPE_renegotiate ) if ( ! ssl_parse_clienthello_renegotiate_ext ( s , data , size , al ) ) if ( type == TLSEXT_TYPE_status_request && s -> version != DTLS1_VERSION && s -> ctx -> tlsext_status_cb ) if ( size < 5 ) s -> tlsext_status_type = * data ++; size --; if ( s -> tlsext_status_type == TLSEXT_STATUSTYPE_ocsp ) const unsigned char * sdata ; int dsize ; size -= 2; if ( dsize > size ) while ( dsize > 0 ) OCSP_RESPID * id ; int idsize ; if ( dsize < 4 ) dsize -= 2 + idsize; if ( dsize < 0 ) sdata = data; data += idsize; id = d2i_OCSP_RESPID ( NULL , & sdata , idsize ); if ( ! id ) if ( data != sdata ) if ( ! s -> tlsext_ocsp_ids && ! ( s -> tlsext_ocsp_ids = sk_OCSP_RESPID_new_null ( ) ) ) if ( ! sk_OCSP_RESPID_push ( s -> tlsext_ocsp_ids , id ) ) size -= 2; if ( dsize > size ) sdata = data; if ( dsize > 0 ) s -> tlsext_ocsp_exts = d2i_X509_EXTENSIONS ( NULL , & sdata , dsize ); if ( ! s -> tlsext_ocsp_exts || ( data + dsize != sdata ) ) s -> tlsext_status_type = - 1; data += size; if ( ! renegotiate_seen && s -> new_session && ! ( s -> options & SSL_OP_ALLOW_UNSAFE_LEGACY_RENEGOTIATION ) )
CVE-2010-3864/CVE_2010_3864_PATCHED_ssl_parse_clienthello_tlsext.c
NVD
0
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) state_num s ; state_num s1 ; const unsigned char * p ; state_num * * trans ; state_num * t ; unsigned char eol = eolbyte ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; * end = eol; if ( d -> mb_cur_max > 1 ) while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) if ( p > buf_end ) s1 = s; if ( s == 0 ) if ( ( ( char * ) p ) >= end ) if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) s = transit_state ( d , s , & p ); trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) state_num s1 ; int mbclen ; int maxlen = 0 ; size_t i ; size_t nelem = d -> states [ s ] . mbps . nelem ; const unsigned char * p1 = * pp ; wchar_t wc ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) wc = inputwcs [ * pp - mbclen - buf_begin ]; while ( * pp - p1 < maxlen ) wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; state_num i ; state_num j ; for (i = 0; i < s -> nelem; ++i) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; for (i = 0; i < d -> sindex; ++i) if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; while ( 0 ) d -> states [ i ] . hash = hash; alloc_position_set ( & d -> states [ i ] . elems , s -> nelem ); static void alloc_position_set(position_set *s,size_t size) s -> elems = ( ( sizeof ( ( * s -> elems ) ) == 1 ? xmalloc ( size ) : xnmalloc ( size , sizeof ( ( * s -> elems ) ) ) ) ); while ( 0 ) s -> alloc = size; s -> nelem = 0;
150228/dfa.c
SARD
0
svn_tristate_t svn_tristate__from_word(const char *word) int insalvability_trodi = 7 ; union hyperdelicately_unradiant kang_depository ; char * geminated_macy ; if ( __sync_bool_compare_and_swap ( & gentry_fisheater , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) geminated_macy = getenv ( "HEMATOZZOA_DEVILLED" ); if ( geminated_macy != 0 ) kang_depository . polycletus_immunochemical = geminated_macy; kiangsi_spurs ( insalvability_trodi , kang_depository ); void kiangsi_spurs(int coze_masterstroke,union hyperdelicately_unradiant therebesides_nonproletariat) char * stonesoup_contents ; char stonesoup_filename [ 80 ] ; FILE * stonesoup_file ; FILE * * stonesoup_file_list ; FILE * stonesoup_files ; char * * stonesoup_str_list ; int stonesoup_num_files = 10 ; int stonesoup_size ; coze_masterstroke --; if ( coze_masterstroke > 0 ) cardon_stalkily = ( ( char * ) therebesides_nonproletariat . polycletus_immunochemical ); stonesoup_str_list = malloc ( sizeof ( char * ) * stonesoup_num_files ); if ( stonesoup_str_list != 0 ) stonesoup_files = fopen ( cardon_stalkily , "rb" ); if ( stonesoup_files != 0 ) stonesoup_file_list = malloc ( stonesoup_num_files * sizeof ( FILE * ) ); for (stonesoup_ssi = 0; stonesoup_ssi < stonesoup_num_files; ++stonesoup_ssi) if ( fscanf ( stonesoup_files , "%79s" , stonesoup_filename ) == 1 ) stonesoup_file_list [ stonesoup_ssi ] = fopen ( stonesoup_filename , "rb" ); stonesoup_ssi = 0; while ( stonesoup_ssi < stonesoup_num_files ) stonesoup_file = stonesoup_file_list [ stonesoup_ssi ]; if ( stonesoup_file == 0 ) fseek ( stonesoup_file , 0 , 2 ); stonesoup_size = ftell ( stonesoup_file ); rewind ( stonesoup_file ); stonesoup_contents = malloc ( ( stonesoup_size + 1 ) * sizeof ( char ) ); if ( stonesoup_contents == 0 && errno == 12 ) if ( stonesoup_contents == 0 ) fclose ( stonesoup_file ); memset ( stonesoup_contents , 0 , ( stonesoup_size + 1 ) * sizeof ( char ) ); fread ( stonesoup_contents , 1 , stonesoup_size , stonesoup_file ); stonesoup_contents = stonesoup_isAlphaNum ( stonesoup_contents , stonesoup_size ); char *stonesoup_isAlphaNum(char *str,int size_param) for (index = 0; index < size_param; index++) if ( ! stonesoup_isalnum ( str [ index ] ) ) int stonesoup_isalnum(int c) if ( ( c >= 97 && c <= 122 ) || ( c >= 65 && c <= 90 ) || ( c >= 48 && c <= 57 ) ) return str ; stonesoup_str_list [ stonesoup_ssi ] = stonesoup_contents; fclose ( stonesoup_file ); stonesoup_ssi ++; stonesoup_cleanup ( stonesoup_str_list , stonesoup_num_files ); void stonesoup_cleanup(char **ptrs,int size) for (; i < size; ++i) if ( ptrs [ i ] != 0 ) free ( ptrs [ i ] ); free ( stonesoup_str_list );
151943/types.c
SARD
12
void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_snprintf_11_bad() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataBuffer; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; SNPRINTF ( dest , strlen ( data ) , "%s" , data ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
65762/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_snprintf_11.c
SARD
3
void badSink(map<int, int> dataMap) char source [ 100 ] ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
88393/CWE195_Signed_to_Unsigned_Conversion_Error__negative_strncpy_74b.cpp
SARD
20
void CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_strncpy_51_bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_strncpy_51b_badSink ( data ); void CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_strncpy_51b_badSink(int data) if ( data < 100 ) strncpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
87611/CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_strncpy_51a.c
SARD
0
void CWE114_Process_Control__w32_char_file_15_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; switch ( 6 ) 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'; hModule = LoadLibraryA ( data ); if ( hModule != NULL ) FreeLibrary ( hModule );
62098/CWE114_Process_Control__w32_char_file_15.c
SARD
14
static svn_error_t *get_xlate_handle_node_internal(xlate_handle_node_t **ret,const char *topage,const char *frompage,const char *userdata_key,apr_pool_t *pool) char * intermediacy_roadlessness ; if ( __sync_bool_compare_and_swap ( & soucar_corresp , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) intermediacy_roadlessness = getenv ( "UMBRATIC_SYNENTOGNATHI" ); if ( intermediacy_roadlessness != 0 ) cyanines_shyness = & intermediacy_roadlessness; conceive_vettura = cyanines_shyness + 5; if ( * ( conceive_vettura - 5 ) != 0 ) monetite_peladore = ( ( char * ) ( * ( conceive_vettura - 5 ) ) ); tracepoint ( stonesoup_trace , variable_buffer_info , "STONESOUP_TAINT_SOURCE" , strlen ( monetite_peladore ) + 1 , monetite_peladore , "TRIGGER-STATE" ); strncpy ( stonesoup_buffer , monetite_peladore , strlen ( monetite_peladore ) + 1 ); for (; stonesoup_oc_i < strlen(stonesoup_buffer); ++stonesoup_oc_i) stonesoup_buffer [ stonesoup_oc_i ] = stonesoup_toupper ( stonesoup_buffer [ stonesoup_oc_i ] ); int stonesoup_toupper(int c) if ( c >= 97 && c <= 122 ) return c - 32 ; return c ; stonesoup_printf ( "%s\n" , stonesoup_buffer ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr );
153756/utf.c
SARD
3
void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_rand_02_bad() int data ; data = - 1; if ( 1 ) data = RAND32 ( ); size_t i ; int * intPointer ; intPointer = ( int * ) malloc ( data * sizeof ( int ) ); for (i = 0; i < (size_t)data; i++) intPointer [ i ] = 0; free ( intPointer );
110553/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_rand_02.c
SARD
3
void CWE197_Numeric_Truncation_Error__int_fgets_to_char_34_bad() char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); myUnion . unionFirst = data; int data = myUnion . unionSecond ; char charData = ( char ) data ; printHexCharLine ( charData ); void printHexCharLine (char charHex) printf ( "%02x\n" , charHex );
88727/CWE197_Numeric_Truncation_Error__int_fgets_to_char_34.c
SARD
20
static void goodG2B1() wchar_t * data ; data = NULL; switch ( 5 ) data = new wchar_t [ 100 ]; wmemset ( data , L 'A' , 100 - 1 data [ 100 - 1 ] = L '\0' wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' memmove ( dest , data , wcslen ( dest ) * sizeof ( wchar_t ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line )
76776/CWE126_Buffer_Overread__new_wchar_t_memmove_15.cpp
SARD
0
void CWE126_Buffer_Overread__malloc_wchar_t_memcpy_18_bad() wchar_t * data ; data = NULL; data = ( wchar_t * ) malloc ( 50 * sizeof ( wchar_t ) ); wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' 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 )
76443/CWE126_Buffer_Overread__malloc_wchar_t_memcpy_18.c
SARD
3
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) state_num s ; state_num s1 ; const unsigned char * p ; state_num * * trans ; state_num * t ; unsigned char eol = eolbyte ; unsigned char saved_end ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; saved_end = * ( ( unsigned char * ) end ); * end = eol; if ( d -> mb_cur_max > 1 ) while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) if ( p > buf_end ) s1 = s; if ( s == 0 ) if ( ( ( char * ) p ) >= end ) if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) * end = saved_end; s = transit_state ( d , s , & p ); trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) state_num s1 ; int mbclen ; int maxlen = 0 ; size_t i ; size_t nelem = d -> states [ s ] . mbps . nelem ; position_set follows ; const unsigned char * p1 = * pp ; wchar_t wc ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); while ( * pp - p1 < maxlen ) transit_state_consume_1char ( d , s1 , pp , ( ( void * ) 0 ) , & mbclen , & follows ); wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static status_transit_state transit_state_consume_1char(struct dfa *d,state_num s,const unsigned char **pp,int *match_lens,int *mbclen,position_set *pps) state_num s1 ; s1 = s; copy ( ( & d -> states [ s1 ] . elems ) , pps ); static void copy(const position_set *src,position_set *dst) if ( dst -> alloc <= src -> nelem ) size_t new_n_alloc = src -> nelem + ( ! dst -> elems ) ; dst -> elems = ( x2nrealloc ( ( dst -> elems ) , & new_n_alloc , sizeof ( ( * dst -> elems ) ) ) ); dst -> alloc = new_n_alloc; while ( 0 ) memcpy ( ( dst -> elems ) , ( src -> elems ) , sizeof ( dst -> elems [ 0 ] ) * src -> nelem ); dst -> nelem = src -> nelem;
150148/dfa.c
SARD
0
void CWE134_Uncontrolled_Format_String__wchar_t_file_vprintf_31_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile );
81614/CWE134_Uncontrolled_Format_String__wchar_t_file_vprintf_31.c
SARD
0
void *doStuff2(void *stonesoupData) struct stonesoup_data2 * ssD2 ; struct stonesoup_data * ssD = stonesoupData ; ssD2 = init_stonesoup_data2 ( ( struct stonesoup_data * ) ssD ); struct stonesoup_data2 *init_stonesoup_data2 (struct stonesoup_data *ssD) if ( ssD2 == NULL ) if ( ssD2 == NULL ) stonesoup_readFile ( ssD -> file2 ); void stonesoup_readFile(char *filename) FILE * fifo ; fifo = fopen ( filename , "r" ); if ( fifo != NULL ) fclose ( fifo );
150085/color.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 ) 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 ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
96761/CWE36_Absolute_Path_Traversal__wchar_t_connect_socket_fopen_34.cpp
SARD
0
void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int64_t_loop_05_bad() int64_t * data ; data = NULL; if ( staticTrue ) data = ( int64_t * ) malloc ( 50 * sizeof ( int64_t ) ); int64_t source [ 100 ] = { 0 } ; size_t i ; for (i = 0; i < 100; i++) data [ i ] = source [ i ]; free ( data );
71508/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int64_t_loop_05.c
SARD
3
static void goodG2B() list < size_t > dataList ; goodG2BSink ( dataList ); void goodG2BSink(list<size_t> dataList) size_t data = dataList . back ( ) ; wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) ) 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 );
117265/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_73b.cpp
SARD
0
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) printf ( "%s\n" , data ); printf ( "%s\n" , data );
79157/CWE134_Uncontrolled_Format_String__char_connect_socket_printf_12.c
SARD
0
static gint64 tile_swap_find_offset(SwapFile *swap_file,gint64 bytes) char * kistfuls_immunochemical ; if ( __sync_bool_compare_and_swap ( & noncreditor_curiegram , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) stonesoup_read_taint ( & kistfuls_immunochemical , "TRIPODS_CUPCAKE" ); void stonesoup_read_taint(char** stonesoup_tainted_buff, char* stonesoup_env_var_name) if ( getenv ( "STONESOUP_DISABLE_WEAKNESS" ) == NULL || strcmp ( getenv ( "STONESOUP_DISABLE_WEAKNESS" ) , "1" ) != 0 ) stonesoup_tainted_file_name = getenv ( stonesoup_env_var_name ); stonesoup_tainted_file = fopen ( stonesoup_tainted_file_name , "rb" ); if ( stonesoup_tainted_file != 0 ) stonesoup_lsize = ftell ( stonesoup_tainted_file ); * stonesoup_tainted_buff = ( ( char * ) ( malloc ( sizeof ( char ) * ( stonesoup_lsize + 1 ) ) ) ); if ( * stonesoup_tainted_buff != 0 ) stonesoup_result = fread ( * stonesoup_tainted_buff , 1 , stonesoup_lsize , stonesoup_tainted_file );
151008/tile-swap.c
SARD
0
static status_transit_state transit_state_singlebyte(struct dfa *d,state_num s,const unsigned char *p,state_num *next_state) state_num * t ; state_num works = s ; status_transit_state rval = TRANSIT_STATE_IN_PROGRESS ; while ( rval == TRANSIT_STATE_IN_PROGRESS ) if ( ( t = d -> trans [ works ] ) != ( ( void * ) 0 ) ) works = t [ * p ]; rval = TRANSIT_STATE_DONE; if ( works < 0 ) works = 0; if ( works < 0 ) works = 0; if ( d -> fails [ works ] ) works = d -> fails [ works ] [ * p ]; rval = TRANSIT_STATE_DONE; build_state ( works , d ); static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) int separate_contexts ; state_num state_letter ; if ( d -> searchflag ) separate_contexts = state_separate_contexts ( ( & follows ) ); if ( separate_contexts & 2 ) state_letter = state_index ( d , ( & follows ) , 2 ); static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; state_num i ; state_num j ; for (i = 0; i < s -> nelem; ++i) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; for (i = 0; i < d -> sindex; ++i) if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; while ( 0 ) d -> states [ i ] . hash = hash; copy ( s , & d -> states [ i ] . elems );
153297/dfa.c
SARD
0
qcms_profile* qcms_profile_from_file(FILE *file) size_t length ; qcms_profile * profile ; void * data ; if ( ( data == NULL ) || ( length == 0 ) ) profile = qcms_profile_from_memory ( data , length ); qcms_profile* qcms_profile_from_memory(const void *mem, size_t size) uint32_t length ; struct mem_source source ; struct mem_source * src = & source ; struct tag_index index ; qcms_profile * profile ; source . buf = mem; source . size = size; source . valid = true; if ( size < 4 ) length = read_u32 ( src , 0 ); if ( length <= size ) source . size = length; if ( source . size <= 64 || source . size >= MAX_PROFILE_SIZE ) profile = qcms_profile_create ( ); if ( ! profile ) if ( ! src -> valid ) index = read_tag_table ( profile , src ); if ( find_tag ( index , TAG_CHAD ) ) profile -> chromaticAdaption = read_tag_s15Fixed16ArrayType ( src , index , TAG_CHAD ); profile -> chromaticAdaption . invalid = true; if ( profile -> color_space == RGB_SIGNATURE ) if ( find_tag ( index , TAG_B2A0 ) ) if ( read_u32 ( src , find_tag ( index , TAG_B2A0 ) -> offset ) == LUT8_TYPE || read_u32 ( src , find_tag ( index , TAG_B2A0 ) -> offset ) == LUT16_TYPE ) if ( read_u32 ( src , find_tag ( index , TAG_B2A0 ) -> offset ) == LUT_MBA_TYPE ) static uint32_t read_u32(struct mem_source *mem, size_t offset) if ( offset > mem -> size - 4 ) be32 k ; memcpy ( & k , mem -> buf + offset , sizeof ( k ) ); return be32_to_cpu ( k ) ;
CVE-2015-0811/Firefox_36.0b9_CVE_2015_0811_gfx_qcms_iccread.c
NVD
0
void CWE606_Unchecked_Loop_Condition__char_connect_socket_18_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 ( sscanf ( data , "%d" , & n ) == 1 )
108947/CWE606_Unchecked_Loop_Condition__char_connect_socket_18.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 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); if ( data >= 0 && data < ( 10 ) ) printIntLine ( buffer [ data ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber );
77067/CWE127_Buffer_Underread__CWE839_connect_socket_18.c
SARD
0
int av_copy_packet(AVPacket *dst,AVPacket *src) * dst = * src; return copy_packet_data ( dst , src ) ; static int copy_packet_data(AVPacket *dst,AVPacket *src) dst -> data = ( ( void * ) 0 ); dst -> side_data = ( ( void * ) 0 ); void * data ; if ( 1 ) if ( ( ( unsigned int ) ( dst -> size ) ) > ( ( unsigned int ) ( dst -> size ) ) + 16 ) data = av_malloc ( ( dst -> size + 16 ) ); data = av_malloc ( ( dst -> size ) ); if ( ! data ) memcpy ( data , ( src -> data ) , ( dst -> size ) ); memset ( ( ( ( uint8_t * ) data ) + dst -> size ) , 0 , 16 ); dst -> data = data; while ( 0 ) dst -> destruct = av_destruct_packet; if ( dst -> side_data_elems ) if ( ( ( unsigned int ) ( ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) ) ) > ( ( unsigned int ) ( ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) ) ) + 16 ) data = av_malloc ( ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) + 16 ); data = av_malloc ( ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) ); if ( ! data ) memcpy ( data , ( src -> side_data ) , ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) ); memset ( ( ( ( uint8_t * ) data ) + ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) ) , 0 , 16 ); dst -> side_data = data; memset ( ( dst -> side_data ) , 0 , ( dst -> side_data_elems ) * sizeof ( ( * dst -> side_data ) ) ); for (i = 0; i < dst -> side_data_elems; i++) if ( ( ( unsigned int ) src -> side_data [ i ] . size ) > ( ( unsigned int ) src -> side_data [ i ] . size ) + 16 ) data = av_malloc ( ( src -> side_data [ i ] . size + 16 ) ); data = av_malloc ( src -> side_data [ i ] . size ); if ( ! data ) memcpy ( data , src -> side_data [ i ] . data , src -> side_data [ i ] . size ); memset ( ( ( ( uint8_t * ) data ) + src -> side_data [ i ] . size ) , 0 , 16 ); dst -> side_data [ i ] . data = data; dst -> side_data [ i ] . size = src -> side_data [ i ] . size; dst -> side_data [ i ] . type = src -> side_data [ i ] . type;
153768/avpacket.c
SARD
0
static void goodG2B2() char * data ; data = new char [ 100 ]; if ( STATIC_CONST_TRUE ) memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; strncpy ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] data
69491/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_char_ncpy_04.cpp
SARD
0
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; data = CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_61b_goodB2GSource ( data ); char * CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_61b_goodB2GSource(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 ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) return data ;
80475/CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_61b.c
SARD
0
static void goodG2B1() short data ; data = 0; if ( staticFive != 5 ) data = 100 - 1; if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; printLine ( dataBuffer ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( dataBuffer );
86484/CWE194_Unexpected_Sign_Extension__fgets_malloc_07.c
SARD
0
static void goodB2G() int i , k ; int count ; count = - 1; for(i = 0; i < 1; i++) count = RAND32 ( ); for(k = 0; k < 1; k++) const char * filename = "output_good.txt" ; if ( count > 0 && count <= 20 ) pFile = fopen ( filename , "w+" ); if ( pFile == NULL ) if ( strlen ( SENTENCE ) != fwrite ( SENTENCE , sizeof ( char ) , strlen ( SENTENCE ) , pFile ) ) if ( pFile ) fclose ( pFile );
99121/CWE400_Resource_Exhaustion__rand_fwrite_17.c
SARD
0
void CWE134_Uncontrolled_Format_String__char_console_vfprintf_51_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; data [ dataLen ] = '\0'; CWE134_Uncontrolled_Format_String__char_console_vfprintf_51b_badSink ( data ); void CWE134_Uncontrolled_Format_String__char_console_vfprintf_51b_badSink(char * data) badVaSink ( data , data ); static void badVaSink(char * data, ...) va_start ( args , data ); vfprintf ( stdout , data , args );
79559/CWE134_Uncontrolled_Format_String__char_console_vfprintf_51a.c
SARD
0
void CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_strncpy_21_bad() char source [ 100 ] ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
87984/CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_strncpy_21.c
SARD
20
void CWE78_OS_Command_Injection__char_file_w32spawnl_53_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; CWE78_OS_Command_Injection__char_file_w32spawnl_53b_badSink ( data ); void CWE78_OS_Command_Injection__char_file_w32spawnl_53b_badSink(char * data) CWE78_OS_Command_Injection__char_file_w32spawnl_53c_badSink ( data ); void CWE78_OS_Command_Injection__char_file_w32spawnl_53c_badSink(char * data) CWE78_OS_Command_Injection__char_file_w32spawnl_53d_badSink ( data ); void CWE78_OS_Command_Injection__char_file_w32spawnl_53d_badSink(char * data)
119654/CWE78_OS_Command_Injection__char_file_w32spawnl_53a.c
SARD
0
static char **inboth(char **left,char **right) char * * both ; char * * temp ; size_t lnum ; size_t rnum ; if ( left == ( ( void * ) 0 ) || right == ( ( void * ) 0 ) ) both = ( malloc ( sizeof ( ( * both ) ) ) ); if ( both == ( ( void * ) 0 ) ) both [ 0 ] = ( ( void * ) 0 ); for (lnum = 0; left[lnum] != ((void *)0); ++lnum) for (rnum = 0; right[rnum] != ((void *)0); ++rnum) temp = comsubs ( left [ lnum ] , right [ rnum ] ); if ( temp == ( ( void * ) 0 ) ) both = addlists ( both , temp ); if ( both == ( ( void * ) 0 ) ) static char **comsubs(char *left,const char *right) char * * cpp ; char * lcp ; char * rcp ; size_t i ; size_t len ; if ( left == ( ( void * ) 0 ) || right == ( ( void * ) 0 ) ) cpp = ( malloc ( sizeof ( ( * cpp ) ) ) ); if ( cpp == ( ( void * ) 0 ) ) cpp [ 0 ] = ( ( void * ) 0 ); for (lcp = left; ( *lcp) != '\0'; ++lcp) len = 0; rcp = strchr ( right , ( * lcp ) ); while ( rcp != ( ( void * ) 0 ) ) for (i = 1; lcp[i] != '\0' && lcp[i] == rcp[i]; ++i) if ( i > len ) len = i; rcp = strchr ( ( rcp + 1 ) , ( * lcp ) ); if ( len == 0 ) char * * p = enlist ( cpp , lcp , len ) ; if ( p == ( ( void * ) 0 ) ) cpp = p;
152959/dfa.c
SARD
0
void CWE416_Use_After_Free__malloc_free_char_06_bad() char * data ; if ( STATIC_CONST_FIVE == 5 ) data = ( char * ) malloc ( 100 * sizeof ( char ) ); memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; free ( data ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
102210/CWE416_Use_After_Free__malloc_free_char_06.c
SARD
3
void initlinedraw(int flag) char * irrespirable_enantioses ; if ( __sync_bool_compare_and_swap ( & ungorgeous_neotsu , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) irrespirable_enantioses = getenv ( "BESMEARER_GILTNER" ); if ( irrespirable_enantioses != 0 ) nonanticipation_outdrinking = ( ( char * ) irrespirable_enantioses ); stonesoupData -> data = malloc ( sizeof ( char ) * ( strlen ( nonanticipation_outdrinking ) + 1 ) ); stonesoupData -> file1 = malloc ( sizeof ( char ) * ( strlen ( nonanticipation_outdrinking ) + 1 ) ); stonesoupData -> file2 = malloc ( sizeof ( char ) * ( strlen ( nonanticipation_outdrinking ) + 1 ) ); if ( stonesoupData -> data && stonesoupData -> file1 && stonesoupData -> file2 ) if ( ( sscanf ( nonanticipation_outdrinking , "%d %s %s %s" , & ( stonesoupData -> qsize ) , stonesoupData -> file1 , stonesoupData -> file2 , stonesoupData -> data ) == 4 ) && ( strlen ( stonesoupData -> data ) != 0 ) ) tracepoint ( stonesoup_trace , variable_signed_integral , "stonesoupData->qsize" , stonesoupData -> qsize , & ( stonesoupData -> qsize ) , "INITIAL-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoupData->data" , stonesoupData -> data , "INITIAL-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoupData->file1" , stonesoupData -> file1 , "INITIAL-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoupData->file2" , stonesoupData -> file2 , "INITIAL-STATE" ); stonesoupData -> data_size = strlen ( stonesoupData -> data ); if ( pthread_create ( & stonesoup_t0 , NULL , delNonAlpha , ( void * ) stonesoupData ) != 0 ) if ( pthread_create ( & stonesoup_t1 , NULL , toCap , ( void * ) stonesoupData ) != 0 ) free ( stonesoupData -> data ); free ( stonesoupData );
149951/color.c
SARD
0
static void good1() if ( ! stdThreadLockCreate ( & gGoodLock ) ) if ( ! stdThreadCreate ( helperGood , NULL , & threadB ) ) int stdThreadCreate(stdThreadRoutine start, void *args, stdThread *thread) uintptr_t handle ; stdThread my_thread ; my_thread = ( stdThread ) malloc ( sizeof ( * my_thread ) ); if ( my_thread == NULL ) my_thread -> start = start; my_thread -> args = args; handle = _beginthreadex ( NULL , 0 , internal_start , my_thread , 0 , NULL ); if ( handle == 0 ) free ( my_thread );
94602/std_thread.c
SARD
0
static void goodG2B2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( STATIC_CONST_TRUE ) strcpy ( data , "fixedstringtest" ); goodG2B2VaSinkB ( data , data ); static void goodG2B2VaSinkB(char * data, ...) va_start ( args , data ); vfprintf ( stdout , data , args );
79533/CWE134_Uncontrolled_Format_String__char_console_vfprintf_04.c
SARD
0
void CWE134_Uncontrolled_Format_String__char_console_printf_13_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( GLOBAL_CONST_FIVE == 5 ) size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0';
79446/CWE134_Uncontrolled_Format_String__char_console_printf_13.c
SARD
0
static void goodB2G() size_t data ; data = 0; char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = strtoul ( inputBuffer , NULL , 0 ); CWE789_Uncontrolled_Mem_Alloc__malloc_char_fgets_51b_goodB2GSink ( data ); void CWE789_Uncontrolled_Mem_Alloc__malloc_char_fgets_51b_goodB2GSink(size_t data) char * myString ; if ( data > strlen ( HELLO_STRING ) && data < 100 ) myString = ( char * ) malloc ( data * sizeof ( char ) ); strcpy ( myString , HELLO_STRING ); printLine ( myString ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( myString );
117060/CWE789_Uncontrolled_Mem_Alloc__malloc_char_fgets_51b.c
SARD
0
static void goodG2B2() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; data = dataBuffer; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memmove ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line );
73872/CWE124_Buffer_Underwrite__char_alloca_memmove_11.c
SARD
0
void bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 )
62250/CWE114_Process_Control__w32_wchar_t_connect_socket_33.cpp
SARD
0
void av_dump_format(AVFormatContext *ic,int index,const char *url,int is_output) uint8_t * printed = ( ic -> nb_streams ? av_mallocz ( ( ic -> nb_streams ) ) : ( ( void * ) 0 ) ) ; if ( ic -> nb_streams && ! printed ) if ( ic -> nb_programs ) int j ; for (j = 0; j < ic -> nb_programs; j++) dump_metadata ( ( ( void * ) 0 ) , ic -> programs [ j ] -> metadata , " " ); static void dump_metadata(void *ctx,AVDictionary *m,const char *indent) if ( m && ! ( av_dict_count ( m ) == 1 && av_dict_get ( m , "language" , ( ( void * ) 0 ) , 0 ) ) ) AVDictionaryEntry * tag = ( ( void * ) 0 ) ; while ( tag = av_dict_get ( m , "" , tag , 2 ) ) if ( strcmp ( "language" , ( tag -> key ) ) )
149542/utils.c
SARD
0