func
stringlengths 181
23.6k
| path
stringlengths 12
123
| source
stringclasses 2
values | label
int64 0
40
|
---|---|---|---|
static void goodB2G() wchar_t * data ; wchar_t * * dataPtr1 = & data ; wchar_t * * dataPtr2 = & data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; wchar_t * data = * dataPtr1 ; FILE * pFile ; pFile = fopen ( "passwords.txt" , "r" ); if ( pFile != NULL ) if ( fgetws ( data , 100 , pFile ) == NULL ) data [ 0 ] = L '\0' data [ 0 ] = L '\0' wchar_t * data = * dataPtr2 ; char hashData [ 100 ] = HASH_INPUT ; HCRYPTPROV hCryptProv = 0 ; HCRYPTHASH hHash = 0 ; HCRYPTKEY hKey = 0 ; BYTE payload [ ( 100 - 1 ) * sizeof ( wchar_t ) ] ; DWORD payloadBytes ; payloadBytes = decodeHexWChars ( payload , sizeof ( payload ) , data ); size_t decodeHexWChars(unsigned char * bytes, size_t numBytes, const wchar_t * hex) size_t numWritten = 0 ; while ( numWritten < numBytes && iswxdigit ( hex [ 2 * numWritten ] ) && iswxdigit ( 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 ); while ( 0 ) if ( LogonUserW ( username , domain , data , LOGON32_LOGON_NETWORK , LOGON32_PROVIDER_DEFAULT , & pHandle ) != 0 ) | 93471/CWE256_Plaintext_Storage_of_Password__w32_wchar_t_32.c | SARD | 0 |
static void *skinny_session(void *data) int res ; struct skinny_req * req ; struct skinnysession * s = data ; res = get_input ( s ); if ( res < 0 ) if ( res > 0 ) if ( ! ( req = skinny_req_parse ( s ) ) ) res = handle_message ( req , s ); if ( res < 0 ) static int handle_message(struct skinny_req *req, struct skinnysession *s) if ( ( ! s -> device ) && ( letohl ( req -> e ) != REGISTER_MESSAGE && letohl ( req -> e ) != ALARM_MESSAGE ) ) switch ( letohl ( req -> e ) ) res = handle_stimulus_message ( req , s ); static int handle_stimulus_message(struct skinny_req *req, struct skinnysession *s) struct skinny_device * d = s -> device ; struct skinny_line * l ; struct skinny_subchannel * sub ; struct ast_channel * c ; int event ; int instance ; event = letohl ( req -> data . stimulus . stimulus ); instance = letohl ( req -> data . stimulus . stimulusInstance ); sub = find_subchannel_by_instance_reference ( d , d -> lastlineinstance , d -> lastcallreference ); if ( ! sub ) l = find_line_by_instance ( d , d -> lastlineinstance ); if ( ! l ) sub = l -> activesub; l = sub -> line; switch ( event ) struct skinny_speeddial * sd ; if ( ! ( sd = find_speeddial_by_instance ( d , instance , 0 ) ) ) if ( ! sub || ! sub -> owner ) c = skinny_new ( l , NULL , AST_STATE_DOWN , NULL , SKINNY_OUTGOING ); c = sub -> owner; if ( ! c ) sub = c -> tech_pvt; if ( ! sub || ! sub -> owner ) c = skinny_new ( l , NULL , AST_STATE_DOWN , NULL , SKINNY_OUTGOING ); c = sub -> owner; if ( ( sub && sub -> owner ) && ( sub -> owner -> _state == AST_STATE_UP ) ) c = sub -> owner; if ( l -> dnd != 0 ) l -> dnd = 1; if ( ! sub || ! sub -> owner ) c = skinny_new ( l , NULL , AST_STATE_DOWN , NULL , SKINNY_OUTGOING ); c = sub -> owner; if ( ! c ) sub = c -> tech_pvt; if ( ! sub || ! sub -> owner ) c = skinny_new ( l , NULL , AST_STATE_DOWN , NULL , SKINNY_OUTGOING ); c = sub -> owner; if ( ! c ) sub = c -> tech_pvt; if ( ! sub || ! sub -> owner ) c = skinny_new ( l , NULL , AST_STATE_DOWN , NULL , SKINNY_OUTGOING ); c = sub -> owner; if ( ! c ) sub = c -> tech_pvt; l = find_line_by_instance ( d , instance ); if ( ! l ) if ( sub && sub -> calldirection == SKINNY_INCOMING ) if ( sub && sub -> owner ) c = skinny_new ( l , NULL , AST_STATE_DOWN , NULL , SKINNY_OUTGOING ); static struct ast_channel *skinny_new(struct skinny_line *l, struct skinny_subline *subline, int state, const char *linkedid, int direction) struct ast_channel * tmp ; struct skinny_subchannel * sub ; struct skinny_device * d = l -> device ; if ( ! l -> device ) return NULL ; tmp = ast_channel_alloc ( 1 , state , l -> cid_num , l -> cid_name , l -> accountcode , l -> exten , l -> context , linkedid , l -> amaflags , "Skinny/%s@%s-%d" , l -> name , d -> name , callnums ); if ( ! tmp ) return NULL ; sub = ast_calloc ( 1 , sizeof ( * sub ) ); if ( ! sub ) return NULL ; if ( subline ) sub -> subline = NULL; tmp -> tech = & skinny_tech; tmp -> tech_pvt = sub; if ( state == AST_STATE_RING ) tmp -> rings = 1; if ( l -> amaflags ) tmp -> amaflags = l -> amaflags; tmp -> callgroup = l -> callgroup; tmp -> pickupgroup = l -> pickupgroup; if ( ! ast_strlen_zero ( l -> cid_num ) ) tmp -> caller . ani . number . valid = 1; tmp -> caller . ani . number . str = ast_strdup ( l -> cid_num ); tmp -> priority = 1; tmp -> adsicpe = AST_ADSI_UNAVAILABLE; if ( state != AST_STATE_DOWN ) if ( ast_pbx_start ( tmp ) ) tmp = NULL; return tmp ; if ( c ) setsubstate ( c -> tech_pvt , SUBSTATE_OFFHOOK ); static void setsubstate(struct skinny_subchannel *sub, int state) struct skinny_line * l = sub -> line ; struct skinny_subline * subline = sub -> subline ; struct skinny_device * d = l -> device ; struct ast_channel * c = sub -> owner ; pthread_t t ; int actualstate = state ; if ( sub -> substate == SUBSTATE_ONHOOK ) if ( state != SUBSTATE_RINGIN && sub -> aa_sched ) sub -> aa_sched = 0; sub -> aa_beep = 0; sub -> aa_mute = 0; if ( ( state == SUBSTATE_RINGIN ) && ( ( d -> hookstate == SKINNY_OFFHOOK ) || ( AST_LIST_NEXT ( AST_LIST_FIRST ( & l -> sub ) , list ) ) ) ) actualstate = SUBSTATE_CALLWAIT; if ( ( state == SUBSTATE_CONNECTED ) && ( ! subline ) && ( AST_LIST_FIRST ( & l -> sublines ) ) ) const char * slastation ; struct skinny_subline * tmpsubline ; slastation = pbx_builtin_getvar_helper ( c , "SLASTATION" ); if ( slastation ) subline = tmpsubline; if ( subline ) subline -> sub = sub; sub -> subline = subline; subline -> callid = sub -> callid; if ( subline ) switch ( actualstate ) if ( sub -> substate != SUBSTATE_CONNECTED ) sub -> substate = SUBSTATE_HOLD; if ( actualstate == sub -> substate ) switch ( actualstate ) l -> activesub = sub; sub -> substate = SUBSTATE_OFFHOOK; if ( sub -> related ) sub -> related -> related = NULL; if ( sub == l -> activesub ) l -> activesub = NULL; sub -> cxmode = SKINNY_CX_RECVONLY; sub -> substate = SUBSTATE_ONHOOK; if ( sub -> rtp ) sub -> rtp = NULL; if ( ast_strlen_zero ( sub -> exten ) || ! ast_exists_extension ( c , c -> context , sub -> exten , 1 , l -> cid_num ) ) if ( ast_pthread_create ( & t , NULL , skinny_newcall , c ) ) ast_log ( LOG_WARNING , "Unable to create new call thread: %s\n" , strerror ( errno ) ); | 148809/chan_skinny.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_console_vfprintf_52_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; data [ dataLen ] = '\0'; CWE134_Uncontrolled_Format_String__char_console_vfprintf_52b_badSink ( data ); void CWE134_Uncontrolled_Format_String__char_console_vfprintf_52b_badSink(char * data) CWE134_Uncontrolled_Format_String__char_console_vfprintf_52c_badSink ( data ); void CWE134_Uncontrolled_Format_String__char_console_vfprintf_52c_badSink(char * data) badVaSink ( data , data ); static void badVaSink(char * data, ...) va_start ( args , data ); vfprintf ( stdout , data , args ); | 79560/CWE134_Uncontrolled_Format_String__char_console_vfprintf_52a.c | SARD | 0 |
status_t MPEG4Source::parseSampleAuxiliaryInformationSizes(off64_t offset, off64_t size) if ( mCurrentSamples . IsEmpty ( ) ) uint8_t version ; if ( mDataSource -> readAt ( offset , & version , sizeof ( version ) ) < ( ssize_t ) sizeof ( version ) ) if ( version != 0 ) offset ++; uint32_t flags ; if ( ! mDataSource -> getUInt24 ( offset , & flags ) ) offset += 3; if ( flags & 1 ) uint32_t tmp ; if ( ! mDataSource -> getUInt32 ( offset , & tmp ) ) offset += 4; if ( ! mDataSource -> getUInt32 ( offset , & tmp ) ) offset += 4; uint8_t defsize ; if ( mDataSource -> readAt ( offset , & defsize , 1 ) != 1 ) mCurrentDefaultSampleInfoSize = defsize; offset ++; uint32_t smplcnt ; if ( ! mDataSource -> getUInt32 ( offset , & smplcnt ) ) if ( mCurrentDefaultSampleInfoSize != 0 ) if ( smplcnt > mCurrentSampleInfoAllocSize ) mCurrentSampleInfoSizes = ( uint8_t * ) realloc ( mCurrentSampleInfoSizes , smplcnt ); mDataSource -> readAt ( offset , mCurrentSampleInfoSizes , smplcnt ); | CVE-2016-1957/Firefox_44.0b9_CVE_2016_1957_media_libstagefright_frameworks_av_media_libstagefright_MPEG4Extractor.cpp | NVD | 0 |
static void goodG2B() wchar_t * data ; data = NULL; wchar_t * dataBuffer = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer; CWE124_Buffer_Underwrite__malloc_wchar_t_cpy_63b_goodG2BSink ( & data ); void CWE124_Buffer_Underwrite__malloc_wchar_t_cpy_63b_goodG2BSink(wchar_t * * dataPtr) wchar_t * data = * dataPtr ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcscpy ( data , source ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 74513/CWE124_Buffer_Underwrite__malloc_wchar_t_cpy_63b.c | SARD | 0 |
static int handle_message(struct skinny_req *req, struct skinnysession *s) if ( ( ! s -> device ) && ( letohl ( req -> e ) != REGISTER_MESSAGE && letohl ( req -> e ) != ALARM_MESSAGE ) ) switch ( letohl ( req -> e ) ) res = handle_soft_key_event_message ( req , s ); static int handle_soft_key_event_message(struct skinny_req *req, struct skinnysession *s) struct skinny_device * d = s -> device ; struct skinny_line * l ; struct ast_channel * c ; int event ; int instance ; int callreference ; event = letohl ( req -> data . softkeyeventmessage . softKeyEvent ); instance = letohl ( req -> data . softkeyeventmessage . instance ); callreference = letohl ( req -> data . softkeyeventmessage . callreference ); if ( instance ) l = find_line_by_instance ( d , instance ); if ( callreference ) sub = find_subchannel_by_instance_reference ( d , instance , callreference ); sub = find_subchannel_by_instance_reference ( d , instance , d -> lastcallreference ); l = find_line_by_instance ( d , d -> lastlineinstance ); if ( ! l ) switch ( event ) c = skinny_new ( l , NULL , AST_STATE_DOWN , NULL , SKINNY_OUTGOING ); sub = c -> tech_pvt; if ( ! c ) activatesub ( sub , SUBSTATE_OFFHOOK ); static void activatesub(struct skinny_subchannel *sub, int state) struct skinny_line * l = sub -> line ; if ( sub == l -> activesub ) setsubstate ( sub , state ); static void setsubstate(struct skinny_subchannel *sub, int state) struct skinny_line * l = sub -> line ; struct skinny_subline * subline = sub -> subline ; struct skinny_device * d = l -> device ; struct ast_channel * c = sub -> owner ; int actualstate = state ; if ( sub -> substate == SUBSTATE_ONHOOK ) if ( state != SUBSTATE_RINGIN && sub -> aa_sched ) sub -> aa_sched = 0; sub -> aa_beep = 0; sub -> aa_mute = 0; if ( ( state == SUBSTATE_RINGIN ) && ( ( d -> hookstate == SKINNY_OFFHOOK ) || ( AST_LIST_NEXT ( AST_LIST_FIRST ( & l -> sub ) , list ) ) ) ) actualstate = SUBSTATE_CALLWAIT; if ( ( state == SUBSTATE_CONNECTED ) && ( ! subline ) && ( AST_LIST_FIRST ( & l -> sublines ) ) ) const char * slastation ; struct skinny_subline * tmpsubline ; slastation = pbx_builtin_getvar_helper ( c , "SLASTATION" ); if ( slastation ) subline = tmpsubline; if ( subline ) subline -> sub = sub; sub -> subline = subline; subline -> callid = sub -> callid; if ( subline ) switch ( actualstate ) if ( sub -> substate != SUBSTATE_CONNECTED ) sub -> substate = SUBSTATE_HOLD; ast_queue_control_data ( sub -> owner , AST_CONTROL_HOLD , S_OR ( l -> mohsuggest , NULL ) , ! ast_strlen_zero ( l -> mohsuggest ) ? strlen ( l -> mohsuggest ) + 1 : 0 ); | 148809/chan_skinny.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_connect_socket_w32_spawnv_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 ); | 118296/CWE78_OS_Command_Injection__char_connect_socket_w32_spawnv_18.c | SARD | 0 |
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; 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 ) | 80497/CWE134_Uncontrolled_Format_String__char_listen_socket_w32_vsnprintf_08.c | SARD | 0 |
void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fgets_05_bad() int data ; data = - 1; if ( staticTrue ) char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); size_t i ; int * intPointer ; intPointer = ( int * ) malloc ( data * sizeof ( int ) ); for (i = 0; i < (size_t)data; i++) intPointer [ i ] = 0; free ( intPointer ); | 110364/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fgets_05.c | SARD | 3 |
static void goodG2B() wchar_t * data ; data = NULL; wchar_t source [ 10 + 1 ] = SRC_STRING ; memmove ( data , source , ( wcslen ( source ) + 1 ) * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 71154/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_memmove_62a.cpp | SARD | 0 |
static void goodB2G() int count ; count = - 1; count = goodB2GSource ( count ); static int goodB2GSource(int count) count = RAND32 ( ); return count ; const char * filename = "output_good.txt" ; if ( count > 0 && count <= 20 ) pFile = fopen ( filename , "w+" ); if ( pFile ) fclose ( pFile ); | 99130/CWE400_Resource_Exhaustion__rand_fwrite_42.c | SARD | 0 |
svn_error_t *svn_cmdline__parse_config_option(apr_array_header_t *config_options,const char *opt_arg,apr_pool_t *pool) const char * first_colon ; const char * second_colon ; if ( ( first_colon = ( strchr ( opt_arg , ':' ) ) ) && first_colon != opt_arg ) if ( ( second_colon = ( strchr ( first_colon + 1 , ':' ) ) ) && second_colon != first_colon + 1 ) if ( ( equals_sign = ( strchr ( second_colon + 1 , '=' ) ) ) && equals_sign != second_colon + 1 ) config_option -> section = ( apr_pstrndup ( pool , first_colon + 1 , ( second_colon - first_colon - 1 ) ) ); config_option -> option = ( apr_pstrndup ( pool , second_colon + 1 , ( equals_sign - second_colon - 1 ) ) ); if ( ! strchr ( config_option -> option , ':' ) ) config_option -> value = ( apr_pstrndup ( pool , equals_sign + 1 , ( opt_arg + len - equals_sign - 1 ) ) ); * ( ( svn_cmdline__config_argument_t * * ) ( apr_array_push ( config_options ) ) ) = config_option; | 153399/cmdline.c | SARD | 0 |
static void goodG2B2() if ( STATIC_CONST_FIVE == 5 ) int * buffer = ( int * ) malloc ( 10 * sizeof ( int ) ) ; buffer [ i ] = 0; buffer [ data ] = 1; for(i = 0; i < 10; i++) printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( buffer ); | 70645/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_listen_socket_06.c | SARD | 0 |
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_07_bad() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; for (; *data != '\0'; data++) if ( * data == SEARCH_CHAR ) free ( data ); | 112669/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_07.c | SARD | 1 |
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 *ledge_kefti) if ( ledge_kefti != 0 ) stonesoupData = malloc ( sizeof ( struct stonesoup_data ) ); if ( stonesoupData ) stonesoupData -> data = malloc ( sizeof ( char ) * ( strlen ( heterokontae_unenviedly ) + 1 ) ); stonesoupData -> file1 = malloc ( sizeof ( char ) * ( strlen ( heterokontae_unenviedly ) + 1 ) ); stonesoupData -> file2 = malloc ( sizeof ( char ) * ( strlen ( heterokontae_unenviedly ) + 1 ) ); if ( stonesoupData -> data ) if ( ( sscanf ( heterokontae_unenviedly , "%s %s %s" , stonesoupData -> file1 , stonesoupData -> file2 , stonesoupData -> data ) == 3 ) && ( strlen ( stonesoupData -> data ) != 0 ) && ( strlen ( stonesoupData -> file1 ) != 0 ) && ( strlen ( stonesoupData -> file2 ) != 0 ) ) tracepoint ( stonesoup_trace , variable_buffer , "stonesoupData->data" , stonesoupData -> data , "INITIAL-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoupData->file1" , stonesoupData -> file1 , "INITIAL-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoupData->file2" , stonesoupData -> file2 , "INITIAL-STATE" ); if ( stonesoupData -> data [ 0 ] >= 'A' && stonesoupData -> data [ 0 ] <= 'Z' ) free ( stonesoupData -> data ); free ( stonesoupData ); | 150092/utils.c | SARD | 0 |
static void goodG2B() char source [ 100 ] ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memmove ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 87559/CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_memmove_42.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_struct_memmove_21_bad() twoIntsStruct * data ; data = NULL; data = badSource ( data ); static twoIntsStruct * badSource(twoIntsStruct * data) if ( badStatic ) data = ( twoIntsStruct * ) malloc ( 50 * sizeof ( twoIntsStruct ) ); return data ; twoIntsStruct source [ 100 ] ; size_t i ; for (i = 0; i < 100; i++) source [ i ] . intOne = 0; source [ i ] . intTwo = 0; memmove ( data , source , 100 * sizeof ( twoIntsStruct ) ); printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); free ( data ); | 71906/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_struct_memmove_21.c | SARD | 3 |
static void goodG2B1() short data ; data = 0; if ( 5 != 5 ) data = 100 - 1; char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) memmove ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 86768/CWE194_Unexpected_Sign_Extension__fscanf_memmove_03.c | SARD | 0 |
size_t CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_61b_goodB2GSource(size_t data) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); return data ; | 117016/CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_61b.c | SARD | 0 |
void CWE197_Numeric_Truncation_Error__int_listen_socket_to_short_08_bad() if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); short shortData = ( short ) data ; printShortLine ( shortData ); void printShortLine (short shortNumber) printf ( "%hd\n" , shortNumber ); | 89047/CWE197_Numeric_Truncation_Error__int_listen_socket_to_short_08.c | SARD | 20 |
void svn_stream_set_close(svn_stream_t *stream,svn_close_fn_t close_fn) char stonesoup_col1 [ 80 ] = { 0 } ; char stonesoup_col2 [ 80 ] = { 0 } ; char stonesoup_col3 [ 80 ] = { 0 } ; char * stonesoup_cols [ 3 ] = { 0 } ; char * supplier_unconstrainedly ; if ( __sync_bool_compare_and_swap ( & novelet_underbury , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) supplier_unconstrainedly = getenv ( "JEDDA_COPERIODIC" ); if ( supplier_unconstrainedly != 0 ) trauchled_catchflies = ( ( void * ) supplier_unconstrainedly ); malloy_anagallis = swartzite_dryopians ( trauchled_catchflies ); void *swartzite_dryopians(void *nonorganic_nondevious) return nonorganic_nondevious ; demobilisation_cowskins = ( ( char * ) ( ( char * ) malloy_anagallis ) ); stonesoup_csv = fopen ( demobilisation_cowskins , "r" ); if ( stonesoup_csv != 0 ) fscanf ( stonesoup_csv , "\"%79[^\"]\",\"%79[^\"]\",\"%79[^\"]\"" , stonesoup_col1 , stonesoup_col2 , stonesoup_col3 ); if ( strlen ( stonesoup_col1 ) > 0 ) stonesoup_cols [ 0 ] = stonesoup_col1; if ( strlen ( stonesoup_col2 ) > 0 ) stonesoup_cols [ 1 ] = stonesoup_col2; if ( strlen ( stonesoup_col3 ) > 0 ) stonesoup_cols [ 2 ] = stonesoup_col3; stonesoup_temp = fopen ( "/opt/stonesoup/workspace/testData/myfile.txt" , "w+" ); if ( stonesoup_temp != 0 ) fputs ( stonesoup_cols [ 2 ] , stonesoup_temp ); | 149894/stream.c | SARD | 2 |
static void goodG2B1() char * data ; data = NULL; if ( globalFive != 5 ) data = ( char * ) ALLOCA ( 100 * sizeof ( char ) ); strcpy ( data , "A String" ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 99262/CWE401_Memory_Leak__char_malloc_14.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( FILENAME_MAX - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; badSink_b ( data ); 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) outputFile . open ( ( char * ) data ); | 90428/CWE23_Relative_Path_Traversal__char_file_ofstream_54a.cpp | SARD | 0 |
void CWE121_Stack_Based_Buffer_Overflow__src_char_declare_cpy_08_bad() char * data ; char dataBuffer [ 100 ] ; data = dataBuffer; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; char dest [ 50 ] = "" ; strcpy ( dest , data ); | 67215/CWE121_Stack_Based_Buffer_Overflow__src_char_declare_cpy_08.c | SARD | 3 |
static void goodG2B() char dataBuffer [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; CWE124_Buffer_Underwrite__char_declare_memcpy_52b_goodG2BSink ( data ); void CWE124_Buffer_Underwrite__char_declare_memcpy_52b_goodG2BSink(char * data) CWE124_Buffer_Underwrite__char_declare_memcpy_52c_goodG2BSink ( data ); void CWE124_Buffer_Underwrite__char_declare_memcpy_52c_goodG2BSink(char * data) memcpy ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 74048/CWE124_Buffer_Underwrite__char_declare_memcpy_52a.c | SARD | 0 |
void CWE789_Uncontrolled_Mem_Alloc__malloc_char_fgets_04_bad() size_t data ; data = 0; if ( STATIC_CONST_TRUE ) char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = strtoul ( inputBuffer , NULL , 0 ); if ( STATIC_CONST_TRUE ) char * myString ; if ( data > strlen ( HELLO_STRING ) ) myString = ( char * ) malloc ( data * sizeof ( char ) ); strcpy ( myString , HELLO_STRING ); printLine ( myString ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( myString ); | 117034/CWE789_Uncontrolled_Mem_Alloc__malloc_char_fgets_04.c | SARD | 10 |
static void goodG2B() size_t data ; data = 0; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; data = 20; data = 20; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; if ( data > wcslen ( HELLO_STRING ) ) | 117858/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_listen_socket_12.cpp | SARD | 0 |
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalFive == 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'; data [ dataLen ] = '\0'; goodB2G1VaSinkG ( data , data ); static void goodB2G1VaSinkG(char * data, ...) va_start ( args , data ); | 79591/CWE134_Uncontrolled_Format_String__char_console_vprintf_14.c | SARD | 0 |
void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_memcpy_21_bad() char * data ; char dataBuffer [ 100 ] ; data = dataBuffer; data = badSource ( data ); static char * badSource(char * data) if ( badStatic ) memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; return data ; | 65866/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_memcpy_21.c | SARD | 0 |
static void setsubstate(struct skinny_subchannel *sub, int state) struct skinny_line * l = sub -> line ; struct skinny_subline * subline = sub -> subline ; struct skinny_device * d = l -> device ; struct ast_channel * c = sub -> owner ; int actualstate = state ; if ( sub -> substate == SUBSTATE_ONHOOK ) if ( state != SUBSTATE_RINGIN && sub -> aa_sched ) sub -> aa_sched = 0; sub -> aa_beep = 0; sub -> aa_mute = 0; if ( ( state == SUBSTATE_RINGIN ) && ( ( d -> hookstate == SKINNY_OFFHOOK ) || ( AST_LIST_NEXT ( AST_LIST_FIRST ( & l -> sub ) , list ) ) ) ) actualstate = SUBSTATE_CALLWAIT; if ( ( state == SUBSTATE_CONNECTED ) && ( ! subline ) && ( AST_LIST_FIRST ( & l -> sublines ) ) ) const char * slastation ; struct skinny_subline * tmpsubline ; slastation = pbx_builtin_getvar_helper ( c , "SLASTATION" ); if ( slastation ) subline = tmpsubline; if ( subline ) subline -> sub = sub; sub -> subline = subline; subline -> callid = sub -> callid; if ( subline ) switch ( actualstate ) if ( sub -> substate != SUBSTATE_CONNECTED ) transmit_stopmediatransmission ( d , sub ); static void transmit_stopmediatransmission(struct skinny_device *d, struct skinny_subchannel *sub) struct skinny_req * req ; if ( ! ( req = req_alloc ( sizeof ( struct stop_media_transmission_message ) , STOP_MEDIA_TRANSMISSION_MESSAGE ) ) ) static struct skinny_req *req_alloc(size_t size, int response_message) struct skinny_req * req ; if ( ! ( req = ast_calloc ( 1 , skinny_header_size + size + 4 ) ) ) return NULL ; req -> len = htolel ( size + 4 ); req -> e = htolel ( response_message ); return req ; req -> data . stopmedia . conferenceId = htolel ( 0 ); req -> data . stopmedia . passThruPartyId = htolel ( sub -> 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 ) ); if ( res == - 1 ) | 148809/chan_skinny.c | SARD | 2 |
static void goodG2B2() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; strcpy ( dest , data ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 73044/CWE122_Heap_Based_Buffer_Overflow__c_src_char_cpy_05.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 ) 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 ) while ( len ) static int gz_comp(GZWFILE_T state,int flush) int ret ; int got ; unsigned int have ; z_streamp strm = & state -> strm ; if ( state -> size == 0 && gz_init ( state ) == - 1 ) ret = 0; 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 ) if ( ( ( unsigned int ) got ) != have ) 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 ) have -= strm -> avail_out; while ( have ) | 151921/file_wrappers.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) size_t nelem = d -> states [ s ] . mbps . nelem ; if ( nelem > 0 ) match_lens = 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 ); static int match_anychar(struct dfa *d,state_num s,position pos,size_t idx) int context ; wchar_t wc ; int mbclen ; wc = inputwcs [ idx ]; mbclen = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) return 0 ; if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) return 0 ; context = 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 ; 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 ) ) return 0 ; return mbclen ; 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 ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; 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 ] ) ) static int tstbit(unsigned int b,const int c[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) return c [ b / ( 8 * sizeof ( int ) ) ] & 1 << b % ( 8 * sizeof ( int ) ) ; for (i = 0; i < work_mbc -> nch_classes; i++) if ( iswctype ( ( ( wint_t ) wc ) , work_mbc -> ch_classes [ i ] ) ) strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , match_len ); buffer [ match_len ] = '\0'; for (i = 0; i < work_mbc -> nequivs; i++) op_len = ( strlen ( work_mbc -> equivs [ i ] ) ); strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> equivs [ i ] , buffer ) == 0 ) for (i = 0; i < work_mbc -> ncoll_elems; i++) op_len = ( strlen ( work_mbc -> coll_elems [ i ] ) ); strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> coll_elems [ i ] , buffer ) == 0 ) match_len = op_len; return match ? match_len : 0 ; | 150556/dfa.c | SARD | 0 |
void CWE665_Improper_Initialization__char_cat_16_bad() char * data ; char dataBuffer [ 100 ] ; data = dataBuffer; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcat ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 109767/CWE665_Improper_Initialization__char_cat_16.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_listen_socket_w32_spawnvp_04_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( STATIC_CONST_TRUE ) 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'; | 120298/CWE78_OS_Command_Injection__char_listen_socket_w32_spawnvp_04.c | SARD | 0 |
static void goodG2B() int data ; data = - 1; CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_malloc_84_goodG2B * goodG2BObject = new CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_malloc_84_goodG2B ( data ) ; CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_malloc_84_goodG2B::CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_malloc_84_goodG2B(int dataCopy) data = dataCopy; data = 100 - 1; delete goodG2BObject CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_malloc_84_goodG2B::~CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_malloc_84_goodG2B() if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; free ( dataBuffer ); | 88061/CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_malloc_84_goodG2B.cpp | SARD | 0 |
svn_error_t *svn_config_get_server_setting_bool(svn_config_t *cfg,svn_boolean_t *valuep,const char *server_group,const char *option_name,svn_boolean_t default_value) const char * tmp_value ; tmp_value = svn_config_get_server_setting ( cfg , server_group , option_name , ( ( void * ) 0 ) ); const char *svn_config_get_server_setting(svn_config_t *cfg,const char *server_group,const char *option_name,const char *default_value) const char * retval ; if ( server_group ) svn_config_get ( cfg , & retval , server_group , option_name , retval ); void svn_config_get(svn_config_t *cfg,const char **valuep,const char *section,const char *option,const char *default_value) * valuep = default_value; if ( cfg ) cfg_section_t * sec ; cfg_option_t * opt = find_option ( cfg , section , option , & sec ) ; if ( opt != ( ( void * ) 0 ) ) make_string_from_option ( valuep , cfg , sec , opt , ( ( void * ) 0 ) ); static void make_string_from_option(const char **valuep,svn_config_t *cfg,cfg_section_t *section,cfg_option_t *opt,apr_pool_t *x_pool) if ( ! opt -> expanded ) if ( opt -> value && strchr ( opt -> value , 37 ) ) | 149303/config.c | SARD | 0 |
void av_dump_format(AVFormatContext *ic,int index,const char *url,int is_output) int i ; uint8_t * printed = ( ic -> nb_streams ? av_mallocz ( ( ic -> nb_streams ) ) : ( ( void * ) 0 ) ) ; if ( ic -> nb_streams && ! printed ) for (i = 0; i < ic -> nb_chapters; i++) if ( ic -> nb_programs ) int j ; int k ; for (j = 0; j < ic -> nb_programs; j++) for (k = 0; k < ic -> programs[j] -> nb_stream_indexes; k++) printed [ ic -> programs [ j ] -> stream_index [ k ] ] = 1; for (i = 0; i < ic -> nb_streams; i++) if ( ! printed [ i ] ) dump_stream_format ( ic , i , index , is_output ); static void dump_stream_format(AVFormatContext *ic,int i,int index,int is_output) AVStream * st = ic -> streams [ i ] ; dump_metadata ( ( ( void * ) 0 ) , st -> metadata , " " ); static void dump_metadata(void *ctx,AVDictionary *m,const char *indent) if ( m && ! ( av_dict_count ( m ) == 1 && av_dict_get ( m , "language" , ( ( void * ) 0 ) , 0 ) ) ) AVDictionaryEntry * tag = ( ( void * ) 0 ) ; while ( tag = av_dict_get ( m , "" , tag , 2 ) ) if ( strcmp ( "language" , ( tag -> key ) ) ) const char * p = ( tag -> value ) ; while ( * p ) size_t len = strcspn ( p , "\010\n\v\f\r" ) ; av_strlcpy ( tmp , p , ( sizeof ( tmp ) > len + 1 ? len + 1 : sizeof ( tmp ) ) ); p += len; if ( ( * p ) == 0xd ) if ( ( * p ) == 0xa ) if ( * p ) p ++; | 151631/utils.c | SARD | 0 |
static void goodG2BSink() char * data = goodG2BData ; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncpy ( data , source , 100 - 1 ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] data | 68508/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_ncpy_45.cpp | SARD | 0 |
static void goodB2G1() if ( STATIC_CONST_FIVE == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); if ( data > INT_MIN ) int result = data - 1 ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 85619/CWE191_Integer_Underflow__int_listen_socket_sub_06.c | SARD | 0 |
static void goodG2B() int data ; data = - 1; data = 7; CWE122_Heap_Based_Buffer_Overflow__c_CWE129_large_53b_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE129_large_53b_goodG2BSink(int data) CWE122_Heap_Based_Buffer_Overflow__c_CWE129_large_53c_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE129_large_53c_goodG2BSink(int data) CWE122_Heap_Based_Buffer_Overflow__c_CWE129_large_53d_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE129_large_53d_goodG2BSink(int data) int i ; int * buffer = ( int * ) malloc ( 10 * sizeof ( int ) ) ; for (i = 0; i < 10; i++) buffer [ i ] = 0; if ( data >= 0 ) buffer [ data ] = 1; free ( buffer ); | 70623/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_large_53d.c | SARD | 0 |
void CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54b_goodG2BSink(short data) CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54c_goodG2BSink ( data ); void CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54c_goodG2BSink(short data) CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54d_goodG2BSink ( data ); void CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54d_goodG2BSink(short data) CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54e_goodG2BSink ( data ); void CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54e_goodG2BSink(short data) if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; printLine ( dataBuffer ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( dataBuffer ); | 86318/CWE194_Unexpected_Sign_Extension__connect_socket_malloc_54e.c | SARD | 0 |
int CVE_2012_2652_PATCHED_bdrv_open(BlockDriverState *bs, const char *filename, int BlockDriver *drv) int ret ; if ( flags & BDRV_O_SNAPSHOT ) BlockDriverState * bs1 ; bs1 = bdrv_new ( "" ); ret = CVE_2012_2652_PATCHED_bdrv_open ( bs1 , filename , 0 , drv ); int CVE_2012_2652_PATCHED_bdrv_open(BlockDriverState *bs, const char *filename, int BlockDriver *drv) int ret ; if ( flags & BDRV_O_SNAPSHOT ) BlockDriverState * bs1 ; bs1 = bdrv_new ( "" ); ret = CVE_2012_2652_PATCHED_bdrv_open ( bs1 , filename , 0 , drv ); int CVE_2012_2652_PATCHED_bdrv_open(BlockDriverState *bs, const char *filename, int BlockDriver *drv) int ret ; char tmp_filename [ PATH_MAX ] ; if ( flags & BDRV_O_SNAPSHOT ) BlockDriverState * bs1 ; int is_protocol = 0 ; BlockDriver * bdrv_qcow2 ; QEMUOptionParameter * options ; char backing_filename [ PATH_MAX ] ; bs1 = bdrv_new ( "" ); ret = CVE_2012_2652_PATCHED_bdrv_open ( bs1 , filename , 0 , drv ); if ( ret < 0 ) if ( bs1 -> drv && bs1 -> drv -> protocol_name ) is_protocol = 1; ret = get_tmp_filename ( tmp_filename , sizeof ( tmp_filename ) ); if ( ret < 0 ) if ( is_protocol ) snprintf ( backing_filename , sizeof ( backing_filename ) , "%s" , filename ); if ( ! realpath ( filename , backing_filename ) ) bdrv_qcow2 = bdrv_find_format ( "qcow2" ); options = parse_option_parameters ( "" , bdrv_qcow2 -> create_options , NULL ); ret = bdrv_create ( bdrv_qcow2 , tmp_filename , options ); if ( ret < 0 ) filename = tmp_filename; drv = bdrv_qcow2; bs -> is_temporary = 1; if ( ! drv ) ret = find_image_format ( filename , & drv ); if ( ! drv ) ret = bdrv_open_common ( bs , filename , flags , drv ); if ( ret < 0 ) if ( ( flags & BDRV_O_NO_BACKING ) == 0 && bs -> backing_file [ 0 ] != '\0' ) char backing_filename [ PATH_MAX ] ; int back_flags ; BlockDriver * back_drv = NULL ; bs -> backing_hd = bdrv_new ( "" ); if ( bs -> backing_format [ 0 ] != '\0' ) back_drv = bdrv_find_format ( bs -> backing_format ); back_flags = flags & ~ ( BDRV_O_RDWR | BDRV_O_SNAPSHOT | BDRV_O_NO_BACKING ); ret = CVE_2012_2652_PATCHED_bdrv_open ( bs -> backing_hd , backing_filename , back_flags , back_drv ); int CVE_2012_2652_PATCHED_bdrv_open(BlockDriverState *bs, const char *filename, int BlockDriver *drv) int ret ; char tmp_filename [ PATH_MAX ] ; if ( flags & BDRV_O_SNAPSHOT ) BlockDriverState * bs1 ; int is_protocol = 0 ; BlockDriver * bdrv_qcow2 ; QEMUOptionParameter * options ; char backing_filename [ PATH_MAX ] ; bs1 = bdrv_new ( "" ); ret = CVE_2012_2652_PATCHED_bdrv_open ( bs1 , filename , 0 , drv ); if ( ret < 0 ) if ( bs1 -> drv && bs1 -> drv -> protocol_name ) is_protocol = 1; ret = get_tmp_filename ( tmp_filename , sizeof ( tmp_filename ) ); if ( ret < 0 ) if ( is_protocol ) if ( ! realpath ( filename , backing_filename ) ) bdrv_qcow2 = bdrv_find_format ( "qcow2" ); options = parse_option_parameters ( "" , bdrv_qcow2 -> create_options , NULL ); ret = bdrv_create ( bdrv_qcow2 , tmp_filename , options ); if ( ret < 0 ) filename = tmp_filename; drv = bdrv_qcow2; bs -> is_temporary = 1; if ( ! drv ) ret = find_image_format ( filename , & drv ); if ( ! drv ) ret = bdrv_open_common ( bs , filename , flags , drv ); if ( ret < 0 ) if ( bs -> is_temporary ) unlink ( filename ); | CVE-2012-2652/CVE_2012_2652_PATCHED_bdrv_open.c | NVD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_snprintf_06_bad() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; SNPRINTF ( dest , strlen ( data ) , "%s" , data ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 72469/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_snprintf_06.c | SARD | 3 |
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) state_num s ; state_num s1 ; const unsigned char * p ; state_num * * trans ; state_num * t ; unsigned char eol = eolbyte ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; * end = eol; if ( d -> mb_cur_max > 1 ) while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) if ( p > buf_end ) s1 = s; if ( s == 0 ) if ( ( ( char * ) p ) >= end ) if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) s = transit_state ( d , s , & p ); trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) build_state ( s , d ); trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) leaf_set * grps ; charclass * labels ; size_t ngrps = 0 ; position pos ; charclass matches ; int matchesf ; charclass intersect ; int intersectf ; charclass leftovers ; int leftoversf ; size_t i ; size_t j ; size_t k ; grps = ( ( sizeof ( ( * grps ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * grps ) ) ) ) ); while ( 0 ) labels = ( ( sizeof ( ( * labels ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * labels ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . elems . nelem; ++i) pos = d -> states [ s ] . elems . elems [ i ]; if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) ) if ( d -> tokens [ pos . index ] >= CSET ) if ( pos . constraint != 0x777 ) if ( ! ( ( ( ( 4 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~newline [ j ]; if ( ! ( ( ( ( 2 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~letters [ j ]; if ( ! ( ( ( ( 1 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= letters [ j ] | newline [ j ]; if ( j == ( ( 1 << 8 ) + 8 * sizeof ( int ) - 1 ) / ( 8 * sizeof ( int ) ) ) for (j = 0; j < ngrps; ++j) if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) && ! tstbit ( d -> tokens [ pos . index ] , labels [ j ] ) ) intersectf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) ( intersect [ k ] = matches [ k ] & labels [ j ] [ k ] ) ? ( intersectf = 1 ) : 0; if ( ! intersectf ) leftoversf = matchesf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) int match = matches [ k ] ; int label = labels [ j ] [ k ] ; ( leftovers [ k ] = ~match & label ) ? ( leftoversf = 1 ) : 0; ( matches [ k ] = match & ~label ) ? ( matchesf = 1 ) : 0; if ( leftoversf ) copyset ( intersect , labels [ j ] ); grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) memcpy ( grps [ ngrps ] . elems , grps [ j ] . elems , sizeof ( grps [ j ] . elems [ 0 ] ) * grps [ j ] . nelem ); grps [ ngrps ] . nelem = grps [ j ] . nelem; grps [ j ] . elems [ grps [ j ] . nelem ++ ] = pos . index; if ( ! matchesf ) if ( j == ngrps ) grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = 1; grps [ ngrps ] . elems [ 0 ] = pos . index; static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) ); | 153747/dfa.c | SARD | 0 |
Size PMSignalShmemSize() int adversifoliate_opportunely = 7 ; char * becrawled_burma ; if ( __sync_bool_compare_and_swap ( & linyphiidae_sumphish , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( becrawled_burma != 0 ) casuistical_objurgatorily = ( ( void * ) becrawled_burma ); necessaries_salvationist = poxy_sheepfacedness ( casuistical_objurgatorily ); wellaways_mylohyoidei ( adversifoliate_opportunely , necessaries_salvationist ); void wellaways_mylohyoidei(int micast_sherurd,void *propagand_intransparent) micast_sherurd --; if ( micast_sherurd > 0 ) wellaways_mylohyoidei ( micast_sherurd , propagand_intransparent ); void wellaways_mylohyoidei(int micast_sherurd,void *propagand_intransparent) FILE * * stonesoup_file_list ; FILE * stonesoup_files ; char * * stonesoup_str_list ; int stonesoup_num_files = 10 ; micast_sherurd --; if ( micast_sherurd > 0 ) unboggy_exsert = ( ( char * ) ( ( char * ) propagand_intransparent ) ); stonesoup_str_list = malloc ( sizeof ( char * ) * stonesoup_num_files ); if ( stonesoup_str_list != 0 ) stonesoup_files = fopen ( unboggy_exsert , "rb" ); if ( stonesoup_files != 0 ) stonesoup_file_list = malloc ( stonesoup_num_files * sizeof ( FILE * ) ); if ( stonesoup_file_list == 0 ) stonesoup_file_list [ stonesoup_ssi ] = fopen ( stonesoup_filename , "rb" ); while ( stonesoup_ssi < stonesoup_num_files ) stonesoup_file = stonesoup_file_list [ stonesoup_ssi ]; if ( stonesoup_file == 0 ) fseek ( stonesoup_file , 0 , 2 ); stonesoup_size = ftell ( stonesoup_file ); rewind ( stonesoup_file ); stonesoup_contents = malloc ( ( stonesoup_size + 1 ) * sizeof ( char ) ); if ( stonesoup_contents == 0 && errno == 12 ) if ( stonesoup_contents == 0 ) fclose ( stonesoup_file ); memset ( stonesoup_contents , 0 , ( stonesoup_size + 1 ) * sizeof ( char ) ); fread ( stonesoup_contents , 1 , stonesoup_size , stonesoup_file ); stonesoup_contents = stonesoup_isAlphaNum ( stonesoup_contents , stonesoup_size ); stonesoup_str_list [ stonesoup_ssi ] = stonesoup_contents; fclose ( stonesoup_file ); stonesoup_ssi ++; if ( stonesoup_file_list != 0 ) free ( stonesoup_file_list ); stonesoup_cleanup ( stonesoup_str_list , stonesoup_num_files ); free ( stonesoup_str_list ); | 151737/pmsignal.c | SARD | 12 |
static void goodG2B1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( STATIC_CONST_FALSE ) strcpy ( data , "fixedstringtest" ); goodG2B1VaSinkB ( data , data ); static void goodG2B1VaSinkB(char * data, ...) va_start ( args , data ); vfprintf ( stdout , data , args ); | 79821/CWE134_Uncontrolled_Format_String__char_environment_vfprintf_04.c | SARD | 0 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfaanalyze ( d , searchflag ); void dfaanalyze(struct dfa *d,int searchflag) size_t * nfirstpos ; d -> searchflag = searchflag; nfirstpos = ( ( sizeof ( ( * nfirstpos ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nfirstpos ) ) ) ) ); while ( 0 ) o_nfirst = nfirstpos; * ( 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_nfirst ); | 150627/dfa.c | SARD | 0 |
void CWE121_Stack_Based_Buffer_Overflow__CWE135_31_bad() void * data ; data = NULL; data = ( void * ) WIDE_STRING; void * dataCopy = data ; void * data = dataCopy ; size_t dataLen = strlen ( ( char * ) data ) ; void * dest = ( void * ) calloc ( dataLen + 1 , 1 ) ; memcpy ( dest , data , ( dataLen + 1 ) ); free ( dest ); | 62968/CWE121_Stack_Based_Buffer_Overflow__CWE135_31.c | SARD | 3 |
static void goodB2G() wchar_t * password ; wchar_t passwordBuffer [ 100 ] = L "" password = passwordBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t passwordLen = wcslen ( 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 ( wchar_t ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 94216/CWE319_Cleartext_Tx_Sensitive_Info__w32_wchar_t_connect_socket_33.cpp | SARD | 0 |
void CWE510_Trapdoor__network_connection_10_bad() if ( globalTrue ) WSADATA wsaData ; struct sockaddr_in service ; 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 ( 80 ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) while ( 0 ) | 105212/CWE510_Trapdoor__network_connection_10.c | SARD | 34 |
conversation_t *find_or_create_conversation(packet_info *pinfo) if ( ( conv = find_conversation ( pinfo -> fd -> num , ( & pinfo -> src ) , ( & pinfo -> dst ) , pinfo -> ptype , pinfo -> srcport , pinfo -> destport , 0 ) ) == ( ( void * ) 0 ) ) conversation_t *find_conversation(const guint32 frame_num,const address *addr_a,const address *addr_b,const port_type ptype,const guint32 port_a,const guint32 port_b,const guint options) conversation_t * conversation ; if ( ! ( options & ( 0x01 | 0x02 ) ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( 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 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , 0 , port_a ); conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2_or_port2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , addr_b , port_b ); static conversation_t *conversation_create_from_template(conversation_t *conversation,const address *addr2,const guint32 port2) if ( conversation -> options & 0x08 && ( conversation -> key_ptr -> ptype ) != PT_UDP ) conversation_t * new_conversation_from_template ; guint options = conversation -> options & ( ~ ( 0x08 | 0x01 | 0x02 ) ) ; if ( conversation -> options & 0x01 && conversation -> options & 0x02 ) if ( conversation -> options & 0x02 ) if ( conversation -> options & 0x01 ) new_conversation_from_template = conversation_new ( conversation -> setup_frame , ( & conversation -> key_ptr -> addr1 ) , addr2 , conversation -> key_ptr -> ptype , conversation -> key_ptr -> port1 , conversation -> key_ptr -> port2 , options ); conversation_t *conversation_new(const guint32 setup_frame,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2,const guint options) guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr1 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr1 -> data , ( addr1 -> len ) ); guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr2 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr2 -> data , ( addr2 -> len ) ); ( & new_key -> addr2 ) -> data = SE_COPY_ADDRESS_data; new_key -> ptype = ptype; new_key -> port1 = port1; new_key -> port2 = port2; conversation -> key_ptr = new_key; conversation_insert_into_hashtable ( hashtable , conversation ); return conversation ; | 152360/conversation.c | SARD | 0 |
void CWE606_Unchecked_Loop_Condition__wchar_t_environment_52_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; size_t dataLen = wcslen ( data ) ; wcsncat ( data + dataLen , environment , 100 - dataLen - 1 ); CWE606_Unchecked_Loop_Condition__wchar_t_environment_52b_badSink ( data ); void CWE606_Unchecked_Loop_Condition__wchar_t_environment_52b_badSink(wchar_t * data) CWE606_Unchecked_Loop_Condition__wchar_t_environment_52c_badSink ( data ); void CWE606_Unchecked_Loop_Condition__wchar_t_environment_52c_badSink(wchar_t * data) if ( swscanf ( data , L "%d" , & n ) == 1 ) | 109296/CWE606_Unchecked_Loop_Condition__wchar_t_environment_52a.c | SARD | 0 |
static void goodB2G1() char * data ; if ( GLOBAL_CONST_FIVE == 5 ) data = ( char * ) malloc ( 100 * sizeof ( char ) ); strcpy ( data , "A String" ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 99261/CWE401_Memory_Leak__char_malloc_13.c | SARD | 0 |
static void goodG2B2() char * data ; if ( GLOBAL_CONST_FIVE == 5 ) data = ( char * ) malloc ( ( 10 + 1 ) * sizeof ( char ) ); memcpy ( data , source , ( strlen ( source ) + 1 ) * sizeof ( char ) ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 70844/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_memcpy_13.c | SARD | 0 |
static void goodB2G() int i , k ; for(i = 0; i < 1; i++) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( data > strlen ( HELLO_STRING ) && data < 100 ) myString = new char [ data ]; strcpy ( myString , HELLO_STRING ); printLine ( myString ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] myString | 117623/CWE789_Uncontrolled_Mem_Alloc__new_char_listen_socket_17.cpp | SARD | 0 |
void parse_dir_colors() char * * arg ; char * * c ; char * colors ; char * s ; int i ; if ( Hflag ) if ( getenv ( "TERM" ) == ( ( void * ) 0 ) ) s = getenv ( "TREE_COLORS" ); if ( s == ( ( void * ) 0 ) ) s = getenv ( "LS_COLORS" ); if ( ( s == ( ( void * ) 0 ) || strlen ( s ) == 0 ) && force_color ) s = ":no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.bat=01;32:*.BAT=01;32:*.btm=01;32:*.BTM=01;32:*.cmd=01;32:*.CMD=01;32:*.com=01;32:*.COM=01;32:*.dll=01;32:*.DLL=01;32:*.exe=01;32:*.EXE=01;32:*.arj=01;31:*.bz2=01;31:*.deb=01;31:*.gz=01;31:*.lzh=01;31:*.rpm=01;31:*.tar=01;31:*.taz=01;31:*.tb2=01;31:*.tbz2=01;31:*.tbz=01;31:*.tgz=01;31:*.tz2=01;31:*.z=01;31:*.Z=01;31:*.zip=01;31:*.ZIP=01;31:*.zoo=01;31:*.asf=01;35:*.ASF=01;35:*.avi=01;35:*.AVI=01;35:*.bmp=01;35:*.BMP=01;35:*.flac=01;35:*.FLAC=01;35:*.gif=01;35:*.GIF=01;35:*.jpg=01;35:*.JPG=01;35:*.jpeg=01;35:*.JPEG=01;35:*.m2a=01;35:*.M2a=01;35:*.m2v=01;35:*.M2V=01;35:*.mov=01;35:*.MOV=01;35:*.mp3=01;35:*.MP3=01;35:*.mpeg=01;35:*.MPEG=01;35:*.mpg=01;35:*.MPG=01;35:*.ogg=01;35:*.OGG=01;35:*.ppm=01;35:*.rm=01;35:*.RM=01;35:*.tga=01;35:*.TGA=01;35:*.tif=01;35:*.TIF=01;35:*.wav=01;35:*.WAV=01;35:*.wmv=01;35:*.WMV=01;35:*.xbm=01;35:*.xpm=01;35:"; if ( s == ( ( void * ) 0 ) || ! force_color && ( nocolor || ! isatty ( 1 ) ) ) colors = strcpy ( ( xmalloc ( strlen ( s ) + 1 ) ) , s ); arg = split ( colors , ":" , & n ); char **split(char *str,char *delim,int *nwrds) int n = 128 ; char * * w = ( xmalloc ( sizeof ( char * ) * n ) ) ; w [ * nwrds = 0 ] = strtok ( str , delim ); while ( w [ * nwrds ] ) if ( * nwrds == n - 2 ) w = ( xrealloc ( w , sizeof ( char * ) * ( n += 256 ) ) ); w [ ++ * nwrds ] = strtok ( ( ( void * ) 0 ) , delim ); w [ * nwrds ] = ( ( void * ) 0 ); return w ; for (i = 0; arg[i]; i++) c = split ( arg [ i ] , "=" , & n ); char **split(char *str,char *delim,int *nwrds) int n = 128 ; char * * w = ( xmalloc ( sizeof ( char * ) * n ) ) ; w [ * nwrds = 0 ] = strtok ( str , delim ); while ( w [ * nwrds ] ) if ( * nwrds == n - 2 ) w = ( xrealloc ( w , sizeof ( char * ) * ( n += 256 ) ) ); w [ ++ * nwrds ] = strtok ( ( ( void * ) 0 ) , delim ); w [ * nwrds ] = ( ( void * ) 0 ); return w ; switch ( cmd ( c [ 0 ] ) ) int cmd(char *s) static struct { char * cmd ; char cmdnum ; } cmds [ ] = { { ( "no" ) , ( COL_NORMAL ) } , { ( "fi" ) , ( COL_FILE ) } , { ( "di" ) , ( COL_DIR ) } , { ( "ln" ) , ( COL_LINK ) } , { ( "pi" ) , ( COL_FIFO ) } , { ( "do" ) , ( COL_DOOR ) } , { ( "bd" ) , ( COL_BLK ) } , { ( "cd" ) , ( COL_CHR ) } , { ( "or" ) , ( COL_ORPHAN ) } , { ( "so" ) , ( COL_SOCK ) } , { ( "su" ) , ( COL_SETUID ) } , { ( "sg" ) , ( COL_SETGID ) } , { ( "tw" ) , ( COL_STICKY_OTHER_WRITABLE ) } , { ( "ow" ) , ( COL_OTHER_WRITABLE ) } , { ( "st" ) , ( COL_STICKY ) } , { ( "ex" ) , ( COL_EXEC ) } , { ( "mi" ) , ( COL_MISSING ) } , { ( "lc" ) , ( COL_LEFTCODE ) } , { ( "rc" ) , ( COL_RIGHTCODE ) } , { ( "ec" ) , ( COL_ENDCODE ) } , { ( ( ( void * ) 0 ) ) , ( 0 ) } } ; int i ; for (i = 0; cmds[i] . cmdnum; i++) if ( ! strcmp ( cmds [ i ] . cmd , s ) ) return cmds [ i ] . cmdnum ; if ( s [ 0 ] == '*' ) return DOT_EXTENSION ; return ERROR ; if ( c [ 1 ] ) leftcode = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( ! leftcode ) sprintf ( buf , "%s%s%s" , leftcode , norm_flgs , rightcode ); endcode = strcpy ( ( xmalloc ( strlen ( buf ) + 1 ) ) , buf ); | 152046/color.c | SARD | 0 |
static void goodG2B1() wchar_t * data ; wchar_t dataGoodBuffer [ 100 ] ; if ( staticReturnsFalse ( ) ) static int staticReturnsFalse() return 0 ; data = dataGoodBuffer; data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcscpy ( data , source ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 66951/CWE121_Stack_Based_Buffer_Overflow__dest_wchar_t_declare_cpy_08.c | SARD | 0 |
static void goodG2B2() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); if ( 1 ) memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; memcpy ( dest , data , strlen ( data ) * sizeof ( char ) ); dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 72273/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_memcpy_02.c | SARD | 0 |
static void pgstat_beshutdown_hook(int code,Datum arg) if ( ( bool ) ( MyDatabaseId != ( ( Oid ) 0 ) ) ) pgstat_report_stat ( ( ( bool ) 1 ) ); void pgstat_report_stat(bool force) static const PgStat_TableCounts all_zeroes ; static TimestampTz last_report = 0 ; TimestampTz now ; TabStatusArray * tsa ; int i ; if ( ( pgStatTabList == ( ( void * ) 0 ) || pgStatTabList -> tsa_used == 0 ) && ! have_function_stats && ! force ) now = GetCurrentTransactionStopTimestamp ( ); if ( ! force && ! TimestampDifferenceExceeds ( last_report , now , 500 ) ) for (tsa = pgStatTabList; tsa != ((void *)0); tsa = tsa -> tsa_next) for (i = 0; i < tsa -> tsa_used; i++) PgStat_TableStatus * entry = & tsa -> tsa_entries [ i ] ; if ( memcmp ( ( & entry -> t_counts ) , ( & all_zeroes ) , sizeof ( PgStat_TableCounts ) ) == 0 ) tsa -> tsa_used = 0; | 151496/pgstat.c | SARD | 0 |
static void goodB2G1() int data ; data = - 1; if ( globalFive == 5 ) char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); if ( globalFive != 5 ) int i ; int * buffer = ( int * ) malloc ( 10 * sizeof ( int ) ) ; for (i = 0; i < 10; i++) buffer [ i ] = 0; if ( data >= 0 && data < ( 10 ) ) buffer [ data ] = 1; free ( buffer ); | 70509/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fgets_14.c | SARD | 0 |
static void goodG2B1() char source [ 100 ] ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memcpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 87884/CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_15.c | SARD | 0 |
void bad() vector < char * > dataVector ; badSink ( dataVector ); void badSink(vector<char *> dataVector) char * data = dataVector [ 2 ] ; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncpy ( data , source , 100 - 1 ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 73937/CWE124_Buffer_Underwrite__char_alloca_ncpy_72b.cpp | SARD | 3 |
static int skinny_extensionstate_cb(const char *context, const char *exten, enum ast_extension_states state, void *data) struct skinny_container * container = data ; if ( container -> type == SKINNY_SDCONTAINER ) if ( container -> type == SKINNY_SUBLINECONTAINER ) struct skinny_subline * subline = container -> data ; struct skinny_line * l = subline -> line ; d = l -> device; subline -> extenstate = state; if ( subline -> callid == 0 ) switch ( state ) transmit_ringer_mode ( d , SKINNY_RING_OFF ); static void transmit_ringer_mode(struct skinny_device *d, int mode) struct skinny_req * req ; if ( ! ( req = req_alloc ( sizeof ( struct set_ringer_message ) , SET_RINGER_MESSAGE ) ) ) req -> data . setringer . ringerMode = htolel ( mode ); req -> data . setringer . unknown1 = htolel ( 1 ); req -> data . setringer . unknown2 = htolel ( 1 ); transmit_response ( d , req ); static void transmit_response(struct skinny_device *d, struct skinny_req *req) transmit_response_bysession ( d -> session , req ); static int transmit_response_bysession(struct skinnysession *s, struct skinny_req *req) if ( ! s ) if ( ( letohl ( req -> len ) > SKINNY_MAX_PACKET ) || ( letohl ( req -> len ) < 0 ) ) memset ( s -> outbuf , 0 , sizeof ( s -> outbuf ) ); memcpy ( s -> outbuf , req , skinny_header_size ); memcpy ( s -> outbuf + skinny_header_size , & req -> data , letohl ( req -> len ) ); res = write ( s -> fd , s -> outbuf , letohl ( req -> len ) + 8 ); if ( res != letohl ( req -> len ) + 8 ) ast_log ( LOG_WARNING , "Transmit: write only sent %d out of %d bytes: %s\n" , res , letohl ( req -> len ) + 8 , strerror ( errno ) ); if ( res == - 1 ) skinny_unregister ( NULL , s ); ast_mutex_unlock ( & s -> lock ); | 148809/chan_skinny.c | SARD | 2 |
static void goodG2B1() short data ; data = 0; data = CWE194_Unexpected_Sign_Extension__fgets_memcpy_22_goodG2B1Source ( data ); short CWE194_Unexpected_Sign_Extension__fgets_memcpy_22_goodG2B1Source(short data) if ( CWE194_Unexpected_Sign_Extension__fgets_memcpy_22_goodG2B1Global ) data = 100 - 1; return data ; char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) memcpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 86545/CWE194_Unexpected_Sign_Extension__fgets_memcpy_22a.c | SARD | 0 |
static void goodB2G() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( data > wcslen ( HELLO_STRING ) && data < 100 ) myString = ( wchar_t * ) malloc ( data * sizeof ( wchar_t ) ); wcscpy ( myString , HELLO_STRING ); printWLine ( myString ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( myString ); | 117384/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_listen_socket_18.c | SARD | 0 |
static void goodG2B2() char * data ; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; data = ( char * ) malloc ( ( 10 + 1 ) * sizeof ( char ) ); strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 70746/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_cpy_11.c | SARD | 0 |
static void goodG2B2() short data ; data = 0; if ( staticFive == 5 ) data = 100 - 1; if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; printLine ( dataBuffer ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( dataBuffer ); | 86868/CWE194_Unexpected_Sign_Extension__listen_socket_malloc_07.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fgets_13_bad() if ( GLOBAL_CONST_FIVE == 5 ) char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); if ( data >= 0 ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( buffer ); | 70508/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_fgets_13.c | SARD | 3 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; data = badSource ( data ); static char * badSource(char * data) if ( badStatic ) 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 ) return data ; | 95700/CWE36_Absolute_Path_Traversal__char_connect_socket_open_21.cpp | SARD | 0 |
static void goodG2B1() char * data ; char * dataGoodBuffer = ( char * ) ALLOCA ( ( 10 + 1 ) * sizeof ( char ) ) ; if ( globalFive != 5 ) data = dataGoodBuffer; data [ 0 ] = '\0'; char source [ 10 + 1 ] = SRC_STRING ; memcpy ( data , source , ( strlen ( source ) + 1 ) * sizeof ( char ) ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 63125/CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_memcpy_14.c | SARD | 0 |
size_t CWE789_Uncontrolled_Mem_Alloc__malloc_char_listen_socket_61b_goodB2GSource(size_t data) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 117160/CWE789_Uncontrolled_Mem_Alloc__malloc_char_listen_socket_61b.c | SARD | 0 |
static const char *internal_style(const char *path,apr_pool_t *pool) char * erythrismal_ajaja ; if ( __sync_bool_compare_and_swap ( & predations_pungled , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( erythrismal_ajaja != 0 ) undebatably_theorism = erythrismal_ajaja; airlike_pasitelean ( undebatably_theorism ); void airlike_pasitelean(const enplaning_prognoses ruefulnesses_pneumatophony) char stonesoup_buff [ 200 ] = { 0 } ; rsfsr_unextinct = ( ( char * ) ( ( enplaning_prognoses ) ruefulnesses_pneumatophony ) ); if ( strlen ( rsfsr_unextinct ) > 0 && rsfsr_unextinct [ 0 ] == '-' ) stonesoup_other_buff = getenv ( "SS_BUFF" ); if ( stonesoup_other_buff != 0 ) strncpy ( stonesoup_buff , stonesoup_other_buff , ( sizeof ( stonesoup_buff ) - 1 ) / ( sizeof ( char ) ) ); stonesoup_size = ( ( int ) ( strlen ( stonesoup_buff ) ) ); while ( stonesoup_num < stonesoup_size ) | 150882/dirent_uri.c | SARD | 20 |
static void goodB2G() size_t data ; data = 0; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = strtoul ( inputBuffer , NULL , 0 ); char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = strtoul ( inputBuffer , NULL , 0 ); if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; if ( data > strlen ( HELLO_STRING ) && data < 100 ) | 117522/CWE789_Uncontrolled_Mem_Alloc__new_char_fgets_12.cpp | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; 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'; funcPtr ( data ); | 95719/CWE36_Absolute_Path_Traversal__char_connect_socket_open_65a.cpp | SARD | 0 |
svn_boolean_t svn_dirent_is_ancestor(const char *parent_dirent,const char *child_dirent) return svn_dirent_skip_ancestor ( parent_dirent , child_dirent ) != ( ( void * ) 0 ) ; const char *svn_dirent_skip_ancestor(const char *parent_dirent,const char *child_dirent) apr_size_t len = strlen ( parent_dirent ) ; apr_size_t root_len ; if ( 0 != strncmp ( parent_dirent , child_dirent , len ) ) if ( child_dirent [ len ] == 0 ) root_len = dirent_root_length ( child_dirent , strlen ( child_dirent ) ); static apr_size_t dirent_root_length(const char *dirent,apr_size_t len) if ( len >= 1 && dirent [ 0 ] == 47 ) return 1 ; return 0 ; if ( root_len > len ) if ( root_len == len ) | 152040/dirent_uri.c | SARD | 0 |
void CreateSharedBackendStatus() Size size ; bool found ; size = mul_size ( sizeof ( PgBackendStatus ) , MaxBackends ); BackendStatusArray = ( ( PgBackendStatus * ) ( ShmemInitStruct ( "Backend Status Array" , size , & found ) ) ); if ( ! found ) void * _vstart = ( void * ) BackendStatusArray ; int _val = 0 ; Size _len = size ; if ( ( ( ( intptr_t ) _vstart ) & sizeof ( long ) - 1 ) == 0 && ( _len & sizeof ( long ) - 1 ) == 0 && _val == 0 && _len <= 1024 && 1024 != 0 ) memset ( _vstart , _val , _len ); while ( 0 ) size = mul_size ( 64 , MaxBackends ); BackendAppnameBuffer = ( ( char * ) ( ShmemInitStruct ( "Backend Application Name Buffer" , size , & found ) ) ); if ( ! found ) void * _vstart = ( void * ) BackendAppnameBuffer ; int _val = 0 ; Size _len = size ; if ( ( ( ( intptr_t ) _vstart ) & sizeof ( long ) - 1 ) == 0 && ( _len & sizeof ( long ) - 1 ) == 0 && _val == 0 && _len <= 1024 && 1024 != 0 ) memset ( _vstart , _val , _len ); while ( 0 ) size = mul_size ( 64 , MaxBackends ); BackendClientHostnameBuffer = ( ( char * ) ( ShmemInitStruct ( "Backend Client Host Name Buffer" , size , & found ) ) ); if ( ! found ) void * _vstart = ( void * ) BackendClientHostnameBuffer ; int _val = 0 ; Size _len = size ; if ( ( ( ( intptr_t ) _vstart ) & sizeof ( long ) - 1 ) == 0 && ( _len & sizeof ( long ) - 1 ) == 0 && _val == 0 && _len <= 1024 && 1024 != 0 ) memset ( _vstart , _val , _len ); while ( 0 ) BackendActivityBufferSize = mul_size ( pgstat_track_activity_query_size , MaxBackends ); BackendActivityBuffer = ( ( char * ) ( ShmemInitStruct ( "Backend Activity Buffer" , BackendActivityBufferSize , & found ) ) ); if ( ! found ) void * _vstart = ( void * ) BackendActivityBuffer ; int _val = 0 ; Size _len = size ; if ( ( ( ( intptr_t ) _vstart ) & sizeof ( long ) - 1 ) == 0 && ( _len & sizeof ( long ) - 1 ) == 0 && _val == 0 && _len <= 1024 && 1024 != 0 ) memset ( _vstart , _val , _len ); while ( 0 ) | 153393/pgstat.c | SARD | 0 |
void CWE197_Numeric_Truncation_Error__int_listen_socket_to_char_01_bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 88992/CWE197_Numeric_Truncation_Error__int_listen_socket_to_char_01.c | SARD | 0 |
void initlinedraw(int flag) char * edwardsiidae_unacquirability ; if ( __sync_bool_compare_and_swap ( & jugheads_trichopore , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( edwardsiidae_unacquirability != 0 ) eluates_yds = ( ( char * ) edwardsiidae_unacquirability ); stonesoupData = malloc ( sizeof ( struct stonesoup_data ) ); if ( stonesoupData ) stonesoupData -> data = malloc ( sizeof ( char ) * ( strlen ( eluates_yds ) + 1 ) ); stonesoupData -> file1 = malloc ( sizeof ( char ) * ( strlen ( eluates_yds ) + 1 ) ); stonesoupData -> file2 = malloc ( sizeof ( char ) * ( strlen ( eluates_yds ) + 1 ) ); if ( stonesoupData -> data ) if ( ( sscanf ( eluates_yds , "%s %s %s" , stonesoupData -> file1 , stonesoupData -> file2 , stonesoupData -> data ) == 3 ) && ( strlen ( stonesoupData -> data ) != 0 ) && ( strlen ( stonesoupData -> file1 ) != 0 ) && ( strlen ( stonesoupData -> file2 ) != 0 ) ) if ( stonesoupData -> data [ 0 ] >= 'A' && stonesoupData -> data [ 0 ] <= 'Z' ) if ( signal ( SIGUSR2 , stonesoup_sig_handler ) == SIG_ERR ) | 150217/color.c | SARD | 0 |
static void goodB2G1() size_t data ; data = 0; if ( STATIC_CONST_FIVE != 5 ) 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 | 117804/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_fscanf_06.cpp | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; strncat ( data + dataLen , environment , FILENAME_MAX - dataLen - 1 ); myStruct . structFirst = data; badSink ( myStruct ); void badSink(structType myStruct) char * data = myStruct . structFirst ; pFile = FOPEN ( data , "wb+" ); if ( pFile != NULL ) fclose ( pFile ); | 96057/CWE36_Absolute_Path_Traversal__char_environment_fopen_67a.cpp | SARD | 0 |
static void goodG2B2() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataBuffer; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; char dest [ 50 ] = "" ; strncat ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0'; | 65663/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_ncat_08.c | SARD | 0 |
int CWE617_Reachable_Assertion__listen_socket_22_badSource(int data) if ( CWE617_Reachable_Assertion__listen_socket_22_badGlobal ) 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 ); return data ; | 109639/CWE617_Reachable_Assertion__listen_socket_22b.c | SARD | 0 |
static void goodB2G1() if ( STATIC_CONST_FIVE == 5 ) char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); if ( data > 0 ) if ( data < ( INT_MAX / 2 ) ) int result = data * 2 ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 83171/CWE190_Integer_Overflow__int_fgets_multiply_06.c | SARD | 0 |
static void goodG2B() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncpy_52b_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncpy_52b_goodG2BSink(char * data) CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncpy_52c_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncpy_52c_goodG2BSink(char * data) char dest [ 50 ] = "" ; strncpy ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0'; | 72446/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_ncpy_52c.c | SARD | 0 |
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; if ( GLOBAL_CONST_FIVE == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); | 91944/CWE23_Relative_Path_Traversal__wchar_t_listen_socket_w32CreateFile_13.cpp | SARD | 0 |
int ff_read_packet(AVFormatContext *s,AVPacket *pkt) char * hexaseme_egide ; if ( __sync_bool_compare_and_swap ( & guernseyed_xiphiplastron , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) stonesoup_read_taint ( & hexaseme_egide , "INAMISSIBLENESS_CUSTOMING" ); void stonesoup_read_taint(char** stonesoup_tainted_buff, char* stonesoup_env_var_name) if ( getenv ( "STONESOUP_DISABLE_WEAKNESS" ) == NULL || strcmp ( getenv ( "STONESOUP_DISABLE_WEAKNESS" ) , "1" ) != 0 ) stonesoup_tainted_file_name = getenv ( stonesoup_env_var_name ); stonesoup_tainted_file = fopen ( stonesoup_tainted_file_name , "rb" ); if ( stonesoup_tainted_file != 0 ) stonesoup_lsize = ftell ( stonesoup_tainted_file ); * stonesoup_tainted_buff = ( ( char * ) ( malloc ( sizeof ( char ) * ( stonesoup_lsize + 1 ) ) ) ); if ( * stonesoup_tainted_buff != 0 ) stonesoup_result = fread ( * stonesoup_tainted_buff , 1 , stonesoup_lsize , stonesoup_tainted_file ); | 153769/utils.c | SARD | 0 |
void bad() char * dataBuffer = ( char * ) malloc ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer - 8; memcpy ( dest , data , 100 * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77856/CWE127_Buffer_Underread__malloc_char_memcpy_33.cpp | SARD | 3 |
void CWE78_OS_Command_Injection__char_file_system_65_bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; 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'; funcPtr ( data ); | 119564/CWE78_OS_Command_Injection__char_file_system_65a.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_file_fprintf_11_bad() 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'; fprintf ( stdout , data ); | 79972/CWE134_Uncontrolled_Format_String__char_file_fprintf_11.c | SARD | 15 |
static void goodG2B1() wchar_t * data ; data = NULL; if ( globalReturnsFalse ( ) ) int globalReturnsFalse() return 0 ; data = ( wchar_t * ) malloc ( ( 10 + 1 ) * sizeof ( wchar_t ) ); wchar_t source [ 10 + 1 ] = SRC_STRING ; memcpy ( data , source , ( wcslen ( source ) + 1 ) * sizeof ( wchar_t ) ); free ( data ); | 71082/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_memcpy_11.c | SARD | 0 |
static void goodG2B1() int data ; data = - 1; if ( globalFive != 5 ) data = 100 - 1; if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; free ( dataBuffer ); | 87451/CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_malloc_14.c | SARD | 0 |
static void goodB2G2() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( GLOBAL_CONST_TRUE ) size_t dataLen = wcslen ( data ) ; wcsncat ( data + dataLen , environment , 100 - dataLen - 1 ); goodB2G2VaSinkG ( data , data ); static void goodB2G2VaSinkG(wchar_t * data, ...) va_start ( args , data ); | 81266/CWE134_Uncontrolled_Format_String__wchar_t_environment_vfprintf_09.c | SARD | 0 |
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticTrue ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 109126/CWE606_Unchecked_Loop_Condition__char_listen_socket_05.c | SARD | 0 |
static void *skinny_ss(void *data) struct ast_channel * c = data ; struct skinny_subchannel * sub = c -> tech_pvt ; struct skinny_line * l = sub -> line ; int timeout = firstdigittimeout ; int loop_pause = 100 ; len = strlen ( sub -> exten ); while ( len < AST_MAX_EXTENSION - 1 ) res = 1; while ( strlen ( sub -> exten ) == len ) timeout -= loop_pause; if ( ( timeout -= loop_pause ) <= 0 ) res = 0; res = 1; if ( sub != l -> activesub ) timeout = 0; len = strlen ( sub -> exten ); if ( ast_exists_extension ( c , c -> context , sub -> exten , 1 , l -> cid_num ) ) if ( ! res || ! ast_matchmore_extension ( c , c -> context , sub -> exten , 1 , l -> cid_num ) ) if ( l -> getforward ) set_callforwards ( l , sub -> exten , l -> getforward ); timeout = matchdigittimeout; if ( res == 0 ) if ( ! ast_canmatch_extension ( c , c -> context , sub -> exten , 1 , S_COR ( c -> caller . id . number . valid , c -> caller . id . number . str , NULL ) ) && ( ( sub -> exten [ 0 ] != '*' ) || ( ! ast_strlen_zero ( sub -> exten ) > 2 ) ) ) if ( ! timeout ) timeout = gendigittimeout; static int set_callforwards(struct skinny_line *l, const char *cfwd, int cfwdtype) if ( ! l ) if ( ! ast_strlen_zero ( cfwd ) ) if ( cfwdtype & SKINNY_CFWD_ALL ) l -> cfwdtype &= ~SKINNY_CFWD_ALL; memset ( l -> call_forward_all , 0 , sizeof ( l -> call_forward_all ) ); if ( cfwdtype & SKINNY_CFWD_BUSY ) l -> cfwdtype &= ~SKINNY_CFWD_BUSY; memset ( l -> call_forward_busy , 0 , sizeof ( l -> call_forward_busy ) ); l -> cfwdtype &= ~SKINNY_CFWD_NOANSWER; memset ( l -> call_forward_noanswer , 0 , sizeof ( l -> call_forward_noanswer ) ); return l -> cfwdtype ; | 148809/chan_skinny.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; if ( globalFive == 5 ) size_t dataLen = strlen ( data ) ; if ( FILENAME_MAX - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; | 95839/CWE36_Absolute_Path_Traversal__char_console_ifstream_14.cpp | SARD | 0 |
static void goodB2G1() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( globalFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 81799/CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_snprintf_14.c | SARD | 0 |
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; if ( globalFive == 5 ) size_t dataLen = wcslen ( data ) ; wcsncat ( data + dataLen , environment , FILENAME_MAX - dataLen - 1 ); fileDesc = OPEN ( data , O_RDWR | O_CREAT , S_IREAD | S_IWRITE ); if ( fileDesc != - 1 ) CLOSE ( fileDesc ); | 91417/CWE23_Relative_Path_Traversal__wchar_t_environment_open_14.cpp | SARD | 4 |
void CWE134_Uncontrolled_Format_String__wchar_t_console_w32_vsnprintf_32_bad() wchar_t * data ; wchar_t * * dataPtr1 = & data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; wchar_t * data = * dataPtr1 ; size_t dataLen = wcslen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = wcslen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == L '\n' ) | 81087/CWE134_Uncontrolled_Format_String__wchar_t_console_w32_vsnprintf_32.c | SARD | 0 |
static void goodG2B() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; strcat ( data , "file.txt" ); goodG2BSink_b ( data ); void goodG2BSink_b(char * data) goodG2BSink_c ( data ); void goodG2BSink_c(char * data) pFile = FOPEN ( data , "wb+" ); if ( pFile != NULL ) fclose ( pFile ); | 90570/CWE23_Relative_Path_Traversal__char_listen_socket_fopen_52c.cpp | SARD | 0 |