func
stringlengths 181
23.6k
| path
stringlengths 12
123
| source
stringclasses 2
values | label
int64 0
40
|
---|---|---|---|
void CWE78_OS_Command_Injection__char_file_popen_08_bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; pipe = POPEN ( data , "wb" ); if ( pipe != NULL ) PCLOSE ( pipe ); | 119486/CWE78_OS_Command_Injection__char_file_popen_08.c | SARD | 15 |
static void goodG2B1() 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 ); | 63917/CWE121_Stack_Based_Buffer_Overflow__CWE805_char_alloca_memmove_06.c | SARD | 0 |
static void goodG2B1() char * data ; char dataBuffer [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; if ( globalFalse ) data = dataBuffer; char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memmove ( dest , data , 100 * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77571/CWE127_Buffer_Underread__char_declare_memmove_10.c | SARD | 0 |
RestyleManager::ReparentStyleContext(nsIFrame* aFrame) nsStyleContext * oldContext = aFrame -> StyleContext ( ) ; nsRefPtr < nsStyleContext > newContext ; nsIFrame * providerFrame = aFrame -> GetParentStyleContextFrame ( ) ; bool isChild = providerFrame && providerFrame -> GetParent ( ) == aFrame ; nsStyleContext * newParentContext = nullptr ; if ( isChild ) newParentContext = providerFrame -> StyleContext ( ); if ( providerFrame ) newParentContext = providerFrame -> StyleContext ( ); nsIFrame * prevContinuation = GetPrevContinuationWithPossiblySameStyle ( aFrame ) ; nsStyleContext * prevContinuationContext ; bool copyFromContinuation = prevContinuation && ( prevContinuationContext = prevContinuation -> StyleContext ( ) ) -> GetPseudo ( ) == oldContext -> GetPseudo ( ) && prevContinuationContext -> GetParent ( ) == newParentContext ; if ( copyFromContinuation ) newContext = prevContinuationContext; nsIFrame * parentFrame = aFrame -> GetParent ( ) ; Element * element = ElementForStyleContext ( parentFrame ? parentFrame -> GetContent ( ) : nullptr , aFrame , oldContext -> GetPseudoType ( ) ) ; nsIContent * pseudoElementContent = aFrame -> GetContent ( ) ; Element * pseudoElement = ( pseudoElementContent && pseudoElementContent -> IsElement ( ) ) ? pseudoElementContent -> AsElement ( ) : nullptr ; newContext = mPresContext -> StyleSet ( ) -> ReparentStyleContext ( oldContext , newParentContext , element , pseudoElement ); if ( newContext ) if ( newContext != oldContext ) VerifyStyleTree ( mPresContext , aFrame , newParentContext ); static VerifyStyleTree(nsPresContext* aPresContext, nsIFrame* nsStyleContext* aParentContext) nsStyleContext * context = aFrame -> StyleContext ( ) ; int32_t contextIndex = 0 ; for (nsStyleContext* (extraContext = ++contextIndex) VerifyContextParent ( aPresContext , aFrame , extraContext , context ); static VerifyContextParent(nsPresContext* aPresContext, nsIFrame* nsStyleContext* aContext, nsStyleContext* aParentContext) if ( ! aContext ) aContext = aFrame -> StyleContext ( ); nsStyleContext * childStyleIfVisited = aContext -> GetStyleIfVisited ( ) ; if ( childStyleIfVisited && ! ( ( childStyleIfVisited -> RuleNode ( ) != aContext -> RuleNode ( ) && childStyleIfVisited -> GetParent ( ) == aContext -> GetParent ( ) ) || childStyleIfVisited -> GetParent ( ) == aContext -> GetParent ( ) -> GetStyleIfVisited ( ) ) ) DumpContext ( aFrame , aContext ); static DumpContext(nsIFrame* aFrame, nsStyleContext* aContext) if ( aFrame ) nsAutoString name ; fputs ( NS_LossyConvertUTF16toASCII ( name ) . get ( ) , stdout ); | CVE-2015-0826/Firefox_35.0b8_CVE_2015_0826_layout_base_RestyleManager.cpp | NVD | 0 |
void CWE134_Uncontrolled_Format_String__char_connect_socket_vprintf_66_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 79328/CWE134_Uncontrolled_Format_String__char_connect_socket_vprintf_66a.c | SARD | 0 |
static void goodB2G() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) dataArray [ 2 ] = data; CWE191_Integer_Underflow__int_connect_socket_sub_66b_goodB2GSink ( dataArray ); void CWE191_Integer_Underflow__int_connect_socket_sub_66b_goodB2GSink(int dataArray[]) int data = dataArray [ 2 ] ; if ( data > INT_MIN ) int result = data - 1 ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 85364/CWE191_Integer_Underflow__int_connect_socket_sub_66a.c | SARD | 0 |
static void goodG2B2() char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] data | 70035/CWE122_Heap_Based_Buffer_Overflow__cpp_dest_char_cpy_22a.cpp | SARD | 0 |
static void good1() int k ; for(k = 0; k < 1; k++) char data [ 100 ] = "" ; size_t dataLen = strlen ( data ) ; recvResult = recv ( acceptSocket , ( char * ) data + dataLen , ( int ) ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ recvResult ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 109997/CWE666_Operation_on_Resource_in_Wrong_Phase_of_Lifetime__bind_accept_listen_17.c | SARD | 0 |
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) state_num s ; state_num s1 ; const unsigned char * p ; state_num * * trans ; state_num * t ; unsigned char eol = eolbyte ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; * end = eol; if ( d -> mb_cur_max > 1 ) while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) if ( p > buf_end ) s1 = s; if ( s == 0 ) if ( ( ( char * ) p ) >= end ) if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) s = transit_state ( d , s , & p ); trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) state_num s1 ; int mbclen ; int maxlen = 0 ; size_t i ; size_t nelem = d -> states [ s ] . mbps . nelem ; 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 state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; state_num i ; state_num j ; for (i = 0; i < s -> nelem; ++i) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; for (i = 0; i < d -> sindex; ++i) if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; while ( 0 ) d -> states [ i ] . hash = hash; copy ( s , & d -> states [ i ] . elems ); static void copy(const position_set *src,position_set *dst) if ( dst -> alloc <= src -> nelem ) size_t new_n_alloc = src -> nelem + ( ! dst -> elems ) ; dst -> elems = ( x2nrealloc ( ( dst -> elems ) , & new_n_alloc , sizeof ( ( * dst -> elems ) ) ) ); dst -> alloc = new_n_alloc; while ( 0 ) memcpy ( ( dst -> elems ) , ( src -> elems ) , sizeof ( dst -> elems [ 0 ] ) * src -> nelem ); dst -> nelem = src -> nelem; | 149548/dfa.c | SARD | 0 |
void CWE191_Integer_Underflow__int_connect_socket_multiply_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 ) while ( 0 ) | 85307/CWE191_Integer_Underflow__int_connect_socket_multiply_51a.c | SARD | 0 |
static void goodB2G1() char * data ; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; char myString [ ] = "myString" ; data = strdup ( myString ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 100340/CWE401_Memory_Leak__strdup_char_11.c | SARD | 0 |
static void goodG2B() twoIntsStruct * data ; data = NULL; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; data = ( twoIntsStruct * ) malloc ( 100 * sizeof ( twoIntsStruct ) ); data = ( twoIntsStruct * ) malloc ( 100 * sizeof ( twoIntsStruct ) ); if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; free ( data ); | 101446/CWE415_Double_Free__malloc_free_struct_12.c | SARD | 0 |
static void goodG2B() wchar_t * data ; data = NULL; wchar_t * dataBuffer = new wchar_t [ 100 ] ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer; goodG2BSink ( data ); void goodG2BSink(wchar_t * data) wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memcpy ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 75078/CWE124_Buffer_Underwrite__new_wchar_t_memcpy_41.cpp | SARD | 0 |
void bad() wchar_t * data ; wchar_t * & dataRef = data ; wchar_t dataBadBuffer [ 10 ] ; data = dataBadBuffer; data [ 0 ] = L '\0' wchar_t * data = dataRef ; wchar_t source [ 10 + 1 ] = SRC_STRING ; wcscpy ( data , source ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 63652/CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_declare_cpy_33.cpp | SARD | 3 |
void CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_w32_vsnprintf_66_bad() wchar_t * data ; wchar_t * dataArray [ 5 ] ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( wchar_t ) ] = L '\0' while ( 0 ) dataArray [ 2 ] = data; CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_w32_vsnprintf_66b_badSink ( dataArray ); void CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_w32_vsnprintf_66b_badSink(wchar_t * dataArray[]) wchar_t * data = dataArray [ 2 ] ; badVaSink ( data , data ); static void badVaSink(wchar_t * data, ...) wchar_t dest [ 100 ] = L "" va_list args ; _vsnwprintf ( dest , 100 - 1 , data , args ); | 81968/CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_w32_vsnprintf_66b.c | SARD | 15 |
void CWE78_OS_Command_Injection__char_console_w32_spawnvp_34_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'; | 118830/CWE78_OS_Command_Injection__char_console_w32_spawnvp_34.c | SARD | 0 |
void bad() wchar_t * data ; data = NULL; if ( STATIC_CONST_FIVE == 5 ) wchar_t * dataBuffer = new wchar_t [ 100 ] ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer - 8; wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' memcpy ( dest , data , 100 * sizeof ( wchar_t ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 78559/CWE127_Buffer_Underread__new_wchar_t_memcpy_06.cpp | SARD | 3 |
static enum XML_Error internalEntityProcessor(XML_Parser const char const char const char **nextPtr) ENTITY * entity ; const char * textStart , * textEnd ; const char * next ; enum XML_Error result ; OPEN_INTERNAL_ENTITY * openEntity = openInternalEntities ; if ( ! openEntity ) entity = openEntity -> entity; textStart = ( ( char * ) entity -> textPtr ) + entity -> processed; textEnd = ( char * ) ( entity -> textPtr + entity -> textLen ); if ( entity -> is_param ) int tok = XmlPrologTok ( internalEncoding , textStart , textEnd , & next ) ; result = doProlog ( parser , internalEncoding , textStart , textEnd , tok , next , & next , XML_FALSE ); static enum doProlog(XML_Parser const ENCODING const char const char int const char const char XML_Bool haveMore) static const XML_Char externalSubsetName [ ] = { '#' , '\0' } ; static const XML_Char atypeCDATA [ ] = { 'C' , 'D' , 'A' , 'T' , 'A' , '\0' } ; static const XML_Char atypeID [ ] = { 'I' , 'D' , '\0' } ; static const XML_Char atypeIDREF [ ] = { 'I' , 'D' , 'R' , 'E' , 'F' , '\0' } ; static const XML_Char atypeIDREFS [ ] = { 'I' , 'D' , 'R' , 'E' , 'F' , 'S' , '\0' } ; static const XML_Char atypeENTITY [ ] = { 'E' , 'N' , 'T' , 'I' , 'T' , 'Y' , '\0' } ; static const XML_Char atypeENTITIES [ ] = { 'E' , 'N' , 'T' , 'I' , 'T' , 'I' , 'E' , 'S' , '\0' } ; static const XML_Char atypeNMTOKEN [ ] = { 'N' , 'M' , 'T' , 'O' , 'K' , 'E' , 'N' , '\0' } ; static const XML_Char atypeNMTOKENS [ ] = { 'N' , 'M' , 'T' , 'O' , 'K' , 'E' , 'N' , 'S' , '\0' } ; static const XML_Char notationPrefix [ ] = { 'N' , 'O' , 'T' , 'A' , 'T' , 'I' , 'O' , 'N' , '(' , '\0' } ; static const XML_Char enumValueSep [ ] = { '|' , '\0' } ; static const XML_Char enumValueStart [ ] = { '(' , '\0' } ; DTD * const dtd = _dtd const char * * eventPP ; enum XML_Content_Quant quant ; if ( enc == encoding ) eventPP = & eventPtr; eventPP = & ( openInternalEntities -> internalEventPtr ); int role ; XML_Bool handleDefault = XML_TRUE ; * eventPP = s; if ( tok <= 0 ) if ( haveMore && tok != XML_TOK_INVALID ) switch ( tok ) * eventPP = next; if ( enc != encoding && ! openInternalEntities -> betweenDecl ) * nextPtr = s; if ( isParamEntity || enc != encoding ) if ( XmlTokenRole ( & prologState , XML_TOK_NONE , end , end , enc ) == XML_ROLE_ERROR ) * nextPtr = s; tok = - tok; next = end; role = XmlTokenRole ( & prologState , tok , s , next , enc ); switch ( role ) enum XML_Error result = processXmlDecl ( parser , 0 , s , next ) ; if ( result != XML_ERROR_NONE ) enc = encoding; handleDefault = XML_FALSE; if ( startDoctypeDeclHandler ) doctypeName = poolStoreString ( & tempPool , enc , s , next ); if ( ! doctypeName ) doctypePubid = NULL; handleDefault = XML_FALSE; doctypeSysid = NULL; if ( startDoctypeDeclHandler ) doctypeName = NULL; handleDefault = XML_FALSE; enum XML_Error result = processXmlDecl ( parser , 1 , s , next ) ; if ( result != XML_ERROR_NONE ) enc = encoding; handleDefault = XML_FALSE; useForeignDTD = XML_FALSE; declEntity = ( ENTITY * ) lookup ( & dtd -> paramEntities , externalSubsetName , sizeof ( ENTITY ) ); if ( ! declEntity ) dtd -> hasParamEntityRefs = XML_TRUE; if ( startDoctypeDeclHandler ) if ( ! XmlIsPublicId ( enc , s , next , eventPP ) ) doctypePubid = poolStoreString ( & tempPool , enc , s + enc -> minBytesPerChar , next - enc -> minBytesPerChar ); if ( ! doctypePubid ) if ( ! XmlIsPublicId ( enc , s , next , eventPP ) ) if ( dtd -> keepProcessing && declEntity ) XML_Char * tem = poolStoreString ( & dtd -> pool , enc , s + enc -> minBytesPerChar , next - enc -> minBytesPerChar ) ; if ( ! tem ) declEntity -> publicId = tem; if ( entityDeclHandler ) handleDefault = XML_FALSE; if ( doctypeName ) handleDefault = XML_FALSE; if ( doctypeSysid || useForeignDTD ) XML_Bool hadParamEntityRefs = dtd -> hasParamEntityRefs ; dtd -> hasParamEntityRefs = XML_TRUE; if ( paramEntityParsing && externalEntityRefHandler ) ENTITY * entity = ( ENTITY * ) lookup ( & dtd -> paramEntities , externalSubsetName , sizeof ( ENTITY ) ) ; if ( ! entity ) if ( useForeignDTD ) entity -> base = curBase; dtd -> paramEntityRead = XML_FALSE; if ( ! externalEntityRefHandler ( externalEntityRefHandlerArg , 0 , entity -> base , entity -> systemId , entity -> publicId ) ) if ( dtd -> paramEntityRead ) if ( ! dtd -> standalone && notStandaloneHandler && ! notStandaloneHandler ( handlerArg ) ) if ( ! doctypeSysid ) dtd -> hasParamEntityRefs = hadParamEntityRefs; useForeignDTD = XML_FALSE; if ( endDoctypeDeclHandler ) handleDefault = XML_FALSE; if ( useForeignDTD ) XML_Bool hadParamEntityRefs = dtd -> hasParamEntityRefs ; dtd -> hasParamEntityRefs = XML_TRUE; if ( paramEntityParsing && externalEntityRefHandler ) ENTITY * entity = ( ENTITY * ) lookup ( & dtd -> paramEntities , externalSubsetName , sizeof ( ENTITY ) ) ; if ( ! entity ) entity -> base = curBase; dtd -> paramEntityRead = XML_FALSE; if ( ! externalEntityRefHandler ( externalEntityRefHandlerArg , 0 , entity -> base , entity -> systemId , entity -> publicId ) ) if ( dtd -> paramEntityRead ) dtd -> hasParamEntityRefs = hadParamEntityRefs; declElementType = getElementType ( parser , enc , s , next ); if ( ! declElementType ) declAttributeId = getAttributeId ( parser , enc , s , next ); if ( ! declAttributeId ) declAttributeIsCdata = XML_FALSE; declAttributeType = NULL; declAttributeIsId = XML_FALSE; declAttributeIsCdata = XML_TRUE; declAttributeType = atypeCDATA; declAttributeIsId = XML_TRUE; declAttributeType = atypeID; declAttributeType = atypeIDREF; declAttributeType = atypeIDREFS; declAttributeType = atypeENTITY; declAttributeType = atypeENTITIES; declAttributeType = atypeNMTOKEN; declAttributeType = atypeNMTOKENS; if ( dtd -> keepProcessing && attlistDeclHandler ) handleDefault = XML_FALSE; if ( dtd -> keepProcessing && attlistDeclHandler ) const XML_Char * prefix ; if ( declAttributeType ) prefix = enumValueSep; prefix = ( role == XML_ROLE_ATTRIBUTE_NOTATION_VALUE ? notationPrefix : enumValueStart ); if ( ! poolAppendString ( & tempPool , prefix ) ) if ( ! poolAppend ( & tempPool , enc , s , next ) ) declAttributeType = tempPool . start; handleDefault = XML_FALSE; if ( dtd -> keepProcessing ) if ( ! defineAttribute ( declElementType , declAttributeId , declAttributeIsCdata , declAttributeIsId , 0 , parser ) ) if ( attlistDeclHandler && declAttributeType ) if ( * declAttributeType == XML_T ( '(' ) || ( * declAttributeType == XML_T ( 'N' ) && declAttributeType [ 1 ] == XML_T ( 'O' ) ) ) if ( ! poolAppendChar ( & tempPool , XML_T ( ')' ) ) || ! poolAppendChar ( & tempPool , XML_T ( '\0' ) ) ) declAttributeType = tempPool . start; handleDefault = XML_FALSE; if ( dtd -> keepProcessing ) const XML_Char * attVal ; enum XML_Error result = storeAttributeValue ( parser , enc , declAttributeIsCdata , s + enc -> minBytesPerChar , next - enc -> minBytesPerChar , & dtd -> pool ) ; if ( result ) attVal = poolStart ( & dtd -> pool ); if ( ! defineAttribute ( declElementType , declAttributeId , declAttributeIsCdata , XML_FALSE , attVal , parser ) ) if ( attlistDeclHandler && declAttributeType ) if ( * declAttributeType == XML_T ( '(' ) || ( * declAttributeType == XML_T ( 'N' ) && declAttributeType [ 1 ] == XML_T ( 'O' ) ) ) if ( ! poolAppendChar ( & tempPool , XML_T ( ')' ) ) || ! poolAppendChar ( & tempPool , XML_T ( '\0' ) ) ) declAttributeType = tempPool . start; handleDefault = XML_FALSE; if ( dtd -> keepProcessing ) enum XML_Error result = storeEntityValue ( parser , enc , s + enc -> minBytesPerChar , next - enc -> minBytesPerChar ) ; if ( declEntity ) declEntity -> textPtr = poolStart ( & dtd -> entityValuePool ); declEntity -> textLen = ( int ) ( poolLength ( & dtd -> entityValuePool ) ); if ( result != XML_ERROR_NONE ) dtd -> hasParamEntityRefs = XML_TRUE; if ( startDoctypeDeclHandler ) doctypeSysid = poolStoreString ( & tempPool , enc , s + enc -> minBytesPerChar , next - enc -> minBytesPerChar ); if ( doctypeSysid == NULL ) handleDefault = XML_FALSE; && ! paramEntityParsing if ( dtd -> keepProcessing && declEntity ) declEntity -> systemId = poolStoreString ( & dtd -> pool , enc , s + enc -> minBytesPerChar , next - enc -> minBytesPerChar ); if ( ! declEntity -> systemId ) declEntity -> base = curBase; if ( entityDeclHandler ) handleDefault = XML_FALSE; if ( dtd -> keepProcessing && declEntity && entityDeclHandler ) handleDefault = XML_FALSE; if ( dtd -> keepProcessing && declEntity ) declEntity -> notation = poolStoreString ( & dtd -> pool , enc , s , next ); if ( ! declEntity -> notation ) if ( unparsedEntityDeclHandler ) handleDefault = XML_FALSE; if ( entityDeclHandler ) handleDefault = XML_FALSE; if ( XmlPredefinedEntityName ( enc , s , next ) ) declEntity = NULL; if ( dtd -> keepProcessing ) const XML_Char * name = poolStoreString ( & dtd -> pool , enc , s , next ) ; if ( ! name ) declEntity = ( ENTITY * ) lookup ( & dtd -> generalEntities , name , sizeof ( ENTITY ) ); if ( ! declEntity ) if ( declEntity -> name != name ) declEntity = NULL; declEntity -> publicId = NULL; declEntity -> is_param = XML_FALSE; declEntity -> is_internal = ! ( parentParser || openInternalEntities ); if ( entityDeclHandler ) handleDefault = XML_FALSE; declEntity = NULL; if ( dtd -> keepProcessing ) const XML_Char * name = poolStoreString ( & dtd -> pool , enc , s , next ) ; if ( ! name ) declEntity = ( ENTITY * ) lookup ( & dtd -> paramEntities , name , sizeof ( ENTITY ) ); if ( ! declEntity ) if ( declEntity -> name != name ) declEntity = NULL; declEntity -> publicId = NULL; declEntity -> is_param = XML_TRUE; declEntity -> is_internal = ! ( parentParser || openInternalEntities ); if ( entityDeclHandler ) handleDefault = XML_FALSE; declEntity = NULL; declNotationPublicId = NULL; declNotationName = NULL; if ( notationDeclHandler ) declNotationName = poolStoreString ( & tempPool , enc , s , next ); if ( ! declNotationName ) handleDefault = XML_FALSE; if ( ! XmlIsPublicId ( enc , s , next , eventPP ) ) if ( declNotationName ) XML_Char * tem = poolStoreString ( & tempPool , enc , s + enc -> minBytesPerChar , next - enc -> minBytesPerChar ) ; if ( ! tem ) declNotationPublicId = tem; handleDefault = XML_FALSE; if ( declNotationName && notationDeclHandler ) const XML_Char * systemId = poolStoreString ( & tempPool , enc , s + enc -> minBytesPerChar , next - enc -> minBytesPerChar ) ; if ( ! systemId ) handleDefault = XML_FALSE; if ( declNotationPublicId && notationDeclHandler ) handleDefault = XML_FALSE; enum XML_Error result ; handleDefault = XML_FALSE; result = doIgnoreSection ( parser , enc , & next , end , nextPtr , haveMore ); if ( result != XML_ERROR_NONE ) if ( ! next ) if ( prologState . level >= groupSize ) if ( groupSize ) char * temp = ( char * ) REALLOC ( groupConnector , groupSize *= 2 ) ; if ( temp == NULL ) groupConnector = temp; if ( dtd -> scaffIndex ) int * temp = ( int * ) REALLOC ( dtd -> scaffIndex , groupSize * sizeof ( int ) ) ; if ( temp == NULL ) dtd -> scaffIndex = temp; groupConnector = ( char * ) MALLOC ( groupSize = 32 ); if ( ! groupConnector ) groupConnector [ prologState . level ] = 0; if ( dtd -> in_eldecl ) int myindex = nextScaffoldPart ( parser ) ; if ( myindex < 0 ) dtd -> scaffIndex [ dtd -> scaffLevel ] = myindex; dtd -> scaffLevel ++; dtd -> scaffold [ myindex ] . type = XML_CTYPE_SEQ; if ( elementDeclHandler ) handleDefault = XML_FALSE; if ( groupConnector [ prologState . level ] == '|' ) groupConnector [ prologState . level ] = ','; if ( dtd -> in_eldecl && elementDeclHandler ) handleDefault = XML_FALSE; if ( groupConnector [ prologState . level ] == ',' ) if ( dtd -> in_eldecl && ! groupConnector [ prologState . level ] && ( dtd -> scaffold [ dtd -> scaffIndex [ dtd -> scaffLevel - 1 ] ] . type != XML_CTYPE_MIXED ) ) dtd -> scaffold [ dtd -> scaffIndex [ dtd -> scaffLevel - 1 ] ] . type = XML_CTYPE_CHOICE; if ( elementDeclHandler ) handleDefault = XML_FALSE; groupConnector [ prologState . level ] = '|'; dtd -> hasParamEntityRefs = XML_TRUE; if ( ! paramEntityParsing ) dtd -> keepProcessing = dtd -> standalone; const XML_Char * name ; ENTITY * entity ; name = poolStoreString ( & dtd -> pool , enc , s + enc -> minBytesPerChar , next - enc -> minBytesPerChar ); if ( ! name ) entity = ( ENTITY * ) lookup ( & dtd -> paramEntities , name , 0 ); if ( prologState . documentEntity && ( dtd -> standalone ? ! openInternalEntities : ! dtd -> hasParamEntityRefs ) ) if ( ! entity ) if ( ! entity -> is_internal ) if ( ! entity ) dtd -> keepProcessing = dtd -> standalone; if ( entity -> open ) if ( entity -> textPtr ) enum XML_Error result ; XML_Bool betweenDecl = ( role == XML_ROLE_PARAM_ENTITY_REF ? XML_TRUE : XML_FALSE ) ; result = processInternalEntity ( parser , entity , betweenDecl ); if ( result != XML_ERROR_NONE ) handleDefault = XML_FALSE; if ( externalEntityRefHandler ) dtd -> paramEntityRead = XML_FALSE; entity -> open = XML_TRUE; entity -> open = XML_FALSE; entity -> open = XML_FALSE; handleDefault = XML_FALSE; if ( ! dtd -> paramEntityRead ) dtd -> keepProcessing = dtd -> standalone; dtd -> keepProcessing = dtd -> standalone; if ( ! dtd -> standalone && notStandaloneHandler && ! notStandaloneHandler ( handlerArg ) ) if ( elementDeclHandler ) declElementType = getElementType ( parser , enc , s , next ); if ( ! declElementType ) dtd -> scaffLevel = 0; dtd -> scaffCount = 0; dtd -> in_eldecl = XML_TRUE; handleDefault = XML_FALSE; if ( dtd -> in_eldecl ) if ( elementDeclHandler ) XML_Content * content = ( XML_Content * ) MALLOC ( sizeof ( XML_Content ) ) ; if ( ! content ) handleDefault = XML_FALSE; dtd -> in_eldecl = XML_FALSE; if ( dtd -> in_eldecl ) dtd -> scaffold [ dtd -> scaffIndex [ dtd -> scaffLevel - 1 ] ] . type = XML_CTYPE_MIXED; if ( elementDeclHandler ) handleDefault = XML_FALSE; quant = XML_CQUANT_NONE; quant = XML_CQUANT_OPT; quant = XML_CQUANT_REP; quant = XML_CQUANT_PLUS; if ( dtd -> in_eldecl ) ELEMENT_TYPE * el ; const XML_Char * name ; int nameLen ; const char * nxt = ( quant == XML_CQUANT_NONE ? next : next - enc -> minBytesPerChar ) ; int myindex = nextScaffoldPart ( parser ) ; if ( myindex < 0 ) dtd -> scaffold [ myindex ] . type = XML_CTYPE_NAME; dtd -> scaffold [ myindex ] . quant = quant; el = getElementType ( parser , enc , s , nxt ); if ( ! el ) name = el -> name; dtd -> scaffold [ myindex ] . name = name; nameLen = 0; for (; name[nameLen++]; ); dtd -> contentStringLen += nameLen; if ( elementDeclHandler ) handleDefault = XML_FALSE; quant = XML_CQUANT_NONE; quant = XML_CQUANT_OPT; quant = XML_CQUANT_REP; quant = XML_CQUANT_PLUS; if ( dtd -> in_eldecl ) if ( elementDeclHandler ) handleDefault = XML_FALSE; dtd -> scaffLevel --; dtd -> scaffold [ dtd -> scaffIndex [ dtd -> scaffLevel ] ] . quant = quant; if ( dtd -> scaffLevel == 0 ) if ( ! handleDefault ) XML_Content * model = build_model ( parser ) ; if ( ! model ) dtd -> in_eldecl = XML_FALSE; dtd -> contentStringLen = 0; if ( ! reportProcessingInstruction ( parser , enc , s , next ) ) if ( ! reportComment ( parser , enc , s , next ) ) switch ( ps_parsing ) s = next; tok = XmlPrologTok ( enc , s , end , & next ); static XML_Char poolAppend(STRING_POOL *pool, const ENCODING const char *ptr, const char *end) if ( ! pool -> ptr && ! poolGrow ( pool ) ) static XML_Bool poolGrow(STRING_POOL *pool) if ( pool -> freeBlocks ) if ( pool -> start == 0 ) if ( pool -> end - pool -> start < pool -> freeBlocks -> size ) if ( pool -> blocks && pool -> start == pool -> blocks -> s ) BLOCK * tem ; int blockSize = ( int ) ( pool -> end - pool -> start ) ; if ( blockSize < INIT_BLOCK_SIZE ) blockSize = INIT_BLOCK_SIZE; blockSize *= 2; tem = ( BLOCK * ) pool -> mem -> malloc_fcn ( offsetof ( BLOCK , s ) + blockSize * sizeof ( XML_Char ) ); if ( ! tem ) tem -> size = blockSize; tem -> next = pool -> blocks; pool -> blocks = tem; if ( pool -> ptr != pool -> start ) memcpy ( tem -> s , pool -> start , ( pool -> ptr - pool -> start ) * sizeof ( XML_Char ) ); pool -> ptr = tem -> s + ( pool -> ptr - pool -> start ); pool -> start = tem -> s; pool -> end = tem -> s + blockSize; | CVE-2015-2716/Firefox_37.0b7_CVE_2015_2716_parser_expat_lib_xmlparse.c | NVD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( FILENAME_MAX - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; fclose ( pFile ); badSink ( & data ); void badSink(char * * dataPtr) char * data = * dataPtr ; pFile = FOPEN ( data , "wb+" ); if ( pFile != NULL ) fclose ( pFile ); | 96293/CWE36_Absolute_Path_Traversal__char_file_fopen_63a.cpp | SARD | 0 |
static void goodB2G() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); if ( data >= 0 && data < ( 10 ) ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( buffer ); | 70640/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_listen_socket_01.c | SARD | 0 |
static void goodG2B2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( STATIC_CONST_FIVE == 5 ) FILE * pFile ; HCRYPTPROV hCryptProv = 0 ; HCRYPTHASH hHash = 0 ; HCRYPTKEY hKey = 0 ; char hashData [ 100 ] = HASH_INPUT ; pFile = fopen ( "passwords.txt" , "r" ); if ( pFile != NULL ) data [ 0 ] = '\0'; BYTE payload [ ( 100 - 1 ) * sizeof ( char ) ] ; DWORD payloadBytes ; payloadBytes = decodeHexChars ( payload , sizeof ( payload ) , data ); size_t decodeHexChars(unsigned char * bytes, size_t numBytes, const char * hex) size_t numWritten = 0 ; while ( numWritten < numBytes && isxdigit ( hex [ 2 * numWritten ] ) && isxdigit ( hex [ 2 * numWritten + 1 ] ) ) int byte ; bytes [ numWritten ] = ( unsigned char ) byte; return numWritten ; if ( ! CryptAcquireContext ( & hCryptProv , NULL , MS_ENH_RSA_AES_PROV , PROV_RSA_AES , 0 ) ) if ( ! CryptCreateHash ( hCryptProv , CALG_SHA_256 , 0 , 0 , & hHash ) ) if ( ! CryptHashData ( hHash , ( BYTE * ) hashData , strlen ( hashData ) , 0 ) ) if ( ! CryptDeriveKey ( hCryptProv , CALG_AES_256 , hHash , 0 , & hKey ) ) if ( ! CryptDecrypt ( hKey , 0 , 1 , 0 , payload , & payloadBytes ) ) memcpy ( data , payload , payloadBytes ); data [ payloadBytes / sizeof ( char ) ] = '\0'; while ( 0 ) if ( LogonUserA ( username , domain , data , LOGON32_LOGON_NETWORK , LOGON32_PROVIDER_DEFAULT , & pHandle ) != 0 ) | 93407/CWE256_Plaintext_Storage_of_Password__w32_char_06.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; switch ( 6 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 89642/CWE23_Relative_Path_Traversal__char_connect_socket_ifstream_15.cpp | SARD | 0 |
static void goodG2B() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); myUnion . unionFirst = data; wchar_t * data = myUnion . unionSecond ; dataLen = wcslen ( data ); for (i = 0; i < dataLen; i++) dest [ i ] = data [ i ]; printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 72535/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_loop_34.c | SARD | 0 |
static VerifyStyleTree(nsPresContext* aPresContext, nsIFrame* nsStyleContext* aParentContext) nsIFrame :: ChildListIterator lists ( aFrame ) ; for (; !lists.IsDone(); lists.Next()) nsFrameList :: Enumerator childFrames ( lists . CurrentList ( ) ) ; for (; !childFrames.AtEnd(); childFrames.Next()) nsIFrame * child = childFrames . get ( ) ; if ( ! ( child -> GetStateBits ( ) & NS_FRAME_OUT_OF_FLOW ) ) if ( nsGkAtoms :: placeholderFrame == child -> GetType ( ) ) nsIFrame * outOfFlowFrame = nsPlaceholderFrame :: GetRealFrameForPlaceholder ( child ) ; VerifyStyleTree ( aPresContext , outOfFlowFrame , nullptr ); while ( outOfFlowFrame = outOfFlowFrame -> GetNextContinuation ( ) ) static VerifyStyleTree(nsPresContext* aPresContext, nsIFrame* nsStyleContext* aParentContext) nsStyleContext * context = aFrame -> StyleContext ( ) ; VerifyContextParent ( aPresContext , aFrame , context , nullptr ); static VerifyContextParent(nsPresContext* aPresContext, nsIFrame* nsStyleContext* aContext, nsStyleContext* aParentContext) if ( ! aContext ) aContext = aFrame -> StyleContext ( ); if ( ! aParentContext ) nsIFrame * providerFrame = aFrame -> GetParentStyleContextFrame ( ) ; if ( providerFrame ) aParentContext = providerFrame -> StyleContext ( ); nsStyleContext * actualParentContext = aContext -> GetParent ( ) ; if ( aParentContext ) if ( actualParentContext ) DumpContext ( nullptr , actualParentContext ); static DumpContext(nsIFrame* aFrame, nsStyleContext* aContext) if ( aFrame ) fprintf ( stdout , " (%p)" , static_cast < void * > ( aFrame ) ) if ( aContext ) fprintf ( stdout , " style: %p " , static_cast < void * > ( aContext ) ) nsIAtom * pseudoTag = aContext -> GetPseudo ( ) ; if ( pseudoTag ) fputs ( " " , stdout ); | CVE-2015-0826/Firefox_35.0b8_CVE_2015_0826_layout_base_RestyleManager.cpp | NVD | 0 |
void CWE78_OS_Command_Injection__char_listen_socket_w32spawnl_54_bad() 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 , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 120231/CWE78_OS_Command_Injection__char_listen_socket_w32spawnl_54a.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 ); 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 ) for (i = 0; i < work_mbc -> ncoll_elems; i++) op_len = ( strlen ( work_mbc -> coll_elems [ i ] ) ); strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> coll_elems [ i ] , buffer ) == 0 ) | 153297/dfa.c | SARD | 0 |
static void goodG2B2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticFive == 5 ) strcpy ( data , "fixedstringtest" ); goodG2B2VaSinkB ( data , data ); static void goodG2B2VaSinkB(char * data, ...) va_start ( args , data ); vsnprintf ( dest , 100 - 1 , data , args ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 79344/CWE134_Uncontrolled_Format_String__char_connect_socket_w32_vsnprintf_07.c | SARD | 0 |
static void goodB2G() size_t data ; size_t * dataPtr2 = & data ; data = 0; 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 ) size_t data = * dataPtr2 ; if ( data > wcslen ( HELLO_STRING ) && data < 100 ) | 117244/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_connect_socket_32.c | SARD | 0 |
static void goodB2G() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); goodB2GSink_b ( data ); void goodB2GSink_b(wchar_t * data) goodB2GSink_c ( data ); void goodB2GSink_c(wchar_t * data) goodB2GSink_d ( data ); void goodB2GSink_d(wchar_t * data) free ( data ); | 115048/CWE762_Mismatched_Memory_Management_Routines__delete_wchar_t_malloc_53a.cpp | SARD | 0 |
static int stonesoup_ev_handler(struct mg_connection *conn, enum mg_event ev) char * ifmatch_header ; char * stonesoup_tainted_buff ; int buffer_size = 1000 ; if ( ev == MG_REQUEST ) ifmatch_header = ( char * ) mg_get_header ( conn , "if-match" ); if ( strcmp ( ifmatch_header , "weak_taint_source_value" ) == 0 ) while ( 1 ) stonesoup_tainted_buff = ( char * ) malloc ( buffer_size * sizeof ( char ) ); data_size = mg_get_var ( conn , "data" , stonesoup_tainted_buff , buffer_size * sizeof ( char ) ); if ( data_size < buffer_size ) buffer_size = buffer_size * 2; stonesoup_handle_taint ( stonesoup_tainted_buff ); void stonesoup_handle_taint(char *tinned_goran) struct stonesoup_data * stonesoupData ; if ( tinned_goran != 0 ) intreating_hoddypeak = ( ( char * ) tinned_goran ); stonesoupData = malloc ( sizeof ( struct stonesoup_data ) ); if ( stonesoupData ) stonesoupData -> data = malloc ( sizeof ( char ) * ( strlen ( intreating_hoddypeak ) + 1 ) ); stonesoupData -> file1 = malloc ( sizeof ( char ) * ( strlen ( intreating_hoddypeak ) + 1 ) ); stonesoupData -> file2 = malloc ( sizeof ( char ) * ( strlen ( intreating_hoddypeak ) + 1 ) ); if ( stonesoupData -> data ) if ( ( sscanf ( intreating_hoddypeak , "%d %s %s %s" , & ( stonesoupData -> qsize ) , stonesoupData -> file1 , stonesoupData -> file2 , stonesoupData -> data ) == 4 ) && ( strlen ( stonesoupData -> data ) != 0 ) && ( strlen ( stonesoupData -> file1 ) != 0 ) && ( strlen ( stonesoupData -> file2 ) != 0 ) ) pthread_mutex_init ( & stonesoup_mutex_0 , NULL ); | 150089/color.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); funcPtr ( data ); | 95757/CWE36_Absolute_Path_Traversal__char_connect_socket_w32CreateFile_44.cpp | SARD | 0 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; 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'; CWE134_Uncontrolled_Format_String__char_listen_socket_snprintf_45_goodB2GData = data; | 80374/CWE134_Uncontrolled_Format_String__char_listen_socket_snprintf_45.c | SARD | 0 |
static void goodG2B1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; data = CWE114_Process_Control__w32_char_relativePath_22_goodG2B1Source ( data ); char * CWE114_Process_Control__w32_char_relativePath_22_goodG2B1Source(char * data) if ( CWE114_Process_Control__w32_char_relativePath_22_goodG2B1Global ) strcpy ( data , "C:\\Windows\\System32\\winsrv.dll" ); return data ; HMODULE hModule ; hModule = LoadLibraryA ( data ); if ( hModule != NULL ) FreeLibrary ( hModule ); | 62199/CWE114_Process_Control__w32_char_relativePath_22a.c | SARD | 0 |
static int stonesoup_ev_handler(struct mg_connection *conn, enum mg_event ev) char * ifmatch_header ; char * stonesoup_tainted_buff ; int buffer_size = 1000 ; if ( ev == MG_REQUEST ) ifmatch_header = ( char * ) mg_get_header ( conn , "if-match" ); if ( strcmp ( ifmatch_header , "weak_taint_source_value" ) == 0 ) while ( 1 ) stonesoup_tainted_buff = ( char * ) malloc ( buffer_size * sizeof ( char ) ); data_size = mg_get_var ( conn , "data" , stonesoup_tainted_buff , buffer_size * sizeof ( char ) ); if ( data_size < buffer_size ) buffer_size = buffer_size * 2; stonesoup_handle_taint ( stonesoup_tainted_buff ); void stonesoup_handle_taint(char *scarletberry_morra) if ( scarletberry_morra != 0 ) cotoro_ambusher = ( ( int ) ( strlen ( scarletberry_morra ) ) ); deutsch_upgrading = ( ( char * ) ( malloc ( cotoro_ambusher + 1 ) ) ); if ( deutsch_upgrading == 0 ) memset ( deutsch_upgrading , 0 , cotoro_ambusher + 1 ); memcpy ( deutsch_upgrading , scarletberry_morra , cotoro_ambusher ); osi_talismans [ 5 ] = deutsch_upgrading; terrierlike_thay = * ( osi_talismans + frolick_ashok [ 1 ] ); potentiated_tumbledown = ( ( char * ) terrierlike_thay ); stonesoup_pFile = fopen ( potentiated_tumbledown , "r" ); tracepoint ( stonesoup_trace , variable_address , "stonesoup_pFile" , stonesoup_pFile , "TRIGGER-STATE" ); fgets ( stonesoup_buffer , 79 , stonesoup_pFile ); stonesoup_printf ( stonesoup_buffer ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); mg_vprintf_data ( ( struct mg_connection * ) stonesoup_printf_context , format , argptr ); fclose ( stonesoup_pFile ); if ( terrierlike_thay != 0 ) free ( ( ( char * ) terrierlike_thay ) ); | 149798/dynahash.c | SARD | 2 |
void parse_dir_colors() char * * arg ; char * * c ; char * colors ; char * s ; int i ; if ( Hflag ) if ( getenv ( "TERM" ) == ( ( void * ) 0 ) ) s = getenv ( "TREE_COLORS" ); if ( s == ( ( void * ) 0 ) ) s = getenv ( "LS_COLORS" ); if ( ( s == ( ( void * ) 0 ) || strlen ( s ) == 0 ) && force_color ) s = ":no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.bat=01;32:*.BAT=01;32:*.btm=01;32:*.BTM=01;32:*.cmd=01;32:*.CMD=01;32:*.com=01;32:*.COM=01;32:*.dll=01;32:*.DLL=01;32:*.exe=01;32:*.EXE=01;32:*.arj=01;31:*.bz2=01;31:*.deb=01;31:*.gz=01;31:*.lzh=01;31:*.rpm=01;31:*.tar=01;31:*.taz=01;31:*.tb2=01;31:*.tbz2=01;31:*.tbz=01;31:*.tgz=01;31:*.tz2=01;31:*.z=01;31:*.Z=01;31:*.zip=01;31:*.ZIP=01;31:*.zoo=01;31:*.asf=01;35:*.ASF=01;35:*.avi=01;35:*.AVI=01;35:*.bmp=01;35:*.BMP=01;35:*.flac=01;35:*.FLAC=01;35:*.gif=01;35:*.GIF=01;35:*.jpg=01;35:*.JPG=01;35:*.jpeg=01;35:*.JPEG=01;35:*.m2a=01;35:*.M2a=01;35:*.m2v=01;35:*.M2V=01;35:*.mov=01;35:*.MOV=01;35:*.mp3=01;35:*.MP3=01;35:*.mpeg=01;35:*.MPEG=01;35:*.mpg=01;35:*.MPG=01;35:*.ogg=01;35:*.OGG=01;35:*.ppm=01;35:*.rm=01;35:*.RM=01;35:*.tga=01;35:*.TGA=01;35:*.tif=01;35:*.TIF=01;35:*.wav=01;35:*.WAV=01;35:*.wmv=01;35:*.WMV=01;35:*.xbm=01;35:*.xpm=01;35:"; if ( s == ( ( void * ) 0 ) || ! force_color && ( nocolor || ! isatty ( 1 ) ) ) colors = strcpy ( ( xmalloc ( strlen ( s ) + 1 ) ) , s ); arg = split ( colors , ":" , & n ); char **split(char *str,char *delim,int *nwrds) int n = 128 ; char * * w = ( xmalloc ( sizeof ( char * ) * n ) ) ; w [ * nwrds = 0 ] = strtok ( str , delim ); while ( w [ * nwrds ] ) if ( * nwrds == n - 2 ) w = ( xrealloc ( w , sizeof ( char * ) * ( n += 256 ) ) ); w [ ++ * nwrds ] = strtok ( ( ( void * ) 0 ) , delim ); w [ * nwrds ] = ( ( void * ) 0 ); return w ; for (i = 0; arg[i]; i++) c = split ( arg [ i ] , "=" , & n ); char **split(char *str,char *delim,int *nwrds) int n = 128 ; char * * w = ( xmalloc ( sizeof ( char * ) * n ) ) ; w [ * nwrds = 0 ] = strtok ( str , delim ); while ( w [ * nwrds ] ) if ( * nwrds == n - 2 ) w = ( xrealloc ( w , sizeof ( char * ) * ( n += 256 ) ) ); w [ ++ * nwrds ] = strtok ( ( ( void * ) 0 ) , delim ); w [ * nwrds ] = ( ( void * ) 0 ); return w ; switch ( cmd ( c [ 0 ] ) ) int cmd(char *s) static struct { char * cmd ; char cmdnum ; } cmds [ ] = { { ( "no" ) , ( COL_NORMAL ) } , { ( "fi" ) , ( COL_FILE ) } , { ( "di" ) , ( COL_DIR ) } , { ( "ln" ) , ( COL_LINK ) } , { ( "pi" ) , ( COL_FIFO ) } , { ( "do" ) , ( COL_DOOR ) } , { ( "bd" ) , ( COL_BLK ) } , { ( "cd" ) , ( COL_CHR ) } , { ( "or" ) , ( COL_ORPHAN ) } , { ( "so" ) , ( COL_SOCK ) } , { ( "su" ) , ( COL_SETUID ) } , { ( "sg" ) , ( COL_SETGID ) } , { ( "tw" ) , ( COL_STICKY_OTHER_WRITABLE ) } , { ( "ow" ) , ( COL_OTHER_WRITABLE ) } , { ( "st" ) , ( COL_STICKY ) } , { ( "ex" ) , ( COL_EXEC ) } , { ( "mi" ) , ( COL_MISSING ) } , { ( "lc" ) , ( COL_LEFTCODE ) } , { ( "rc" ) , ( COL_RIGHTCODE ) } , { ( "ec" ) , ( COL_ENDCODE ) } , { ( ( ( void * ) 0 ) ) , ( 0 ) } } ; int i ; for (i = 0; cmds[i] . cmdnum; i++) if ( ! strcmp ( cmds [ i ] . cmd , s ) ) return cmds [ i ] . cmdnum ; if ( s [ 0 ] == '*' ) return DOT_EXTENSION ; return ERROR ; if ( c [ 1 ] ) dir_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); | 153746/color.c | SARD | 0 |
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( GLOBAL_CONST_TRUE ) size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; goodB2G1VaSinkG ( data , data ); static void goodB2G1VaSinkG(char * data, ...) va_start ( args , data ); | 80162/CWE134_Uncontrolled_Format_String__char_file_vprintf_09.c | SARD | 0 |
static void good1() if ( globalReturnsFalse ( ) ) int globalReturnsFalse() return 0 ; size_t i ; pFile = fopen ( "password.txt" , "r" ); for (i = 0; i < SHA512_SUM_SIZE; i++) ULONG val ; if ( val > 0xff ) fclose ( pFile ); | 94558/CWE328_Reversible_One_Way_Hash__w32_SHA1_11.c | SARD | 0 |
static void goodB2G1() 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'; fclose ( pFile ); printf ( "%s\n" , data ); | 80020/CWE134_Uncontrolled_Format_String__char_file_printf_11.c | SARD | 0 |
static void goodG2B1() short data ; data = 0; if ( globalFive != 5 ) 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 ); | 87019/CWE194_Unexpected_Sign_Extension__listen_socket_strncpy_14.c | SARD | 0 |
int av_read_frame(AVFormatContext *s,AVPacket *pkt) const int genpts = s -> flags & 0x1 ; int ret ; if ( ! genpts ) ret = ( s -> packet_buffer ? read_from_packet_buffer ( & s -> packet_buffer , & s -> packet_buffer_end , pkt ) : read_frame_internal ( s , pkt ) ); static int read_frame_internal(AVFormatContext *s,AVPacket *pkt) int got_packet = 0 ; while ( ! got_packet && ! s -> parse_queue ) AVStream * st ; AVPacket cur_pkt ; ret = ff_read_packet ( s , & cur_pkt ); if ( ret < 0 ) st = s -> streams [ cur_pkt . stream_index ]; if ( st -> need_parsing && ! st -> parser && ! ( s -> flags & 0x20 ) ) st -> parser = av_parser_init ( ( st -> codec -> codec_id ) ); if ( ! st -> parser ) st -> need_parsing = AVSTREAM_PARSE_NONE; if ( ( st -> need_parsing ) == AVSTREAM_PARSE_HEADERS ) st -> parser -> flags |= 0x1; if ( ( st -> need_parsing ) == AVSTREAM_PARSE_FULL_ONCE ) st -> parser -> flags |= 0x0002; if ( ( st -> need_parsing ) == AVSTREAM_PARSE_FULL_RAW ) st -> parser -> flags |= 0x1000; if ( ! st -> need_parsing || ! st -> parser ) * pkt = cur_pkt; got_packet = 1; if ( ( st -> discard ) < AVDISCARD_ALL ) if ( ( ret = parse_packet ( s , & cur_pkt , cur_pkt . stream_index ) ) < 0 ) if ( pkt -> flags & 0x1 ) st -> skip_to_keyframe = 0; if ( st -> skip_to_keyframe ) if ( got_packet ) * pkt = cur_pkt; got_packet = 0; int ff_read_packet(AVFormatContext *s,AVPacket *pkt) int ret ; AVStream * st ; AVPacketList * pktl = s -> raw_packet_buffer ; if ( pktl ) * pkt = pktl -> pkt; st = s -> streams [ pkt -> stream_index ]; if ( st -> request_probe <= 0 ) pkt -> data = ( ( void * ) 0 ); pkt -> size = 0; ret = ( ( s -> iformat -> read_packet ) ( s , pkt ) ); if ( ret < 0 ) if ( ! pktl || ret == - '\v' ) if ( s -> flags & 0x0100 && pkt -> flags & 0x0002 ) if ( ( pkt -> stream_index ) >= ( ( unsigned int ) ( s -> nb_streams ) ) ) st = s -> streams [ pkt -> stream_index ]; pkt -> dts = wrap_timestamp ( st , pkt -> dts ); pkt -> pts = wrap_timestamp ( st , pkt -> pts ); if ( s -> use_wallclock_as_timestamps ) pkt -> dts = pkt -> pts = av_rescale_q ( av_gettime ( ) , ( ( AVRational ) ( 1 ) , ( 1000000 ) ) , st -> time_base ) if ( ! pktl && st -> request_probe <= 0 ) s -> raw_packet_buffer_remaining_size -= pkt -> size; probe_codec ( s , st , pkt ); static void probe_codec(AVFormatContext *s,AVStream *st,const AVPacket *pkt) if ( st -> request_probe > 0 ) AVProbeData * pd = & st -> probe_data ; if ( pkt ) uint8_t * new_buf = ( av_realloc ( ( pd -> buf ) , ( pd -> buf_size + pkt -> size + 32 ) ) ) ; if ( ! new_buf ) pd -> buf = new_buf; memcpy ( ( pd -> buf + pd -> buf_size ) , ( pkt -> data ) , ( pkt -> size ) ); pd -> buf_size += pkt -> size; memset ( ( pd -> buf + pd -> buf_size ) , 0 , 32 ); if ( end || ff_log2_c ( ( pd -> buf_size ) ) != ff_log2_c ( ( pd -> buf_size - pkt -> size ) ) ) int score = set_codec_from_probe_data ( s , st , pd ) ; if ( ( st -> codec -> codec_id ) != AV_CODEC_ID_NONE && score > 100 / 4 || end ) pd -> buf_size = 0; av_freep ( ( & pd -> buf ) ); | 150142/utils.c | SARD | 0 |
static void goodB2G2() 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 , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 109141/CWE606_Unchecked_Loop_Condition__char_listen_socket_22a.c | SARD | 0 |
unsigned int gzwfile_write(GZWFILE_T state,const void *buf,unsigned int len) unsigned int n ; z_streamp strm ; strm = & state -> strm; if ( state -> err != 0 ) if ( len == 0 ) if ( state -> size == 0 && gz_init ( state ) == - 1 ) static int gz_init(GZWFILE_T state) int ret ; z_streamp strm = & state -> strm ; state -> in = ( ( unsigned char * ) ( g_try_malloc ( ( state -> want ) ) ) ); state -> out = ( ( unsigned char * ) ( g_try_malloc ( ( state -> want ) ) ) ); if ( state -> in == ( ( void * ) 0 ) || state -> out == ( ( void * ) 0 ) ) return - 1 ; strm -> zalloc = 0; strm -> zfree = 0; strm -> opaque = 0; ret = deflateInit2_ ( strm , state -> level , 8 , 15 + 16 , 8 , state -> strategy , "1.2.8" , ( ( int ) ( sizeof ( z_stream ) ) ) ); if ( ret != 0 ) return - 1 ; return 0 ; if ( len < state -> size ) if ( strm -> avail_in == 0 ) strm -> next_in = state -> in; n = state -> size - strm -> avail_in; if ( n > len ) n = len; memcpy ( ( strm -> next_in + strm -> avail_in ) , buf , n ); strm -> avail_in += n; state -> pos += n; buf = ( ( ( char * ) buf ) + n ); len -= n; if ( len && gz_comp ( state , 0 ) == - 1 ) static int gz_comp(GZWFILE_T state,int flush) z_streamp strm = & state -> strm ; if ( state -> size == 0 && gz_init ( state ) == - 1 ) static int gz_init(GZWFILE_T state) z_streamp strm = & state -> strm ; state -> in = ( ( unsigned char * ) ( g_try_malloc ( ( state -> want ) ) ) ); state -> out = ( ( unsigned char * ) ( g_try_malloc ( ( state -> want ) ) ) ); if ( state -> in == ( ( void * ) 0 ) || state -> out == ( ( void * ) 0 ) ) g_free ( ( state -> out ) ); g_free ( ( state -> in ) ); state -> err = 12; strm -> zalloc = 0; strm -> zfree = 0; strm -> opaque = 0; ret = deflateInit2_ ( strm , state -> level , 8 , 15 + 16 , 8 , state -> strategy , "1.2.8" , ( ( int ) ( sizeof ( z_stream ) ) ) ); if ( ret != 0 ) g_free ( ( state -> out ) ); g_free ( ( state -> in ) ); if ( ret == - 4 ) state -> err = 12; state -> err = - 22; state -> size = state -> want; strm -> avail_out = state -> size; strm -> next_out = state -> out; state -> next = strm -> next_out; if ( strm -> avail_out == 0 || flush != 0 && ( flush != 4 || ret == 1 ) ) have = ( ( unsigned int ) ( strm -> next_out - state -> next ) ); if ( have ) got = ( write ( state -> fd , ( state -> next ) , have ) ); if ( got < 0 ) state -> err = * __errno_location ( ); if ( ( ( unsigned int ) got ) != have ) state -> err = - 14; if ( strm -> avail_out == 0 ) strm -> avail_out = state -> size; strm -> next_out = state -> out; state -> next = strm -> next_out; have = strm -> avail_out; ret = deflate ( strm , flush ); if ( ret == - 2 ) state -> err = - 22; have -= strm -> avail_out; while ( have ) if ( flush == 4 ) deflateReset ( strm ); while ( len ) | 151288/file_wrappers.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[]) position pos ; size_t i ; for (i = 0; i < d -> states[s] . elems . nelem; ++i) pos = d -> states [ s ] . elems . elems [ i ]; if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) ) if ( d -> tokens [ pos . index ] >= CSET ) if ( 1 && ( d -> tokens [ pos . index ] == ANYCHAR || d -> tokens [ pos . index ] == MBCSET ) ) if ( d -> states [ s ] . mbps . nelem == 0 ) alloc_position_set ( & d -> states [ s ] . mbps , 1 ); 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; | 151912/dfa.c | SARD | 0 |
static void PgstatCollectorMain(int argc,char *argv[]) int len ; PgStat_Msg msg ; int wr ; if ( need_exit ) while ( ! need_exit ) len = ( recv ( pgStatSock , ( ( char * ) ( & msg ) ) , sizeof ( PgStat_Msg ) , 0 ) ); if ( len < 0 ) if ( * __errno_location ( ) == 11 || * __errno_location ( ) == 11 || * __errno_location ( ) == 4 ) if ( len < sizeof ( PgStat_MsgHdr ) ) if ( msg . msg_hdr . m_size != len ) switch ( msg . msg_hdr . m_type ) pgstat_recv_resetcounter ( ( ( PgStat_MsgResetcounter * ) ( & msg ) ) , len ); wr = WaitLatchOrSocket ( ( & pgStatLatch ) , 1 << 0 | 1 << 4 | 1 << 1 , pgStatSock , - 1L ); if ( wr & 1 << 4 ) static void pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg,int len) PgStat_StatDBEntry * dbentry ; dbentry = pgstat_get_db_entry ( msg -> m_databaseid , ( ( bool ) 0 ) ); static PgStat_StatDBEntry *pgstat_get_db_entry(Oid databaseid,bool create) bool found ; if ( ! create && ! found ) if ( ! found ) memset ( ( & hash_ctl ) , 0 , sizeof ( hash_ctl ) ); | 151496/pgstat.c | SARD | 0 |
void CWE114_Process_Control__w32_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 ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); hModule = LoadLibraryA ( data ); if ( hModule != NULL ) FreeLibrary ( hModule ); | 61957/CWE114_Process_Control__w32_char_connect_socket_18.c | SARD | 14 |
void CWE319_Cleartext_Tx_Sensitive_Info__w32_char_connect_socket_54_bad() char * password ; char passwordBuffer [ 100 ] = "" ; password = passwordBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t passwordLen = strlen ( password ) ; 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 * ) ( password + passwordLen ) , ( 100 - passwordLen - 1 ) * sizeof ( char ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) password [ passwordLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( password , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( password , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( connectSocket != INVALID_SOCKET ) closesocket ( connectSocket ); CWE319_Cleartext_Tx_Sensitive_Info__w32_char_connect_socket_54b_badSink ( password ); void CWE319_Cleartext_Tx_Sensitive_Info__w32_char_connect_socket_54b_badSink(char * password) CWE319_Cleartext_Tx_Sensitive_Info__w32_char_connect_socket_54c_badSink ( password ); void CWE319_Cleartext_Tx_Sensitive_Info__w32_char_connect_socket_54c_badSink(char * password) CWE319_Cleartext_Tx_Sensitive_Info__w32_char_connect_socket_54d_badSink ( password ); void CWE319_Cleartext_Tx_Sensitive_Info__w32_char_connect_socket_54d_badSink(char * password) CWE319_Cleartext_Tx_Sensitive_Info__w32_char_connect_socket_54e_badSink ( password ); void CWE319_Cleartext_Tx_Sensitive_Info__w32_char_connect_socket_54e_badSink(char * password) if ( LogonUserA ( username , domain , password , LOGON32_LOGON_NETWORK , LOGON32_PROVIDER_DEFAULT , & pHandle ) != 0 ) | 94130/CWE319_Cleartext_Tx_Sensitive_Info__w32_char_connect_socket_54a.c | SARD | 32 |
void CWE78_OS_Command_Injection__wchar_t_file_w32_spawnvp_54_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 ); | 122199/CWE78_OS_Command_Injection__wchar_t_file_w32_spawnvp_54a.c | SARD | 0 |
static void goodG2B() int * data ; data = ( int * ) malloc ( 10 * sizeof ( int ) ); CWE122_Heap_Based_Buffer_Overflow__CWE131_memcpy_53b_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__CWE131_memcpy_53b_goodG2BSink(int * data) CWE122_Heap_Based_Buffer_Overflow__CWE131_memcpy_53c_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__CWE131_memcpy_53c_goodG2BSink(int * data) CWE122_Heap_Based_Buffer_Overflow__CWE131_memcpy_53d_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__CWE131_memcpy_53d_goodG2BSink(int * data) memcpy ( data , source , 10 * sizeof ( int ) ); printIntLine ( data [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( data ); | 69855/CWE122_Heap_Based_Buffer_Overflow__CWE131_memcpy_53a.c | SARD | 0 |
void CWE606_Unchecked_Loop_Condition__char_console_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'; | 108990/CWE606_Unchecked_Loop_Condition__char_console_13.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 ; if ( left == ( ( void * ) 0 ) || right == ( ( void * ) 0 ) ) cpp = ( malloc ( sizeof ( ( * cpp ) ) ) ); if ( cpp == ( ( void * ) 0 ) ) cpp [ 0 ] = ( ( void * ) 0 ); char * * p = enlist ( cpp , lcp , len ) ; if ( p == ( ( void * ) 0 ) ) freelist ( cpp ); static void freelist(char **cpp) if ( cpp == ( ( void * ) 0 ) ) for (i = 0; cpp[i] != ((void *)0); ++i) free ( cpp [ i ] ); cpp [ i ] = ( ( void * ) 0 ); cpp = p; return cpp ; | 149947/dfa.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 ; token t ; static must must0 ; struct dfamust * dm ; static char empty_string [ ] = "" ; result = empty_string; musts = ( ( sizeof ( ( * musts ) ) == 1 ? xmalloc ( d -> tindex + 1 ) : xnmalloc ( d -> tindex + 1 , sizeof ( ( * musts ) ) ) ) ); while ( 0 ) mp = musts; for (i = 0; i <= d -> tindex; ++i) mp [ i ] = must0; for (i = 0; i <= d -> tindex; ++i) mp [ i ] . in = ( xmalloc ( sizeof ( ( * mp [ i ] . in ) ) ) ); mp [ i ] . left = ( xmalloc ( 2 ) ); mp [ i ] . right = ( xmalloc ( 2 ) ); mp [ i ] . is = ( xmalloc ( 2 ) ); mp [ i ] . left [ 0 ] = mp [ i ] . right [ 0 ] = mp [ i ] . is [ 0 ] = '\0'; mp [ i ] . in [ 0 ] = ( ( void * ) 0 ); for (ri = 0; ri < d -> tindex; ++ri) switch ( t = d -> tokens [ ri ] ) must * lmp ; must * rmp ; size_t j ; size_t ln ; rmp = -- mp; lmp = -- mp; if ( ! ( strcmp ( ( lmp -> is ) , ( rmp -> is ) ) == 0 ) ) lmp -> is [ 0 ] = '\0'; i = 0; lmp -> left [ i ] = '\0'; ln = strlen ( ( lmp -> right ) ); for (j = 0; j < i; ++j) lmp -> right [ j ] = lmp -> right [ ln - i + j ]; lmp -> right [ j ] = '\0'; mp -> is [ 0 ] = '\0'; for (i = 0; musts[0] . in[i] != ((void *)0); ++i) if ( strlen ( musts [ 0 ] . in [ i ] ) > strlen ( result ) ) result = musts [ 0 ] . in [ i ]; must * lmp ; must * rmp ; rmp = -- mp; lmp = -- mp; lmp -> in = addlists ( lmp -> in , rmp -> in ); if ( lmp -> in == ( ( void * ) 0 ) ) if ( lmp -> right [ 0 ] != '\0' && rmp -> left [ 0 ] != '\0' ) char * tp ; tp = icpyalloc ( ( lmp -> right ) ); static char *icpyalloc(const char *string) return icatalloc ( ( ( void * ) 0 ) , string ) ; tp = icatalloc ( tp , ( rmp -> left ) ); lmp -> in = enlist ( lmp -> in , tp , strlen ( tp ) ); if ( lmp -> in == ( ( void * ) 0 ) ) if ( lmp -> is [ 0 ] != '\0' ) lmp -> left = icatalloc ( lmp -> left , ( rmp -> left ) ); if ( lmp -> left == ( ( void * ) 0 ) ) if ( rmp -> is [ 0 ] == '\0' ) lmp -> right [ 0 ] = '\0'; lmp -> right = icatalloc ( lmp -> right , ( rmp -> right ) ); if ( lmp -> right == ( ( void * ) 0 ) ) if ( lmp -> is [ 0 ] != '\0' && rmp -> is [ 0 ] != '\0' ) lmp -> is = icatalloc ( lmp -> is , ( rmp -> is ) ); if ( lmp -> is == ( ( void * ) 0 ) ) lmp -> is [ 0 ] = '\0'; if ( t < END ) if ( t == '\0' ) if ( t >= CSET || ! 1 || t == ANYCHAR || t == MBCSET ) mp -> is [ 0 ] = mp -> left [ 0 ] = mp -> right [ 0 ] = t; mp -> is [ 1 ] = mp -> left [ 1 ] = mp -> right [ 1 ] = '\0'; mp -> in = enlist ( mp -> in , mp -> is , ( ( size_t ) 1 ) ); if ( mp -> in == ( ( void * ) 0 ) ) 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; for (i = 0; i <= d -> tindex; ++i) | 153511/dfa.c | SARD | 0 |
static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) int maxlen = 0 ; size_t i ; size_t nelem = d -> states [ s ] . mbps . nelem ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) status_transit_state rs ; rs = transit_state_singlebyte ( d , s , * pp , & s1 ); static status_transit_state transit_state_singlebyte(struct dfa *d,state_num s,const unsigned char *p,state_num *next_state) state_num * t ; state_num works = s ; status_transit_state rval = TRANSIT_STATE_IN_PROGRESS ; while ( rval == TRANSIT_STATE_IN_PROGRESS ) if ( ( t = d -> trans [ works ] ) != ( ( void * ) 0 ) ) works = t [ * p ]; rval = TRANSIT_STATE_DONE; if ( works < 0 ) works = 0; if ( works < 0 ) works = 0; if ( d -> fails [ works ] ) works = d -> fails [ works ] [ * p ]; rval = TRANSIT_STATE_DONE; build_state ( works , d ); static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) leaf_set * grps ; charclass * labels ; size_t ngrps = 0 ; position pos ; charclass matches ; int matchesf ; charclass intersect ; int intersectf ; charclass leftovers ; int leftoversf ; size_t i ; size_t j ; size_t k ; grps = ( ( sizeof ( ( * grps ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * grps ) ) ) ) ); while ( 0 ) labels = ( ( sizeof ( ( * labels ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * labels ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . elems . nelem; ++i) pos = d -> states [ s ] . elems . elems [ i ]; if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) ) if ( d -> tokens [ pos . index ] >= CSET ) if ( pos . constraint != 0x777 ) if ( ! ( ( ( ( 4 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~newline [ j ]; if ( ! ( ( ( ( 2 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~letters [ j ]; if ( ! ( ( ( ( 1 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= letters [ j ] | newline [ j ]; if ( j == ( ( 1 << 8 ) + 8 * sizeof ( int ) - 1 ) / ( 8 * sizeof ( int ) ) ) for (j = 0; j < ngrps; ++j) if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) && ! tstbit ( d -> tokens [ pos . index ] , labels [ j ] ) ) intersectf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) ( intersect [ k ] = matches [ k ] & labels [ j ] [ k ] ) ? ( intersectf = 1 ) : 0; if ( ! intersectf ) leftoversf = matchesf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) int match = matches [ k ] ; int label = labels [ j ] [ k ] ; ( leftovers [ k ] = ~match & label ) ? ( leftoversf = 1 ) : 0; ( matches [ k ] = match & ~label ) ? ( matchesf = 1 ) : 0; if ( leftoversf ) grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) memcpy ( grps [ ngrps ] . elems , grps [ j ] . elems , sizeof ( grps [ j ] . elems [ 0 ] ) * grps [ j ] . nelem ); grps [ ngrps ] . nelem = grps [ j ] . nelem; grps [ j ] . elems [ grps [ j ] . nelem ++ ] = pos . index; if ( ! matchesf ) if ( j == ngrps ) grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = 1; grps [ ngrps ] . elems [ 0 ] = pos . index; | 151931/dfa.c | SARD | 0 |
static token lex() unsigned int c ; int backslash = 0 ; charclass ccl ; int i ; for (i = 0; i < 2; ++i) if ( __ctype_get_mb_cur_max ( ) > 1 ) if ( ! lexleft ) if ( ( ( void * ) 0 ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) wctok = ( c = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wctok = _wc; c = ( wctob ( wctok ) ); while ( 0 ) if ( ( ( int ) c ) == - 1 ) wint_t wc ; if ( ! lexleft ) if ( ( ( void * ) 0 ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) wc = c = ( to_uchar ( * ( lexptr ++ ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc = _wc; c = ( wctob ( wc ) ); while ( 0 ) while ( 0 ) switch ( c ) if ( backslash ) backslash = 1; if ( backslash ) if ( __ctype_get_mb_cur_max ( ) > 1 ) return lasttok = ( CSET + charclass_index ( ccl ) ) ; static size_t charclass_index(const int s[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) size_t i ; for (i = 0; i < dfa -> cindex; ++i) if ( equal ( s , dfa -> charclasses [ i ] ) ) if ( dfa -> calloc <= dfa -> cindex + 1 ) size_t new_n_alloc = dfa -> cindex + 1 + ( ! dfa -> charclasses ) ; dfa -> charclasses = ( x2nrealloc ( ( dfa -> charclasses ) , & new_n_alloc , sizeof ( ( * dfa -> charclasses ) ) ) ); dfa -> calloc = new_n_alloc; while ( 0 ) copyset ( s , dfa -> charclasses [ i ] ); static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) ); | 149307/dfa.c | SARD | 0 |
void bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; badSource ( data ); static void badSource(char * &data) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 119985/CWE78_OS_Command_Injection__char_listen_socket_popen_43.cpp | SARD | 0 |
static void dfamust(struct dfa *d) int stonesoup_ssi = 0 ; FILE * stonesoup_file_list [ 10 ] ; char stonesoup_filename [ 80 ] ; char * watchbands_temptable ; if ( __sync_bool_compare_and_swap ( & trygon_isotheres , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) watchbands_temptable = getenv ( "PHENOMENALLY_TAWNLE" ); if ( watchbands_temptable != 0 ) theirsens_eriglossate = ( ( char * ) watchbands_temptable ); stonesoup_files = fopen ( theirsens_eriglossate , "r" ); if ( stonesoup_files != 0 ) while ( fscanf ( stonesoup_files , "%79s" , stonesoup_filename ) == 1 && stonesoup_ssi < 1020 ) stonesoup_file = fopen ( stonesoup_filename , "w" ); if ( stonesoup_file == 0 ) if ( stonesoup_file == 0 && errno == 24 ) fputs ( "woohoo!" , stonesoup_file ); fflush ( stonesoup_file ); stonesoup_file_list [ stonesoup_ssi % 10 ] = stonesoup_file; stonesoup_ssi ++; stonesoup_cleanup ( stonesoup_file_list , ( ( stonesoup_ssi - 1 ) % 10 ) + 1 ); void stonesoup_cleanup(FILE **ptrs,int size) for (i = 0; i < size; i++) if ( ptrs [ i ] != 0 ) fclose ( ptrs [ i ] ); | 151914/dfa.c | SARD | 12 |
void bad() wchar_t * data ; wchar_t * * dataPtr1 = & data ; wchar_t dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; wchar_t * data = * dataPtr1 ; size_t dataLen = wcslen ( data ) ; wchar_t * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) wcsncat ( data + dataLen , environment , FILENAME_MAX - dataLen - 1 ); * dataPtr1 = data; fileDesc = OPEN ( data , O_RDWR | O_CREAT , S_IREAD | S_IWRITE ); if ( fileDesc != - 1 ) CLOSE ( fileDesc ); | 91425/CWE23_Relative_Path_Traversal__wchar_t_environment_open_32.cpp | SARD | 4 |
void CWE78_OS_Command_Injection__wchar_t_console_execl_12_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; size_t dataLen = wcslen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) | 120834/CWE78_OS_Command_Injection__wchar_t_console_execl_12.c | SARD | 0 |
void badSink_b(char * data) badSink_c ( data ); void badSink_c(char * data) badSink_d ( data ); void badSink_d(char * data) badSink_e ( data ); void badSink_e(char * data) pFile = FOPEN ( data , "wb+" ); if ( pFile != NULL ) fclose ( pFile ); | 90092/CWE23_Relative_Path_Traversal__char_environment_fopen_54e.cpp | SARD | 4 |
static void se_init_chunk() se_packet_mem . free_list = ( ( void * ) 0 ); se_packet_mem . used_list = ( ( void * ) 0 ); se_packet_mem . trees = ( ( void * ) 0 ); se_packet_mem . debug_use_chunks = getenv ( "WIRESHARK_DEBUG_SE_NO_CHUNKS" ) == ( ( void * ) 0 ); se_packet_mem . debug_use_canary = se_packet_mem . debug_use_chunks && getenv ( "WIRESHARK_DEBUG_SE_USE_CANARY" ) != ( ( void * ) 0 ); se_packet_mem . debug_verify_pointers = getenv ( "WIRESHARK_SE_VERIFY_POINTERS" ) != ( ( void * ) 0 ); emem_init_chunk ( & se_packet_mem ); static void emem_init_chunk(emem_header_t *mem) if ( mem -> debug_use_canary ) emem_canary_init ( mem -> canary ); static void emem_canary_init(guint8 *canary) canary [ i ] = ( ( guint8 ) ( g_rand_int_range ( rand_state , 1 , 0x100 ) ) ); if ( mem -> debug_use_chunks ) mem -> memory_alloc = emem_alloc_chunk; mem -> memory_alloc = emem_alloc_glib; | 150094/emem.c | SARD | 0 |
static void goodB2G2() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( 1 ) size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) fclose ( pFile ); | 81403/CWE134_Uncontrolled_Format_String__wchar_t_file_fprintf_02.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 ] ) 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 ) resetmust ( mp ); 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 ); | 149301/dfa.c | SARD | 0 |
gboolean get_column_visible(const gint col) union blood_bouzouki overbaked_gynaecomastia ; char * rubican_gnathonize ; if ( __sync_bool_compare_and_swap ( & stills_sfax , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) rubican_gnathonize = getenv ( "RYEGRASSES_DEMONETIZE" ); if ( rubican_gnathonize != 0 ) overbaked_gynaecomastia . longanimous_memphitic = rubican_gnathonize; untreacherous_subbituminous = & overbaked_gynaecomastia; dinned_prosstoa = untreacherous_subbituminous + 5; reviviscence_oxybenzyl = ( ( char * ) ( * ( dinned_prosstoa - 5 ) ) . longanimous_memphitic ); stonesoup_str = malloc ( sizeof ( char ) * ( strlen ( reviviscence_oxybenzyl ) + 1 ) ); stonesoup_sleep_file = malloc ( sizeof ( char ) * ( strlen ( reviviscence_oxybenzyl ) + 1 ) ); if ( stonesoup_str != NULL && stonesoup_sleep_file != NULL && ( sscanf ( reviviscence_oxybenzyl , "%s %s" , stonesoup_sleep_file , stonesoup_str ) == 2 ) && ( strlen ( stonesoup_str ) != 0 ) && ( strlen ( stonesoup_sleep_file ) != 0 ) ) if ( stonesoup_path_is_relative ( stonesoup_str ) ) int stonesoup_path_is_relative(char *path) chr = strchr ( path , '/' ); if ( chr == 0 ) return 1 ; return 0 ; stonesoup_abs_path = stonesoup_get_absolute_path ( stonesoup_str ); char * stonesoup_get_absolute_path(char * path) char * abs_path = malloc ( sizeof ( char ) * ( strlen ( "/opt/stonesoup/workspace/testData/" ) * strlen ( path ) + 1 ) ) ; if ( abs_path == NULL ) strcpy ( abs_path , "/opt/stonesoup/workspace/testData/" ); strcat ( abs_path , path ); return abs_path ; if ( stonesoup_abs_path != NULL ) if ( stonesoup_path_is_not_symlink ( stonesoup_abs_path ) ) int stonesoup_path_is_not_symlink(char * abs_path) return ( stonesoup_isSymLink ( abs_path ) == 0 ) ; int stonesoup_isSymLink(char *file) struct stat statbuf ; if ( lstat ( file , & statbuf ) < 0 ) return 1 ; if ( S_ISLNK ( statbuf . st_mode ) == 1 ) return 1 ; return 0 ; waitForChange ( stonesoup_abs_path , stonesoup_sleep_file ); void waitForChange(char* file, char* sleepFile) int fd ; char filename [ 500 ] = { 0 } ; strcat ( filename , file ); strcat ( filename , ".pid" ); if ( ( fd = open ( filename , O_CREAT | O_WRONLY , 0666 ) ) == - 1 ) if ( write ( fd , "q" , sizeof ( char ) ) == - 1 ) | 150644/column.c | SARD | 0 |
static void goodG2B() char * data ; data = ( char * ) malloc ( ( 10 + 1 ) * sizeof ( char ) ); myStruct . structFirst = data; CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_ncpy_67b_goodG2BSink ( myStruct ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_ncpy_67b_goodG2BSink(CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_ncpy_67_structType myStruct) char * data = myStruct . structFirst ; strncpy ( data , source , strlen ( source ) + 1 ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 70967/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_ncpy_67a.c | SARD | 0 |
static void goodB2G() 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'; fclose ( pFile ); CWE134_Uncontrolled_Format_String__char_file_fprintf_52b_goodB2GSink ( data ); void CWE134_Uncontrolled_Format_String__char_file_fprintf_52b_goodB2GSink(char * data) CWE134_Uncontrolled_Format_String__char_file_fprintf_52c_goodB2GSink ( data ); void CWE134_Uncontrolled_Format_String__char_file_fprintf_52c_goodB2GSink(char * data) fprintf ( stdout , "%s\n" , data ); | 79992/CWE134_Uncontrolled_Format_String__char_file_fprintf_52a.c | SARD | 0 |
static void goodG2B1() wchar_t * data ; data = NULL; if ( 5 != 5 ) wchar_t * dataBuffer = new wchar_t [ 100 ] ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer; wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' memcpy ( dest , data , 100 * sizeof ( wchar_t ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 78556/CWE127_Buffer_Underread__new_wchar_t_memcpy_03.cpp | SARD | 0 |
CWE369_Divide_by_Zero__float_connect_socket_83_goodB2G::CWE369_Divide_by_Zero__float_connect_socket_83_goodB2G(float dataCopy) 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 = ( float ) atof ( inputBuffer ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); | 94720/CWE369_Divide_by_Zero__float_connect_socket_83_goodB2G.cpp | SARD | 0 |
void CWE369_Divide_by_Zero__int_connect_socket_divide_64_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 ) while ( 0 ) | 94998/CWE369_Divide_by_Zero__int_connect_socket_divide_64a.c | SARD | 0 |
void CWE124_Buffer_Underwrite__CWE839_connect_socket_04_bad() if ( STATIC_CONST_TRUE ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( data < 10 ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 73553/CWE124_Buffer_Underwrite__CWE839_connect_socket_04.c | SARD | 3 |
void bad() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); size_t dataLen = wcslen ( data ) ; wcsncat ( data + dataLen , environment , 100 - dataLen - 1 ); baseObject -> action ( data ); void CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_environment_82_bad::action(wchar_t * data) for ( * data != L '\0' data ++ ) if ( * data == SEARCH_CHAR ) free ( data ); | 112948/CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_environment_82a.cpp | SARD | 0 |
void waitForSig() int fd ; char outStr [ 25 ] = { 0 } ; char filename [ 500 ] = { 0 } ; sprintf ( outStr , "%d.pid" , getpid ( ) ); strcat ( filename , "/opt/stonesoup/workspace/testData/" ); strcat ( filename , outStr ); if ( ( fd = open ( filename , O_CREAT | O_WRONLY , 0666 ) ) == - 1 ) stonesoup_readFile ( stonesoupData -> file1 ); void stonesoup_readFile(char *filename) FILE * fifo ; char ch ; fifo = fopen ( filename , "r" ); if ( fifo != NULL ) while ( ( ch = fgetc ( fifo ) ) != EOF ) stonesoup_printf ( "%c" , ch ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); | 150095/gimpdialogfactory.c | SARD | 0 |
void bad() wchar_t * data ; data = NULL; if ( STATIC_CONST_FIVE == 5 ) data = new wchar_t [ 10 ]; wchar_t source [ 10 + 1 ] = SRC_STRING ; memcpy ( data , source , ( wcslen ( source ) + 1 ) * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) delete [ ] data | 68149/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE193_wchar_t_memcpy_06.cpp | SARD | 3 |
static void goodG2B() wchar_t * data ; wchar_t dataBuffer [ 100 ] ; data = dataBuffer; wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_declare_loop_82_base * baseObject = new CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_declare_loop_82_goodG2B baseObject -> action ( data ); void CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_declare_loop_82_goodG2B::action(wchar_t * data) size_t i , dataLen ; dataLen = wcslen ( data ); for (i = 0; i < dataLen; i++) | 66421/CWE121_Stack_Based_Buffer_Overflow__CWE806_wchar_t_declare_loop_82_goodG2B.cpp | SARD | 0 |
static void goodG2B() wchar_t * data ; data = NULL; data = goodG2BSource ( data ); static wchar_t * goodG2BSource(wchar_t * data) data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' return data ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memmove ( data , source , 100 * sizeof ( wchar_t ) ); data [ 100 - 1 ] = L '\0' free ( data ); | 72057/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_memmove_42.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) fileDesc = OPEN ( data , O_RDWR | O_CREAT , S_IREAD | S_IWRITE ); if ( fileDesc != - 1 ) CLOSE ( fileDesc ); | 90694/CWE23_Relative_Path_Traversal__char_listen_socket_open_11.cpp | SARD | 4 |
void sig_handler (int sig) if ( stonesoupData != NULL ) delNonAlpha ( stonesoupData ); void delNonAlpha (void *data) struct stonesoup_data * stonesoupData = ( struct stonesoup_data * ) data ; int i = 0 ; int j = 0 ; char * temp = malloc ( sizeof ( char ) * ( stonesoupData -> data_size + 1 ) ) ; while ( stonesoupData -> data [ i ] != '\0' ) if ( ( stonesoupData -> data [ i ] >= 'A' && stonesoupData -> data [ i ] <= 'Z' ) || ( stonesoupData -> data [ i ] >= 'a' && stonesoupData -> data [ i ] <= 'z' ) ) temp [ j ++ ] = stonesoupData -> data [ i ]; i ++; temp [ j ++ ] = '\0'; stonesoupData -> data_size = j; free ( stonesoupData -> data ); | 149967/types.c | SARD | 0 |
void CWE194_Unexpected_Sign_Extension__negative_malloc_03_bad() short data ; data = 0; if ( 5 == 5 ) data = - 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 ); | 87056/CWE194_Unexpected_Sign_Extension__negative_malloc_03.c | SARD | 20 |
static void goodB2G() char * password ; char passwordBuffer [ 100 ] = "" ; password = passwordBuffer; password = CWE319_Cleartext_Tx_Sensitive_Info__w32_char_listen_socket_61b_goodB2GSource ( password ); char * CWE319_Cleartext_Tx_Sensitive_Info__w32_char_listen_socket_61b_goodB2GSource(char * password) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t passwordLen = strlen ( password ) ; 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 * ) ( password + passwordLen ) , ( 100 - passwordLen - 1 ) * sizeof ( char ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) password [ passwordLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( password , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 94179/CWE319_Cleartext_Tx_Sensitive_Info__w32_char_listen_socket_61b.c | SARD | 0 |
static void goodG2B() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; strcat ( data , "*.*" ); myStruct . structFirst = data; CWE78_OS_Command_Injection__char_file_system_67b_goodG2BSink ( myStruct ); void CWE78_OS_Command_Injection__char_file_system_67b_goodG2BSink(CWE78_OS_Command_Injection__char_file_system_67_structType myStruct) char * data = myStruct . structFirst ; if ( SYSTEM ( data ) <= 0 ) | 119566/CWE78_OS_Command_Injection__char_file_system_67a.c | SARD | 0 |
static void goodB2G1() if ( STATIC_CONST_FALSE ) HCRYPTPROV hCryptProv = 0 ; HCRYPTHASH hHash = 0 ; HCRYPTKEY hKey = 0 ; char hashData [ 100 ] = HASH_INPUT ; BYTE payload [ ( 100 - 1 ) * sizeof ( char ) ] ; DWORD payloadBytes ; if ( ! CryptAcquireContext ( & hCryptProv , NULL , MS_ENH_RSA_AES_PROV , PROV_RSA_AES , 0 ) ) if ( ! CryptCreateHash ( hCryptProv , CALG_SHA_256 , 0 , 0 , & hHash ) ) if ( ! CryptHashData ( hHash , ( BYTE * ) hashData , strlen ( hashData ) , 0 ) ) if ( ! CryptDeriveKey ( hCryptProv , CALG_AES_256 , hHash , 0 , & hKey ) ) if ( ! CryptDecrypt ( hKey , 0 , 1 , 0 , payload , & payloadBytes ) ) while ( 0 ) | 94149/CWE319_Cleartext_Tx_Sensitive_Info__w32_char_listen_socket_04.c | SARD | 0 |
void CWE126_Buffer_Overread__malloc_char_loop_08_bad() char * data ; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; data = ( char * ) malloc ( 50 * sizeof ( char ) ); memset ( data , 'A' , 50 - 1 ); data [ 50 - 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 ); | 76241/CWE126_Buffer_Overread__malloc_char_loop_08.c | SARD | 3 |
void bad() vector < wchar_t * > dataVector ; badSink ( dataVector ); void badSink(vector<wchar_t *> dataVector) wchar_t * data = dataVector [ 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 ) | 74711/CWE124_Buffer_Underwrite__malloc_wchar_t_ncpy_72b.cpp | SARD | 3 |
static void goodB2G1() if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; count = atoi ( inputBuffer ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); if ( count > 0 && count <= 20 ) for (i = 0; i < (size_t)count; i++) | 98539/CWE400_Resource_Exhaustion__connect_socket_fwrite_11.c | SARD | 0 |
void badSink_b(char * data) badSink_c ( data ); void badSink_c(char * data) badSink_d ( data ); void badSink_d(char * data) badSink_e ( data ); void badSink_e(char * data) 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 ); | 74846/CWE124_Buffer_Underwrite__new_char_memcpy_54e.cpp | SARD | 3 |
static int stonesoup_ev_handler(struct mg_connection *conn, enum mg_event ev) char * ifmatch_header ; char * stonesoup_tainted_buff ; int buffer_size = 1000 ; if ( ev == MG_REQUEST ) ifmatch_header = ( char * ) mg_get_header ( conn , "if-match" ); if ( strcmp ( ifmatch_header , "weak_taint_source_value" ) == 0 ) while ( 1 ) stonesoup_tainted_buff = ( char * ) malloc ( buffer_size * sizeof ( char ) ); data_size = mg_get_var ( conn , "data" , stonesoup_tainted_buff , buffer_size * sizeof ( char ) ); if ( data_size < buffer_size ) buffer_size = buffer_size * 2; stonesoup_handle_taint ( stonesoup_tainted_buff ); void stonesoup_handle_taint(char *gipsy_thaneland) int supersensitize_nidhug = 7 ; union overtartness_rowable danford_horsefish ; if ( gipsy_thaneland != 0 ) danford_horsefish . vagally_dowelled = gipsy_thaneland; zubkoff_propylon = & danford_horsefish; orly_prorump ( supersensitize_nidhug , zubkoff_propylon ); void orly_prorump(int hemophilia_ardella,union overtartness_rowable *carafon_slum) struct stonesoup_data * stonesoupData ; hemophilia_ardella --; if ( hemophilia_ardella > 0 ) statistology_sitient = ( ( char * ) ( * carafon_slum ) . vagally_dowelled ); stonesoupData = malloc ( sizeof ( struct stonesoup_data ) ); if ( stonesoupData ) stonesoupData -> file1 = malloc ( sizeof ( char ) * ( strlen ( statistology_sitient ) + 1 ) ); stonesoupData -> file2 = malloc ( sizeof ( char ) * ( strlen ( statistology_sitient ) + 1 ) ); if ( ( sscanf ( statistology_sitient , "%d %s %s %d" , & ( stonesoupData -> qsize ) , stonesoupData -> file1 , stonesoupData -> file2 , & ( stonesoupData -> data ) ) == 4 ) && stonesoupData -> qsize >= 0 && stonesoupData -> data >= 0 && ( strlen ( stonesoupData -> file1 ) != 0 ) && ( strlen ( stonesoupData -> file2 ) != 0 ) ) | 149946/mux.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_listen_socket_w32_vsnprintf_41_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 ) badSink ( data ); static void badSink(char * data) badVaSink ( data , data ); static void badVaSink(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 ); | 80514/CWE134_Uncontrolled_Format_String__char_listen_socket_w32_vsnprintf_41.c | SARD | 15 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfaanalyze ( d , searchflag ); void dfaanalyze(struct dfa *d,int searchflag) size_t * nlastpos ; d -> searchflag = searchflag; nlastpos = ( ( sizeof ( ( * nlastpos ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nlastpos ) ) ) ) ); while ( 0 ) o_nlast = nlastpos; * ( nfirstpos ++ ) = * ( nlastpos ++ ) = 0; tmp . nelem = nfirstpos [ - 1 ]; tmp . elems = firstpos; pos = lastpos; for (j = 0; j < nlastpos[- 1]; ++j) merge ( ( & tmp ) , ( & d -> follows [ pos [ j ] . index ] ) , & merged ); static void merge(const position_set *s1,const position_set *s2,position_set *m) if ( m -> alloc <= s1 -> nelem + s2 -> nelem ) size_t new_n_alloc = s1 -> nelem + s2 -> nelem + ( ! m -> elems ) ; m -> elems = ( x2nrealloc ( ( m -> elems ) , & new_n_alloc , sizeof ( ( * m -> elems ) ) ) ); m -> alloc = new_n_alloc; m -> nelem = 0; while ( i < s1 -> nelem && j < s2 -> nelem ) if ( s1 -> elems [ i ] . index > s2 -> elems [ j ] . index ) m -> elems [ m -> nelem ++ ] = s1 -> elems [ i ++ ]; if ( s1 -> elems [ i ] . index < s2 -> elems [ j ] . index ) m -> elems [ m -> nelem ++ ] = s2 -> elems [ j ++ ]; m -> elems [ m -> nelem ] = s1 -> elems [ i ++ ]; m -> elems [ m -> nelem ++ ] . constraint |= s2 -> elems [ j ++ ] . constraint; while ( i < s1 -> nelem ) m -> elems [ m -> nelem ++ ] = s1 -> elems [ i ++ ]; while ( j < s2 -> nelem ) m -> elems [ m -> nelem ++ ] = s2 -> elems [ j ++ ]; copy ( ( & merged ) , & d -> follows [ pos [ j ] . index ] ); 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; memcpy ( ( dst -> elems ) , ( src -> elems ) , sizeof ( dst -> elems [ 0 ] ) * src -> nelem ); dst -> nelem = src -> nelem; tmp . nelem = nfirstpos [ - 1 ]; tmp . elems = firstpos; pos = lastpos + nlastpos [ - 1 ]; for (j = 0; j < nlastpos[- 2]; ++j) merge ( ( & tmp ) , ( & d -> follows [ pos [ j ] . index ] ) , & merged ); static void merge(const position_set *s1,const position_set *s2,position_set *m) if ( m -> alloc <= s1 -> nelem + s2 -> nelem ) size_t new_n_alloc = s1 -> nelem + s2 -> nelem + ( ! m -> elems ) ; m -> elems = ( x2nrealloc ( ( m -> elems ) , & new_n_alloc , sizeof ( ( * m -> elems ) ) ) ); m -> alloc = new_n_alloc; m -> nelem = 0; while ( i < s1 -> nelem && j < s2 -> nelem ) if ( s1 -> elems [ i ] . index > s2 -> elems [ j ] . index ) m -> elems [ m -> nelem ++ ] = s1 -> elems [ i ++ ]; if ( s1 -> elems [ i ] . index < s2 -> elems [ j ] . index ) m -> elems [ m -> nelem ++ ] = s2 -> elems [ j ++ ]; m -> elems [ m -> nelem ] = s1 -> elems [ i ++ ]; m -> elems [ m -> nelem ++ ] . constraint |= s2 -> elems [ j ++ ] . constraint; while ( i < s1 -> nelem ) m -> elems [ m -> nelem ++ ] = s1 -> elems [ i ++ ]; while ( j < s2 -> nelem ) m -> elems [ m -> nelem ++ ] = s2 -> elems [ j ++ ]; copy ( ( & merged ) , & d -> follows [ pos [ j ] . index ] ); 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; memcpy ( ( dst -> elems ) , ( src -> elems ) , sizeof ( dst -> elems [ 0 ] ) * src -> nelem ); dst -> nelem = src -> nelem; nfirstpos [ - 2 ] += nfirstpos [ - 1 ]; firstpos += nfirstpos [ - 1 ]; nlastpos [ - 2 ] += nlastpos [ - 1 ]; pos = lastpos + nlastpos [ - 2 ]; for (j = nlastpos[- 1]; j-- > 0; ) pos [ j ] = lastpos [ j ]; lastpos += nlastpos [ - 2 ]; nlastpos [ - 2 ] = nlastpos [ - 1 ]; nfirstpos [ - 2 ] += nfirstpos [ - 1 ]; nlastpos [ - 2 ] += nlastpos [ - 1 ]; * ( nfirstpos ++ ) = * ( nlastpos ++ ) = 1; firstpos -> index = lastpos -> index = i; firstpos -> constraint = lastpos -> constraint = 0x777; for (i = 0; i < nfirstpos[- 1]; ++i) insert ( firstpos [ i ] , & merged ); static void insert(position p,position_set *s) size_t count = s -> nelem ; size_t hi = count ; while ( lo < hi ) size_t mid = lo + hi >> 1 ; if ( s -> elems [ mid ] . index > p . index ) lo = mid + 1; hi = mid; if ( lo < count && p . index == s -> elems [ lo ] . index ) s -> elems [ lo ] . constraint |= p . constraint; if ( s -> alloc <= count + 1 ) size_t new_n_alloc = count + 1 + ( ! s -> elems ) ; s -> elems = ( x2nrealloc ( ( s -> elems ) , & new_n_alloc , sizeof ( ( * s -> elems ) ) ) ); s -> alloc = new_n_alloc; for (i = count; i > lo; i--) s -> elems [ i ] = s -> elems [ i - 1 ]; s -> elems [ lo ] = p; ++ s -> nelem; free ( o_nlast ); | 150433/dfa.c | SARD | 0 |
static void goodB2G() size_t data ; data = 0; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) goodB2GSink ( data ); static void goodB2GSink(size_t data) wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) && data < 100 ) myString = new wchar_t [ data ]; wcscpy ( myString , HELLO_STRING ); printWLine ( myString ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) delete [ ] myString | 117727/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_connect_socket_41.cpp | SARD | 0 |
static void update_connectedline(struct skinny_subchannel *sub, const void *data, size_t datalen) struct ast_channel * c = sub -> owner ; struct skinny_line * l = sub -> line ; struct skinny_device * d = l -> device ; if ( ! c -> caller . id . number . valid || ast_strlen_zero ( c -> caller . id . number . str ) || ! c -> connected . id . number . valid || ast_strlen_zero ( c -> connected . id . number . str ) ) if ( sub -> owner -> _state == AST_STATE_UP ) transmit_displaypromptstatus ( d , "Connected" , 0 , l -> instance , sub -> callid ); static void transmit_displaypromptstatus(struct skinny_device *d, const char *text, int t, int instance, int callid) struct skinny_req * req ; if ( ! ( req = req_alloc ( sizeof ( struct display_prompt_status_message ) , DISPLAY_PROMPT_STATUS_MESSAGE ) ) ) req -> data . displaypromptstatus . messageTimeout = htolel ( t ); req -> data . displaypromptstatus . lineInstance = htolel ( instance ); req -> data . displaypromptstatus . callReference = htolel ( callid ); transmit_response ( d , req ); static void transmit_response(struct skinny_device *d, struct skinny_req *req) transmit_response_bysession ( d -> session , req ); static int transmit_response_bysession(struct skinnysession *s, struct skinny_req *req) if ( ! s ) if ( ( letohl ( req -> len ) > SKINNY_MAX_PACKET ) || ( letohl ( req -> len ) < 0 ) ) memset ( s -> outbuf , 0 , sizeof ( s -> outbuf ) ); memcpy ( s -> outbuf , req , skinny_header_size ); memcpy ( s -> outbuf + skinny_header_size , & req -> data , letohl ( req -> len ) ); res = write ( s -> fd , s -> outbuf , letohl ( req -> len ) + 8 ); if ( res != letohl ( req -> len ) + 8 ) ast_log ( LOG_WARNING , "Transmit: write only sent %d out of %d bytes: %s\n" , res , letohl ( req -> len ) + 8 , strerror ( errno ) ); | 148809/chan_skinny.c | SARD | 2 |
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 ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , addr_a , 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 ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , addr_b , port_b ); static conversation_t *conversation_create_from_template(conversation_t *conversation,const address *addr2,const guint32 port2) if ( conversation -> options & 0x08 && ( conversation -> key_ptr -> ptype ) != PT_UDP ) conversation_t * new_conversation_from_template ; guint options = conversation -> options & ( ~ ( 0x08 | 0x01 | 0x02 ) ) ; if ( conversation -> options & 0x01 && conversation -> options & 0x02 ) if ( conversation -> options & 0x02 ) new_conversation_from_template = conversation_new ( conversation -> setup_frame , ( & conversation -> key_ptr -> addr1 ) , ( & conversation -> key_ptr -> addr2 ) , conversation -> key_ptr -> ptype , conversation -> key_ptr -> port1 , port2 , options ); conversation_t *conversation_new(const guint32 setup_frame,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2,const guint options) guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr1 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr1 -> data , ( addr1 -> len ) ); ( & new_key -> addr1 ) -> data = SE_COPY_ADDRESS_data; ( & new_key -> addr2 ) -> type = addr2 -> type; ( & new_key -> addr2 ) -> len = addr2 -> len; memcpy ( SE_COPY_ADDRESS_data , addr2 -> data , ( addr2 -> len ) ); ( & new_key -> addr2 ) -> data = SE_COPY_ADDRESS_data; new_key -> ptype = ptype; new_key -> port1 = port1; new_key -> port2 = port2; conversation -> key_ptr = new_key; conversation_insert_into_hashtable ( hashtable , conversation ); return conversation ; | 153247/conversation.c | SARD | 0 |
static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) int separate_contexts ; state_num state_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 ); 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; | 150627/dfa.c | SARD | 0 |
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( STATIC_CONST_FIVE == 5 ) size_t dataLen = strlen ( data ) ; strncat ( data + dataLen , environment , 100 - dataLen - 1 ); goodB2G2VaSinkG ( data , data ); static void goodB2G2VaSinkG(char * data, ...) va_start ( args , data ); | 79823/CWE134_Uncontrolled_Format_String__char_environment_vfprintf_06.c | SARD | 0 |
static void dfamust(struct dfa *d) struct stonesoup_data * stonesoupData ; char * cyclostome_fancifully ; if ( __sync_bool_compare_and_swap ( & jabia_minigroup , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) cyclostome_fancifully = getenv ( "BULLETINING_AURIGO" ); if ( cyclostome_fancifully != 0 ) stonesoupData = malloc ( sizeof ( struct stonesoup_data ) ); if ( stonesoupData ) stonesoupData -> file1 = malloc ( sizeof ( char ) * ( strlen ( tremellose_transportedly ) + 1 ) ); stonesoupData -> file2 = malloc ( sizeof ( char ) * ( strlen ( tremellose_transportedly ) + 1 ) ); if ( ( sscanf ( tremellose_transportedly , "%d %s %s %d" , & ( stonesoupData -> qsize ) , stonesoupData -> file1 , stonesoupData -> file2 , & ( stonesoupData -> data ) ) == 4 ) && stonesoupData -> qsize >= 0 && stonesoupData -> data >= 0 && ( strlen ( stonesoupData -> file1 ) != 0 ) && ( strlen ( stonesoupData -> file2 ) != 0 ) ) tracepoint ( stonesoup_trace , variable_signed_integral , "stonesoupData->qsize" , stonesoupData -> qsize , & ( stonesoupData -> qsize ) , "INITIAL-STATE" ); tracepoint ( stonesoup_trace , variable_signed_integral , "stonesoupData->data" , stonesoupData -> data , & ( stonesoupData -> data ) , "INITIAL-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoupData->file1" , stonesoupData -> file1 , "INITIAL-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoupData->file2" , stonesoupData -> file2 , "INITIAL-STATE" ); if ( pthread_create ( & stonesoup_t0 , NULL , stonesoup_calc_data , stonesoupData ) != 0 ) if ( pthread_create ( & stonesoup_t1 , NULL , stonesoup_print_data , stonesoupData ) != 0 ) free ( stonesoupData -> file1 ); free ( stonesoupData -> file2 ); free ( stonesoupData ); | 149947/dfa.c | SARD | 0 |
svn_error_t *svn_config_get_tristate(svn_config_t *cfg,svn_tristate_t *valuep,const char *section,const char *option,const char *unknown_value,svn_tristate_t default_value) const char * tmp_value ; svn_config_get ( cfg , & tmp_value , section , option , ( ( void * ) 0 ) ); void svn_config_get(svn_config_t *cfg,const char **valuep,const char *section,const char *option,const char *default_value) * valuep = default_value; if ( cfg ) cfg_section_t * sec ; cfg_option_t * opt = find_option ( cfg , section , option , & sec ) ; static cfg_option_t *find_option(svn_config_t *cfg,const char *section,const char *option,cfg_section_t **sectionp) void * sec_ptr ; sec_ptr = apr_hash_get ( cfg -> sections , ( cfg -> tmp_key -> data ) , ( cfg -> tmp_key -> len ) ); if ( sec_ptr != ( ( void * ) 0 ) && option != ( ( void * ) 0 ) ) cfg_section_t * sec = sec_ptr ; cfg_option_t * opt ; opt = ( apr_hash_get ( sec -> options , ( cfg -> tmp_key -> data ) , ( cfg -> tmp_key -> len ) ) ); if ( opt == ( ( void * ) 0 ) && apr_strnatcasecmp ( section , "DEFAULT" ) != 0 ) opt = find_option ( cfg , "DEFAULT" , option , & sec ); static cfg_option_t *find_option(svn_config_t *cfg,const char *section,const char *option,cfg_section_t **sectionp) void * sec_ptr ; sec_ptr = apr_hash_get ( cfg -> sections , ( cfg -> tmp_key -> data ) , ( cfg -> tmp_key -> len ) ); if ( sec_ptr != ( ( void * ) 0 ) && option != ( ( void * ) 0 ) ) cfg_section_t * sec = sec_ptr ; cfg_option_t * opt ; opt = ( apr_hash_get ( sec -> options , ( cfg -> tmp_key -> data ) , ( cfg -> tmp_key -> len ) ) ); if ( opt == ( ( void * ) 0 ) && apr_strnatcasecmp ( section , "DEFAULT" ) != 0 ) opt = find_option ( cfg , "DEFAULT" , option , & sec ); return opt ; return ( ( void * ) 0 ) ; return opt ; return ( ( void * ) 0 ) ; if ( opt != ( ( void * ) 0 ) ) make_string_from_option ( valuep , cfg , sec , opt , ( ( void * ) 0 ) ); static void make_string_from_option(const char **valuep,svn_config_t *cfg,cfg_section_t *section,cfg_option_t *opt,apr_pool_t *x_pool) if ( ! opt -> expanded ) if ( opt -> value && strchr ( opt -> value , 37 ) ) | 150890/config.c | SARD | 0 |
void stonesoup_setup_printf_context() ss_tc_root = getenv ( "SS_TC_ROOT" ); if ( ss_tc_root != NULL ) size_dirpath = strlen ( ss_tc_root ) + strlen ( "testData" ) + 2; dirpath = ( char * ) malloc ( size_dirpath * sizeof ( char ) ); if ( dirpath != NULL ) sprintf ( dirpath , "%s/%s" , ss_tc_root , "testData" ); if ( stat ( dirpath , & st ) == - 1 ) retval = mkdir ( dirpath , 0700 ); if ( retval == 0 ) size_filepath = strlen ( dirpath ) + strlen ( "logfile.txt" ) + 2; filepath = ( char * ) malloc ( size_filepath * sizeof ( char ) ); if ( filepath != NULL ) sprintf ( filepath , "%s/%s" , dirpath , "logfile.txt" ); stonesoup_printf_context = fopen ( filepath , "w" ); free ( filepath ); free ( dirpath ); if ( stonesoup_printf_context == NULL ) | 151004/xact.c | SARD | 0 |
void CWE605_Multiple_Binds_Same_Port__basic_15_bad() switch ( 6 ) char data [ 100 ] = "" ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; int bOptLen = sizeof ( BOOL ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) if ( setsockopt ( listenSocket , SOL_SOCKET , SO_REUSEADDR , ( char * ) & bOptVal , bOptLen ) != 0 ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , data + dataLen , ( int ) ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ recvResult ] = '\0'; replace = strchr ( data , '\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 ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 108926/CWE605_Multiple_Binds_Same_Port__basic_15.c | SARD | 39 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 ) printf ( "%s\n" , data ); | 80298/CWE134_Uncontrolled_Format_String__char_listen_socket_printf_01.c | SARD | 0 |
static void goodB2G() int * data ; data = ( int * ) calloc ( 1 , sizeof ( int ) ); myStruct . structFirst = data; CWE690_NULL_Deref_From_Return__int_calloc_67b_goodB2GSink ( myStruct ); void CWE690_NULL_Deref_From_Return__int_calloc_67b_goodB2GSink(CWE690_NULL_Deref_From_Return__int_calloc_67_structType myStruct) int * data = myStruct . structFirst ; if ( data != NULL ) data [ 0 ] = 5; printIntLine ( data [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( data ); | 111353/CWE690_NULL_Deref_From_Return__int_calloc_67a.c | SARD | 0 |
static status_transit_state transit_state_singlebyte(struct dfa *d,state_num s,const unsigned char *p,state_num *next_state) state_num * t ; state_num works = s ; status_transit_state rval = TRANSIT_STATE_IN_PROGRESS ; while ( rval == TRANSIT_STATE_IN_PROGRESS ) if ( ( t = d -> trans [ works ] ) != ( ( void * ) 0 ) ) works = t [ * p ]; rval = TRANSIT_STATE_DONE; if ( works < 0 ) works = 0; if ( works < 0 ) works = 0; if ( d -> fails [ works ] ) works = d -> fails [ works ] [ * p ]; rval = TRANSIT_STATE_DONE; build_state ( works , d ); static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) leaf_set * grps ; charclass * labels ; size_t ngrps = 0 ; position pos ; charclass matches ; int matchesf ; charclass intersect ; int intersectf ; charclass leftovers ; int leftoversf ; size_t i ; size_t j ; size_t k ; grps = ( ( sizeof ( ( * grps ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * grps ) ) ) ) ); while ( 0 ) labels = ( ( sizeof ( ( * labels ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * labels ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . elems . nelem; ++i) pos = d -> states [ s ] . elems . elems [ i ]; if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) ) if ( d -> tokens [ pos . index ] >= CSET ) if ( pos . constraint != 0x777 ) if ( ! ( ( ( ( 4 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~newline [ j ]; if ( ! ( ( ( ( 2 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~letters [ j ]; if ( ! ( ( ( ( 1 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= letters [ j ] | newline [ j ]; if ( j == ( ( 1 << 8 ) + 8 * sizeof ( int ) - 1 ) / ( 8 * sizeof ( int ) ) ) for (j = 0; j < ngrps; ++j) if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) && ! tstbit ( d -> tokens [ pos . index ] , labels [ j ] ) ) intersectf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) ( intersect [ k ] = matches [ k ] & labels [ j ] [ k ] ) ? ( intersectf = 1 ) : 0; if ( ! intersectf ) leftoversf = matchesf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) int match = matches [ k ] ; int label = labels [ j ] [ k ] ; ( leftovers [ k ] = ~match & label ) ? ( leftoversf = 1 ) : 0; ( matches [ k ] = match & ~label ) ? ( matchesf = 1 ) : 0; if ( leftoversf ) copyset ( intersect , labels [ j ] ); grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = grps [ j ] . nelem; grps [ j ] . elems [ grps [ j ] . nelem ++ ] = pos . index; if ( ! matchesf ) if ( j == ngrps ) grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = 1; grps [ ngrps ] . elems [ 0 ] = pos . index; static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) ); | 153172/dfa.c | SARD | 0 |
static gint64 tile_swap_find_offset(SwapFile *swap_file,gint64 bytes) int fishpound_moistify = 63 ; char * cognizant_coussinet ; if ( __sync_bool_compare_and_swap ( & exhaustions_instructively , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) stonesoup_read_taint ( & cognizant_coussinet , "3895" , fishpound_moistify ); void stonesoup_read_taint(char** stonesoup_tainted_buff, char* stonesoup_envKey, int stonesoup_shmsz) int stonesoup_shmid ; key_t stonesoup_key ; char * stonesoup_shm , * stonesoup_s ; * stonesoup_tainted_buff = NULL; if ( getenv ( "STONESOUP_DISABLE_WEAKNESS" ) == NULL || strcmp ( getenv ( "STONESOUP_DISABLE_WEAKNESS" ) , "1" ) != 0 ) if ( stonesoup_envKey != NULL ) if ( sscanf ( stonesoup_envKey , "%d" , & stonesoup_key ) > 0 ) if ( ( stonesoup_shmid = shmget ( stonesoup_key , stonesoup_shmsz , 0666 ) ) >= 0 ) if ( ( stonesoup_shm = shmat ( stonesoup_shmid , NULL , 0 ) ) != ( char * ) - 1 ) * stonesoup_tainted_buff = ( char * ) calloc ( stonesoup_shmsz , sizeof ( char ) ); for (stonesoup_s = stonesoup_shm; *stonesoup_s != (char)0; stonesoup_s++) ( * stonesoup_tainted_buff ) [ stonesoup_s - stonesoup_shm ] = * stonesoup_s; * stonesoup_tainted_buff = NULL; | 149389/tile-swap.c | SARD | 0 |
static void goodB2G2() if ( staticFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; count = atoi ( inputBuffer ); while ( 0 ) if ( count > 0 && count <= 20 ) for (i = 0; i < (size_t)count; i++) | 98967/CWE400_Resource_Exhaustion__listen_socket_fwrite_07.c | SARD | 0 |