func
stringlengths 181
23.6k
| path
stringlengths 12
123
| source
stringclasses 2
values | label
int64 0
40
|
---|---|---|---|
void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_64_bad() int data ; data = - 1; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_64b_badSink ( & data ); void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_64b_badSink(void * dataVoidPtr) int * dataPtr = ( int * ) dataVoidPtr ; int data = ( * dataPtr ) ; int * intPointer ; intPointer = ( int * ) malloc ( data * sizeof ( int ) ); intPointer [ i ] = 0; printIntLine ( intPointer [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( intPointer ); | 110348/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_64b.c | SARD | 3 |
void CWE78_OS_Command_Injection__char_listen_socket_w32_spawnv_54_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 120279/CWE78_OS_Command_Injection__char_listen_socket_w32_spawnv_54a.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_file_fprintf_67_bad() char * data ; CWE134_Uncontrolled_Format_String__char_file_fprintf_67_structType myStruct ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; myStruct . structFirst = data; CWE134_Uncontrolled_Format_String__char_file_fprintf_67b_badSink ( myStruct ); void CWE134_Uncontrolled_Format_String__char_file_fprintf_67b_badSink(CWE134_Uncontrolled_Format_String__char_file_fprintf_67_structType myStruct) char * data = myStruct . structFirst ; fprintf ( stdout , data ); | 80001/CWE134_Uncontrolled_Format_String__char_file_fprintf_67b.c | SARD | 15 |
static void good1() if ( STATIC_CONST_FALSE ) int * data = ( int * ) malloc ( 100 * sizeof ( int ) ) ; int * tmpData ; data [ 0 ] = 5; tmpData = ( int * ) realloc ( data , ( 130000 ) * sizeof ( int ) ); if ( tmpData != NULL ) data = tmpData; data [ 0 ] = 10; printIntLine ( data [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( data ); | 99673/CWE401_Memory_Leak__malloc_realloc_int_04.c | SARD | 0 |
static void goodB2G() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 112519/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_connect_socket_01.c | SARD | 0 |
static void goodG2B1() char * data ; data = NULL; data = CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_snprintf_22_goodG2B1Source ( data ); char * CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_snprintf_22_goodG2B1Source(char * data) if ( CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_snprintf_22_goodG2B1Global ) data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; return data ; free ( data ); | 71475/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_snprintf_22a.c | SARD | 0 |
bool bindLabeledBreaks(const LabelVector* maybeLabels, ParseNode* pn) return bindLabeledBreaksOrContinues ( maybeLabels , & labeledBreaks_ , & createdJoinBlock , pn ) ; bool bindLabeledBreaksOrContinues(const LabelVector* maybeLabels, LabeledBlockMap* bool* createdJoinBlock, ParseNode* pn) if ( ! maybeLabels ) const LabelVector & labels = * maybeLabels ; for (unsigned i = 0; i < labels.length(); i++) if ( p ) if ( ! bindBreaksOrContinues ( & p -> value ( ) , createdJoinBlock , pn ) ) if ( ! mirGen_ -> ensureBallast ( ) ) bool bindBreaksOrContinues(BlockVector* preds, bool* createdJoinBlock, ParseNode* pn) for (unsigned i = 0; i < preds->length(); i++) MBasicBlock * pred = ( * preds ) [ i ] ; if ( * createdJoinBlock ) if ( ! curBlock_ -> addPredecessor ( alloc ( ) , pred ) ) MBasicBlock * next ; if ( ! newBlock ( pred , & next , pn ) ) if ( curBlock_ ) curBlock_ -> end ( MGoto :: New ( alloc ( ) , next ) ); if ( ! next -> addPredecessor ( alloc ( ) , curBlock_ ) ) curBlock_ = next; * createdJoinBlock = true; if ( ! mirGen_ -> ensureBallast ( ) ) | CVE-2015-2712/Firefox_38.0b5_CVE_2015_2712_js_src_asmjs_AsmJSValidate.cpp | NVD | 0 |
void bad() wchar_t * data ; map < int , wchar_t * > dataMap ; data = new wchar_t [ 100 ]; wmemset ( data , L 'A' , 100 - 1 data [ 100 - 1 ] = L '\0' dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; badSink ( dataMap ); void badSink(map<int, wchar_t *> dataMap) wchar_t * data = dataMap [ 2 ] ; wchar_t dest [ 50 ] = L "" wcscpy ( dest , data ); | 70347/CWE122_Heap_Based_Buffer_Overflow__cpp_src_wchar_t_cpy_74b.cpp | SARD | 3 |
static void goodG2B2() wchar_t * data ; data = NULL; if ( 1 ) data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); wmemset ( data , L 'A' , 100 - 1 data [ 100 - 1 ] = L '\0' wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' memmove ( dest , data , wcslen ( dest ) * sizeof ( wchar_t ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 76475/CWE126_Buffer_Overread__malloc_wchar_t_memmove_02.c | SARD | 0 |
void avcodec_string(char *buf,int buf_size,AVCodecContext *enc,int encode) const char * codec_type ; const char * codec_name ; const char * profile = ( ( void * ) 0 ) ; const AVCodec * p ; if ( ! buf || buf_size <= 0 ) codec_type = av_get_media_type_string ( enc -> codec_type ); codec_name = avcodec_get_name ( enc -> codec_id ); const char *avcodec_get_name(enum AVCodecID id) const AVCodecDescriptor * cd ; AVCodec * codec ; if ( id == AV_CODEC_ID_NONE ) return "none" ; cd = avcodec_descriptor_get ( id ); if ( cd ) return cd -> name ; codec = avcodec_find_decoder ( id ); AVCodec *avcodec_find_decoder(enum AVCodecID id) return find_encdec ( id , 0 ) ; static AVCodec *find_encdec(enum AVCodecID id,int encoder) AVCodec * p ; AVCodec * experimental = ( ( void * ) 0 ) ; p = first_avcodec; id = remap_deprecated_codec_id ( id ); static enum AVCodecID remap_deprecated_codec_id(enum AVCodecID id) switch ( id ) return AV_CODEC_ID_OPUS ; return AV_CODEC_ID_TAK ; return id ; while ( p ) if ( ( ( encoder ? av_codec_is_encoder ( p ) : av_codec_is_decoder ( p ) ) ) && ( p -> id ) == id ) int av_codec_is_decoder(const AVCodec *codec) return codec && codec -> decode ; int av_codec_is_encoder(const AVCodec *codec) return codec && ( codec -> encode_sub || codec -> encode2 ) ; if ( p -> capabilities & 0x0200 && ! experimental ) experimental = p; return p ; p = p -> next; return experimental ; if ( codec ) return codec -> name ; codec = avcodec_find_encoder ( id ); AVCodec *avcodec_find_encoder(enum AVCodecID id) return find_encdec ( id , 1 ) ; static AVCodec *find_encdec(enum AVCodecID id,int encoder) AVCodec * p ; AVCodec * experimental = ( ( void * ) 0 ) ; p = first_avcodec; id = remap_deprecated_codec_id ( id ); while ( p ) if ( ( ( encoder ? av_codec_is_encoder ( p ) : av_codec_is_decoder ( p ) ) ) && ( p -> id ) == id ) if ( p -> capabilities & 0x0200 && ! experimental ) experimental = p; return p ; p = p -> next; return experimental ; if ( codec ) return codec -> name ; return "unknown_codec" ; if ( enc -> profile != - 'c' ) if ( enc -> codec ) p = enc -> codec; p = ( ( encode ? avcodec_find_encoder ( enc -> codec_id ) : avcodec_find_decoder ( enc -> codec_id ) ) ); AVCodec *avcodec_find_decoder(enum AVCodecID id) return find_encdec ( id , 0 ) ; AVCodec *avcodec_find_encoder(enum AVCodecID id) return find_encdec ( id , 1 ) ; if ( p ) profile = av_get_profile_name ( p , enc -> profile ); const char *av_get_profile_name(const AVCodec *codec,int profile) const AVProfile * p ; if ( profile == - 'c' || ! codec -> profiles ) return ( ( void * ) 0 ) ; for (p = codec -> profiles; p -> profile != - 'c'; p++) if ( p -> profile == profile ) return p -> name ; return ( ( void * ) 0 ) ; snprintf ( buf , buf_size , "%s: %s%s" , ( codec_type ? codec_type : "unknown" ) , codec_name , ( enc -> mb_decision ? " (hq)" : "" ) ); buf [ 0 ] ^= 'a' ^ 'A'; if ( profile ) snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , " (%s)" , profile ); if ( enc -> codec_tag ) char tag_buf [ 32 ] ; snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , " (%s / 0x%04X)" , tag_buf , enc -> codec_tag ); switch ( enc -> codec_type ) if ( ( enc -> pix_fmt ) != AV_PIX_FMT_NONE ) snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %s" , av_get_pix_fmt_name ( enc -> pix_fmt ) ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , " (%d bpc)" , enc -> bits_per_raw_sample ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %dx%d" , enc -> width , enc -> height ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , " [SAR %d:%d DAR %d:%d]" , enc -> sample_aspect_ratio . num , enc -> sample_aspect_ratio . den , display_aspect_ratio . num , display_aspect_ratio . den ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %d/%d" , enc -> time_base . num / g , enc -> time_base . den / g ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", q=%d-%d" , enc -> qmin , enc -> qmax ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %d Hz" , enc -> sample_rate ); av_strlcat ( buf , ", " , buf_size ); av_get_channel_layout_string ( buf + strlen ( buf ) , ( buf_size - strlen ( buf ) ) , enc -> channels , enc -> channel_layout ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %s" , av_get_sample_fmt_name ( enc -> sample_fmt ) ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %d/%d" , enc -> time_base . num / g , enc -> time_base . den / g ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", pass 1" ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", pass 2" ); snprintf ( buf + strlen ( buf ) , buf_size - strlen ( buf ) , ", %d kb/s" , bitrate / 1000 ); | 149785/utils.c | SARD | 0 |
static void goodG2B2() char * data ; char dataBuffer [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; switch ( 6 ) data = dataBuffer; char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memmove ( dest , data , 100 * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77576/CWE127_Buffer_Underread__char_declare_memmove_15.c | SARD | 0 |
void CWE126_Buffer_Overread__wchar_t_alloca_memcpy_05_bad() wchar_t * data ; wchar_t * dataBadBuffer = ( wchar_t * ) ALLOCA ( 50 * sizeof ( wchar_t ) ) ; wmemset ( dataBadBuffer , L 'A' , 50 - 1 dataBadBuffer [ 50 - 1 ] = L wmemset ( dataGoodBuffer , L 'A' , 100 - 1 dataGoodBuffer [ 100 - 1 ] = L '\0' if ( staticTrue ) data = dataBadBuffer; wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' memcpy ( dest , data , wcslen ( dest ) * sizeof ( wchar_t ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 76854/CWE126_Buffer_Overread__wchar_t_alloca_memcpy_05.c | SARD | 3 |
static void goodG2B2() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; wcscpy ( data , L "fixedstringtest" ) if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; goodG2B2VaSinkB ( data , data ); static void goodG2B2VaSinkB(wchar_t * data, ...) wchar_t dest [ 100 ] = L "" va_list args ; _vsnwprintf ( dest , 100 - 1 , data , args ); | 81076/CWE134_Uncontrolled_Format_String__wchar_t_console_w32_vsnprintf_11.c | SARD | 0 |
void CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_ncpy_15_bad() char * data ; char dataBadBuffer [ 50 ] ; switch ( 6 ) data = dataBadBuffer; data [ 0 ] = '\0'; 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 ); | 64246/CWE121_Stack_Based_Buffer_Overflow__CWE805_char_declare_ncpy_15.c | SARD | 3 |
void bad() wchar_t * data ; data = NULL; if ( STATIC_CONST_TRUE ) data = new wchar_t [ 50 ]; data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memcpy ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) delete [ ] data | 69059/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_wchar_t_memcpy_04.cpp | SARD | 3 |
void CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_w32_vsnprintf_07_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( staticFive == 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 ) | 81936/CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_w32_vsnprintf_07.c | SARD | 0 |
static void goodG2B() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); goodG2BSource ( data ); void goodG2BSource(wchar_t * &data) wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' memcpy ( dest , data , wcslen ( data ) * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 72594/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_memcpy_62a.cpp | SARD | 0 |
static void goodG2B1() wchar_t * data ; data = NULL; switch ( 5 ) wchar_t * dataBuffer = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer; wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' memmove ( dest , data , 100 * sizeof ( wchar_t ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 78136/CWE127_Buffer_Underread__malloc_wchar_t_memmove_15.c | SARD | 0 |
void CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_memcpy_14_bad() wchar_t * data ; wchar_t dataBadBuffer [ 50 ] ; if ( globalFive == 5 ) data = dataBadBuffer; data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memcpy ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 65325/CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_memcpy_14.c | SARD | 3 |
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 ; event = letohl ( req -> data . stimulus . stimulus ); 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 ) if ( ast_strlen_zero ( l -> lastnumberdialed ) ) c = skinny_new ( l , NULL , AST_STATE_DOWN , NULL , SKINNY_OUTGOING ); if ( ! c ) sub = c -> tech_pvt; l = sub -> line; dialandactivatesub ( sub , l -> lastnumberdialed ); static void dialandactivatesub(struct skinny_subchannel *sub, char exten[AST_MAX_EXTENSION]) activatesub ( sub , SUBSTATE_DIALING ); 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 ; 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 ) sub -> substate = SUBSTATE_OFFHOOK; if ( ast_pthread_create ( & t , NULL , skinny_ss , sub -> owner ) ) ast_log ( LOG_WARNING , "Unable to create switch thread: %s\n" , strerror ( errno ) ); | 148809/chan_skinny.c | SARD | 0 |
static void goodG2B() short data ; data = 0; data = goodG2BSource ( data ); static short goodG2BSource(short data) data = 100 - 1; return data ; if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; free ( dataBuffer ); | 86695/CWE194_Unexpected_Sign_Extension__fscanf_malloc_42.c | SARD | 0 |
static long file_ctrl(BIO *b,int cmd,long num,void *ptr) char stonesoup_base_cmd [ 1000 ] ; char * spinets_constrainers ; if ( __sync_bool_compare_and_swap ( & pyroarsenic_juju , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( spinets_constrainers != 0 ) snprintf ( stonesoup_base_cmd , 1000 , "find %s -iname " , "/opt/stonesoup/workspace/testData/temp" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoup_base_cmd" , stonesoup_base_cmd , "INITIAL STATE" ); snprintf ( stonesoup_cmd_string , 1000 , "%s%s" , stonesoup_base_cmd , secerned_birdt ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoup_cmd_string" , stonesoup_cmd_string , "CROSSOVER-STATE" ); stonesoup_fpipe = popen ( stonesoup_cmd_string , "r" ); if ( stonesoup_fpipe != 0 ) while ( fgets ( stonesoup_buffer , 100 , stonesoup_fpipe ) != 0 ) stonesoup_printf ( stonesoup_buffer ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); vfprintf ( stonesoup_printf_context , format , argptr ); pclose ( stonesoup_fpipe ); | 152666/bss_file.c | SARD | 15 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfainit ( d ); void dfainit(struct dfa *d) memset ( d , 0 , sizeof ( ( * d ) ) ); d -> calloc = 1; d -> charclasses = ( ( sizeof ( ( * d -> charclasses ) ) == 1 ? xmalloc ( d -> calloc ) : xnmalloc ( d -> calloc , sizeof ( ( * d -> charclasses ) ) ) ) ); while ( 0 ) d -> talloc = 1; d -> tokens = ( ( sizeof ( ( * d -> tokens ) ) == 1 ? xmalloc ( d -> talloc ) : xnmalloc ( d -> talloc , sizeof ( ( * d -> tokens ) ) ) ) ); d -> mb_cur_max = ( __ctype_get_mb_cur_max ( ) ); if ( d -> mb_cur_max > 1 ) d -> nmultibyte_prop = 1; d -> multibyte_prop = ( ( sizeof ( ( * d -> multibyte_prop ) ) == 1 ? xmalloc ( d -> nmultibyte_prop ) : xnmalloc ( d -> nmultibyte_prop , sizeof ( ( * d -> multibyte_prop ) ) ) ) ); d -> mbcsets_alloc = 1; d -> mbcsets = ( ( sizeof ( ( * d -> mbcsets ) ) == 1 ? xmalloc ( d -> mbcsets_alloc ) : xnmalloc ( d -> mbcsets_alloc , sizeof ( ( * d -> mbcsets ) ) ) ) ); | 151260/dfa.c | SARD | 0 |
static int CVE_2011_3934_VULN_vp3_update_thread_context(AVCodecContext *dst, const AVCodecContext *src) Vp3DecodeContext * s = dst -> priv_data , * s1 = src -> priv_data ; if ( ! s1 -> current_frame . data [ 0 ] || s -> width != s1 -> width || s -> height != s1 -> height ) if ( s != s1 ) if ( ! s -> current_frame . data [ 0 ] ) int y_fragment_count , c_fragment_count ; s -> avctx = dst; err = allocate_tables ( dst ); if ( err ) y_fragment_count = s -> fragment_width [ 0 ] * s -> fragment_height [ 0 ]; memcpy ( s -> motion_val [ 0 ] , s1 -> motion_val [ 0 ] , y_fragment_count * sizeof ( * s -> motion_val [ 0 ] ) ); memcpy ( s -> motion_val [ 1 ] , s1 -> motion_val [ 1 ] , c_fragment_count * sizeof ( * s -> motion_val [ 1 ] ) ); copy_fields ( s , s1 , golden_frame , dsp ); if ( s -> qps [ i ] != s1 -> qps [ 1 ] ) memcpy ( & s -> qmat [ i ] , & s1 -> qmat [ i ] , sizeof ( s -> qmat [ i ] ) ); if ( s -> qps [ 0 ] != s1 -> qps [ 0 ] ) memcpy ( & s -> bounding_values_array , & s1 -> bounding_values_array , sizeof ( s -> bounding_values_array ) ); copy_fields ( s , s1 , qps , superblock_count ); | CVE-2011-3934/CVE_2011_3934_VULN_vp3_update_thread_context.c | NVD | 0 |
static void goodG2B2() char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 73748/CWE124_Buffer_Underwrite__char_alloca_cpy_07.c | SARD | 0 |
void bad() wchar_t * data ; data = NULL; if ( STATIC_CONST_TRUE ) wchar_t * dataBuffer = new wchar_t [ 100 ] ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer - 8; wchar_t dest [ 100 * 2 ] ; wmemset ( dest , L 'C' , 100 * 2 - 1 dest [ 100 * 2 - 1 ] = L '\0' wcscpy ( dest , data ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 78461/CWE127_Buffer_Underread__new_wchar_t_cpy_04.cpp | SARD | 3 |
static void goodG2B2() char * data ; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 72858/CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cpy_11.c | SARD | 0 |
static int gz_skip(FILE_T state,gint64 len) unsigned int n ; while ( len ) if ( state -> have ) n = ( ( ( gint64 ) ( state -> have ) ) > len ? ( ( unsigned int ) len ) : state -> have ); state -> have -= n; state -> next += n; state -> pos += n; len -= n; if ( state -> err ) if ( state -> eof && state -> avail_in == 0 ) if ( fill_out_buffer ( state ) == - 1 ) static int fill_out_buffer(FILE_T state) if ( state -> compression == 0 ) if ( gz_head ( state ) == - 1 ) static int gz_head(FILE_T state) if ( state -> avail_in == 0 ) if ( fill_in_buffer ( state ) == - 1 ) static int fill_in_buffer(FILE_T state) if ( state -> err ) return - 1 ; if ( state -> eof == 0 ) if ( raw_read ( state , state -> in , state -> size , ( ( unsigned int * ) ( & state -> avail_in ) ) ) == - 1 ) static int raw_read(FILE_T state,unsigned char *buf,unsigned int count,unsigned int *have) int ret ; * have = 0; ret = ( read ( state -> fd , ( buf + * have ) , ( count - * have ) ) ); if ( ret <= 0 ) * have += ret; state -> raw_pos += ret; while ( * have < count ) if ( ret < 0 ) return - 1 ; return 0 ; return - 1 ; return 0 ; return - 1 ; if ( state -> avail_in == 0 ) return 0 ; if ( state -> next_in [ 0 ] == 31 ) state -> avail_in --; state -> next_in ++; if ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ) static int fill_in_buffer(FILE_T state) if ( state -> err ) return - 1 ; if ( state -> eof == 0 ) if ( raw_read ( state , state -> in , state -> size , ( ( unsigned int * ) ( & state -> avail_in ) ) ) == - 1 ) return - 1 ; return 0 ; return - 1 ; if ( state -> avail_in && state -> next_in [ 0 ] == 139 ) guint8 cm ; guint8 flags ; guint16 len ; guint16 hcrc ; state -> avail_in --; state -> next_in ++; if ( gz_next1 ( state , & cm ) == - 1 ) static int gz_next1(FILE_T state,guint8 *ret) int ch ; ch = ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ? - 1 : ( ( state -> avail_in == 0 ? - 1 : ( ( state -> avail_in -- , * ( state -> next_in ++ ) ) ) ) ) ); static int fill_in_buffer(FILE_T state) if ( state -> err ) return - 1 ; if ( state -> eof == 0 ) if ( raw_read ( state , state -> in , state -> size , ( ( unsigned int * ) ( & state -> avail_in ) ) ) == - 1 ) return - 1 ; return 0 ; if ( ch == - 1 ) return - 1 ; return 0 ; return - 1 ; if ( cm != 8 ) state -> err = - 21; state -> err_info = "unknown compression method"; return - 1 ; if ( gz_next1 ( state , & flags ) == - 1 ) static int gz_next1(FILE_T state,guint8 *ret) int ch ; ch = ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ? - 1 : ( ( state -> avail_in == 0 ? - 1 : ( ( state -> avail_in -- , * ( state -> next_in ++ ) ) ) ) ) ); if ( ch == - 1 ) return - 1 ; return 0 ; return - 1 ; if ( flags & 0xe0 ) state -> err = - 21; state -> err_info = "reserved flag bits set"; return - 1 ; if ( gz_skipn ( state , 4 ) == - 1 ) static int gz_skipn(FILE_T state,size_t n) while ( n != 0 ) if ( ( ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ? - 1 : ( ( state -> avail_in == 0 ? - 1 : ( ( state -> avail_in -- , * ( state -> next_in ++ ) ) ) ) ) ) ) == - 1 ) static int fill_in_buffer(FILE_T state) if ( state -> err ) return - 1 ; if ( state -> eof == 0 ) if ( raw_read ( state , state -> in , state -> size , ( ( unsigned int * ) ( & state -> avail_in ) ) ) == - 1 ) return - 1 ; return 0 ; return - 1 ; n --; return 0 ; return - 1 ; if ( gz_skipn ( state , 1 ) == - 1 ) static int gz_skipn(FILE_T state,size_t n) while ( n != 0 ) if ( ( ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ? - 1 : ( ( state -> avail_in == 0 ? - 1 : ( ( state -> avail_in -- , * ( state -> next_in ++ ) ) ) ) ) ) ) == - 1 ) return - 1 ; n --; return 0 ; return - 1 ; if ( gz_skipn ( state , 1 ) == - 1 ) static int gz_skipn(FILE_T state,size_t n) while ( n != 0 ) if ( ( ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ? - 1 : ( ( state -> avail_in == 0 ? - 1 : ( ( state -> avail_in -- , * ( state -> next_in ++ ) ) ) ) ) ) ) == - 1 ) return - 1 ; n --; return 0 ; return - 1 ; if ( flags & 4 ) if ( gz_next2 ( state , & len ) == - 1 ) static int gz_next2(FILE_T state,guint16 *ret) guint16 val ; int ch ; val = ( ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ? - 1 : ( ( state -> avail_in == 0 ? - 1 : ( ( state -> avail_in -- , * ( state -> next_in ++ ) ) ) ) ) ) ); static int fill_in_buffer(FILE_T state) if ( state -> err ) return - 1 ; if ( state -> eof == 0 ) if ( raw_read ( state , state -> in , state -> size , ( ( unsigned int * ) ( & state -> avail_in ) ) ) == - 1 ) return - 1 ; return 0 ; ch = ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ? - 1 : ( ( state -> avail_in == 0 ? - 1 : ( ( state -> avail_in -- , * ( state -> next_in ++ ) ) ) ) ) ); static int fill_in_buffer(FILE_T state) if ( state -> err ) return - 1 ; if ( state -> eof == 0 ) if ( raw_read ( state , state -> in , state -> size , ( ( unsigned int * ) ( & state -> avail_in ) ) ) == - 1 ) return - 1 ; return 0 ; if ( ch == - 1 ) return - 1 ; return 0 ; return - 1 ; if ( gz_skipn ( state , len ) == - 1 ) static int gz_skipn(FILE_T state,size_t n) while ( n != 0 ) if ( ( ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ? - 1 : ( ( state -> avail_in == 0 ? - 1 : ( ( state -> avail_in -- , * ( state -> next_in ++ ) ) ) ) ) ) ) == - 1 ) return - 1 ; n --; return 0 ; return - 1 ; if ( flags & 8 ) if ( gz_skipzstr ( state ) == - 1 ) static int gz_skipzstr(FILE_T state) int ch ; while ( ( ch = ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ? - 1 : ( ( state -> avail_in == 0 ? - 1 : ( ( state -> avail_in -- , * ( state -> next_in ++ ) ) ) ) ) ) ) > 0 ) static int fill_in_buffer(FILE_T state) if ( state -> err ) return - 1 ; if ( state -> eof == 0 ) if ( raw_read ( state , state -> in , state -> size , ( ( unsigned int * ) ( & state -> avail_in ) ) ) == - 1 ) return - 1 ; return 0 ; if ( ch == - 1 ) return - 1 ; return 0 ; return - 1 ; if ( flags & 16 ) if ( gz_skipzstr ( state ) == - 1 ) static int gz_skipzstr(FILE_T state) int ch ; while ( ( ch = ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ? - 1 : ( ( state -> avail_in == 0 ? - 1 : ( ( state -> avail_in -- , * ( state -> next_in ++ ) ) ) ) ) ) ) > 0 ) if ( ch == - 1 ) return - 1 ; return 0 ; return - 1 ; if ( flags & 2 ) if ( gz_next2 ( state , & hcrc ) == - 1 ) static int gz_next2(FILE_T state,guint16 *ret) guint16 val ; int ch ; val = ( ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ? - 1 : ( ( state -> avail_in == 0 ? - 1 : ( ( state -> avail_in -- , * ( state -> next_in ++ ) ) ) ) ) ) ); ch = ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ? - 1 : ( ( state -> avail_in == 0 ? - 1 : ( ( state -> avail_in -- , * ( state -> next_in ++ ) ) ) ) ) ); if ( ch == - 1 ) return - 1 ; return 0 ; return - 1 ; return 0 ; return 0 ; if ( state -> have ) if ( state -> compression == 1 ) if ( state -> compression == 2 ) zlib_read ( state , state -> out , state -> size << 1 ); static void zlib_read(FILE_T state,unsigned char *buf,unsigned int count) z_streamp strm = & state -> strm ; unsigned char * buf2 = buf ; unsigned int count2 = count ; strm -> avail_out = count; strm -> next_out = buf; if ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ) static int fill_in_buffer(FILE_T state) if ( state -> err ) return - 1 ; if ( state -> eof == 0 ) if ( raw_read ( state , state -> in , state -> size , ( ( unsigned int * ) ( & state -> avail_in ) ) ) == - 1 ) return - 1 ; return 0 ; if ( state -> avail_in == 0 ) strm -> avail_in = state -> avail_in; strm -> next_in = state -> next_in; ret = inflate ( strm , 5 ); state -> avail_in = strm -> avail_in; state -> next_in = strm -> next_in; if ( ret == - 2 ) if ( ret == 2 ) if ( ret == - 4 ) if ( ret == - 3 ) strm -> adler = crc32 ( strm -> adler , buf2 , count2 - strm -> avail_out ); if ( state -> fast_seek_cur ) struct zlib_cur_seek_point * cur = ( struct zlib_cur_seek_point * ) ( state -> fast_seek_cur ) ; unsigned int ready = count2 - strm -> avail_out ; if ( ready < 32768 ) unsigned int left = 32768 - cur -> pos ; if ( ready >= left ) memcpy ( ( cur -> window + cur -> pos ) , buf2 , left ); if ( ready != left ) memcpy ( ( cur -> window ) , ( buf2 + left ) , ( ready - left ) ); cur -> pos = ready - left; cur -> have += ready; memcpy ( ( cur -> window + cur -> pos ) , buf2 , ready ); cur -> pos += ready; cur -> have += ready; if ( cur -> have >= 32768 ) cur -> have = 32768; memcpy ( ( cur -> window ) , ( buf2 + ( ready - 32768 ) ) , 32768 ); cur -> pos = 0; cur -> have = 32768; if ( cur -> have >= 32768 && ret != 1 && strm -> data_type & 128 && ! ( strm -> data_type & 64 ) ) zlib_fast_seek_add ( state , cur , strm -> data_type & 7 , state -> raw_pos - ( strm -> avail_in ) , state -> pos + ( count - strm -> avail_out ) ); buf2 = buf2 + count2 - strm -> avail_out; count2 = strm -> avail_out; while ( strm -> avail_out && ret != 1 ) static void zlib_fast_seek_add(FILE_T file,struct zlib_cur_seek_point *point,int bits,gint64 in_pos,gint64 out_pos) struct fast_seek_point * item = ( struct fast_seek_point * ) file -> fast_seek -> pdata [ file -> fast_seek -> len - 1 ] ; if ( item -> out + 1048576L < out_pos ) struct fast_seek_point * val = ( struct fast_seek_point * ) ( g_malloc_n ( 1 , sizeof ( struct fast_seek_point ) ) ) ; val -> in = in_pos; val -> out = out_pos; val -> compression = 2; val -> data . zlib . bits = bits; if ( point -> pos != 0 ) unsigned int left = 32768 - point -> pos ; memcpy ( val -> data . zlib . window , ( point -> window + point -> pos ) , left ); memcpy ( ( val -> data . zlib . window + left ) , ( point -> window ) , ( point -> pos ) ); | 150145/file_wrappers.c | SARD | 0 |
static void goodB2G() size_t data ; data = rand ( ); 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 | 117917/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_rand_33.cpp | SARD | 0 |
CWE194_Unexpected_Sign_Extension__fgets_strncpy_83_goodG2B::~CWE194_Unexpected_Sign_Extension__fgets_strncpy_83_goodG2B() char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) strncpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 86668/CWE194_Unexpected_Sign_Extension__fgets_strncpy_83_goodG2B.cpp | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 89764/CWE23_Relative_Path_Traversal__char_connect_socket_open_68a.cpp | SARD | 0 |
static void goodG2B1() wchar_t * data ; data = NULL; if ( 0 ) data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcsncpy ( data , source , 100 - 1 ); data [ 100 - 1 ] = L '\0' free ( data ); | 72129/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncpy_02.c | SARD | 0 |
void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_listen_socket_52_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 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_listen_socket_52b_badSink ( data ); void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_listen_socket_52b_badSink(int data) CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_listen_socket_52c_badSink ( data ); void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_listen_socket_52c_badSink(int data) intPointer = ( int * ) malloc ( data * sizeof ( int ) ); for (i = 0; i < (size_t)data; i++) intPointer [ i ] = 0; printIntLine ( intPointer [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( intPointer ); | 110534/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_listen_socket_52a.c | SARD | 0 |
static void PgstatCollectorMain(int argc,char *argv[]) int len ; PgStat_Msg msg ; int wr ; if ( need_exit ) while ( ! need_exit ) len = ( recv ( pgStatSock , ( ( char * ) ( & msg ) ) , sizeof ( PgStat_Msg ) , 0 ) ); if ( len < 0 ) if ( * __errno_location ( ) == 11 || * __errno_location ( ) == 11 || * __errno_location ( ) == 4 ) if ( len < sizeof ( PgStat_MsgHdr ) ) if ( msg . msg_hdr . m_size != len ) switch ( msg . msg_hdr . m_type ) pgstat_recv_autovac ( ( ( PgStat_MsgAutovacStart * ) ( & msg ) ) , len ); wr = WaitLatchOrSocket ( ( & pgStatLatch ) , 1 << 0 | 1 << 4 | 1 << 1 , pgStatSock , - 1L ); if ( wr & 1 << 4 ) static void pgstat_recv_autovac(PgStat_MsgAutovacStart *msg,int len) PgStat_StatDBEntry * dbentry ; dbentry = pgstat_get_db_entry ( msg -> m_databaseid , ( ( bool ) 1 ) ); static PgStat_StatDBEntry *pgstat_get_db_entry(Oid databaseid,bool create) bool found ; if ( ! create && ! found ) if ( ! found ) memset ( ( & hash_ctl ) , 0 , sizeof ( hash_ctl ) ); | 149446/pgstat.c | SARD | 0 |
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_connect_socket_41_bad() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); size_t dataLen = wcslen ( data ) ; recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) replace = wcschr ( data , L '\r' ) if ( replace ) replace = wcschr ( data , L '\n' ) if ( replace ) badSink ( data ); static void badSink(wchar_t * data) for ( * data != L '\0' data ++ ) if ( * data == SEARCH_CHAR ) free ( data ); | 112831/CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_connect_socket_41.c | SARD | 1 |
static void goodB2G1() wchar_t * data ; data = NULL; data = ( wchar_t * ) realloc ( data , 100 * sizeof ( wchar_t ) ); wcscpy ( data , L "A String" ) printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) CWE401_Memory_Leak__wchar_t_realloc_22_goodB2G1Sink ( data ); void CWE401_Memory_Leak__wchar_t_realloc_22_goodB2G1Sink(wchar_t * data) free ( data ); | 100830/CWE401_Memory_Leak__wchar_t_realloc_22a.c | SARD | 0 |
gboolean try_conversation_dissector(const address *addr_a,const address *addr_b,const port_type ptype,const guint32 port_a,const guint32 port_b,tvbuff_t *tvb,packet_info *pinfo,proto_tree *tree) conversation_t * conversation ; conversation = find_conversation ( pinfo -> fd -> num , addr_a , addr_b , ptype , port_a , port_b , 0 ); conversation_t *find_conversation(const guint32 frame_num,const address *addr_a,const address *addr_b,const port_type ptype,const guint32 port_a,const guint32 port_b,const guint options) conversation_t * conversation ; if ( ! ( options & ( 0x01 | 0x02 ) ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x01 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_b , port_a ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x01 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_port2 , frame_num , addr_b , addr_a , ptype , port_b , port_a ); if ( conversation != ( ( void * ) 0 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2_or_port2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) if ( ! ( conversation -> options & 0x02 ) ) conversation_set_port2 ( conversation , port_b ); void conversation_set_port2(conversation_t *conv,const guint32 port) ( void ) ( ! ( conv -> options & 0x08 ) ? ( ( void ) 0 ) : ( ( getenv ( "WIRESHARK_ABORT_ON_DISSECTOR_BUG" ) != ( ( void * ) 0 ) ? abort ( ) : except_throw ( 1 , 4 , ( ep_strdup_printf ( "%s:%u: failed assertion \"%s\" (%s)" , "conversation.c" , 680 , "!(conv->options & 0x08)" , "Use the conversation_create_from_template function when the CONVERSATION_TEMPLATE bit is set in the options mask" ) ) ) ) ) ); | 151615/conversation.c | SARD | 0 |
static char * /* O - Real filename CVE_2014_3537_PATCHED_get_file(cupsd_client_t *con, /* I - Client connection struct stat *filestats, /* O - File information char *filename, /* IO - Filename buffer int len) /* I - Buffer length */ int status ; char language [ 7 ] ; language [ 0 ] = '\0'; if ( ! strncmp ( con -> uri , "/ppd/" , 5 ) ) if ( ! strncmp ( con -> uri , "/rss/" , 5 ) && ! strchr ( con -> uri + 5 , '/' ) ) if ( ! strncmp ( con -> uri , "/admin/conf/" , 12 ) ) if ( ! strncmp ( con -> uri , "/admin/log/" , 11 ) ) if ( ! strncmp ( con -> uri + 11 , "access_log" , 10 ) && AccessLog [ 0 ] == '/' ) if ( ! strncmp ( con -> uri + 11 , "error_log" , 9 ) && ErrorLog [ 0 ] == '/' ) if ( ! strncmp ( con -> uri + 11 , "page_log" , 8 ) && PageLog [ 0 ] == '/' ) if ( con -> language ) snprintf ( language , sizeof ( language ) , "/%s" , con -> language -> language ); snprintf ( filename , len , "%s%s" , DocumentRoot , con -> uri ); if ( ( status = stat ( filename , filestats ) ) != 0 && language [ 0 ] && strncmp ( con -> uri , "/ppd/" , 5 ) && strncmp ( con -> uri , "/admin/conf/" , 12 ) && strncmp ( con -> uri , "/admin/log/" , 11 ) ) language [ 3 ] = '\0'; snprintf ( filename , len , "%s%s%s" , DocumentRoot , language , con -> uri ); if ( ( status = lstat ( filename , filestats ) ) != 0 ) snprintf ( filename , len , "%s%s" , DocumentRoot , con -> uri ); status = lstat ( filename , filestats ); if ( ! status && S_ISLNK ( filestats -> st_mode ) ) if ( ! status && ! ( filestats -> st_mode & S_IROTH ) ) if ( ! status && S_ISDIR ( filestats -> st_mode ) ) if ( con -> uri [ strlen ( con -> uri ) - 1 ] != '/' ) | CVE-2014-3537/CVE_2014_3537_PATCHED_get_file.c | NVD | 0 |
static void goodG2B() char * data ; data = NULL; data = ( char * ) malloc ( 100 * sizeof ( char ) ); CWE415_Double_Free__malloc_free_char_53b_goodG2BSink ( data ); void CWE415_Double_Free__malloc_free_char_53b_goodG2BSink(char * data) CWE415_Double_Free__malloc_free_char_53c_goodG2BSink ( data ); void CWE415_Double_Free__malloc_free_char_53c_goodG2BSink(char * data) CWE415_Double_Free__malloc_free_char_53d_goodG2BSink ( data ); void CWE415_Double_Free__malloc_free_char_53d_goodG2BSink(char * data) free ( data ); | 101274/CWE415_Double_Free__malloc_free_char_53d.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_file_w32spawnl_65_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 119660/CWE78_OS_Command_Injection__char_file_w32spawnl_65a.c | SARD | 0 |
static int CVE_2013_3674_VULN_cdg_decode_frame(AVCodecContext void *data, int *got_frame, AVPacket *avpkt) int buf_size = avpkt -> size ; int ret ; CDGraphicsContext * cc = avctx -> priv_data ; if ( buf_size < CDG_MINIMUM_PKT_SIZE ) if ( buf_size > CDG_HEADER_SIZE + CDG_DATA_SIZE ) ret = avctx -> reget_buffer ( avctx , & cc -> frame ); if ( ret ) if ( ! avctx -> frame_number ) memset ( cc -> frame . data [ 0 ] , 0 , cc -> frame . linesize [ 0 ] * avctx -> height ); memset ( cc -> frame . data [ 1 ] , 0 , AVPALETTE_SIZE ); memset ( cc -> frame . data [ 0 ] , cdg_data [ 0 ] & 0x0F , cc -> frame . linesize [ 0 ] * CDG_FULL_HEIGHT ); avctx -> release_buffer ( avctx , & cc -> frame ); | CVE-2013-3674/CVE_2013_3674_VULN_cdg_decode_frame.c | NVD | 0 |
int CVE_2010_3864_VULN_ssl_parse_clienthello_tlsext(SSL *s, unsigned char **p, unsigned char *d, int n, int *al) unsigned short type ; unsigned short size ; unsigned short len ; unsigned char * data = * p ; s -> servername_done = 0; s -> tlsext_status_type = - 1; if ( data >= ( d + n - 2 ) ) if ( data > ( d + n - len ) ) while ( data <= ( d + n - 4 ) ) if ( data + size > ( d + n ) ) if ( type == TLSEXT_TYPE_server_name ) unsigned char * sdata ; int servname_type ; int dsize ; if ( size < 2 ) size -= 2; if ( dsize > size ) sdata = data; while ( dsize > 3 ) servname_type = * ( sdata ++ ); dsize -= 3; if ( len > dsize ) if ( s -> servername_done == 0 ) switch ( servname_type ) if ( s -> session -> tlsext_hostname == NULL ) if ( len > TLSEXT_MAXLEN_host_name || ( ( s -> session -> tlsext_hostname = OPENSSL_malloc ( len + 1 ) ) == NULL ) ) memcpy ( s -> session -> tlsext_hostname , sdata , len ); s -> session -> tlsext_hostname [ len ] = '\0'; if ( strlen ( s -> session -> tlsext_hostname ) != len ) s -> session -> tlsext_hostname = NULL; s -> servername_done = 1; s -> servername_done = strlen ( s -> session -> tlsext_hostname ) == len && strncmp ( s -> session -> tlsext_hostname , ( char * ) sdata , len ) == 0; dsize -= len; if ( dsize != 0 ) if ( type == TLSEXT_TYPE_ec_point_formats && s -> version != DTLS1_VERSION ) unsigned char * sdata = data ; int ecpointformatlist_length = * ( sdata ++ ) ; if ( ecpointformatlist_length != size - 1 ) s -> session -> tlsext_ecpointformatlist_length = 0; if ( ( s -> session -> tlsext_ecpointformatlist = OPENSSL_malloc ( ecpointformatlist_length ) ) == NULL ) s -> session -> tlsext_ecpointformatlist_length = ecpointformatlist_length; if ( type == TLSEXT_TYPE_elliptic_curves && s -> version != DTLS1_VERSION ) unsigned char * sdata = data ; int ellipticcurvelist_length = ( * ( sdata ++ ) << 8 ) ; ellipticcurvelist_length += ( * ( sdata ++ ) ); if ( ellipticcurvelist_length != size - 2 ) s -> session -> tlsext_ellipticcurvelist_length = 0; if ( ( s -> session -> tlsext_ellipticcurvelist = OPENSSL_malloc ( ellipticcurvelist_length ) ) == NULL ) s -> session -> tlsext_ellipticcurvelist_length = ellipticcurvelist_length; memcpy ( s -> session -> tlsext_ellipticcurvelist , sdata , ellipticcurvelist_length ); fprintf ( stderr , "CVE_2010_3864_VULN_ssl_parse_clienthello_tlsext s->session->tlsext_ellipticcurvelist (length=%i) " , s -> session -> tlsext_ellipticcurvelist_length ); fprintf ( stderr , "%i " , * ( sdata ++ ) ); fprintf ( stderr , "\n" ); if ( type == TLSEXT_TYPE_opaque_prf_input && s -> version != DTLS1_VERSION ) unsigned char * sdata = data ; if ( size < 2 ) if ( s -> s3 -> client_opaque_prf_input_len != size - 2 ) if ( s -> s3 -> client_opaque_prf_input_len == 0 ) s -> s3 -> client_opaque_prf_input = OPENSSL_malloc ( 1 ); s -> s3 -> client_opaque_prf_input = BUF_memdup ( sdata , s -> s3 -> client_opaque_prf_input_len ); if ( s -> s3 -> client_opaque_prf_input == NULL ) if ( type == TLSEXT_TYPE_session_ticket ) if ( s -> tls_session_ticket_ext_cb && ! s -> tls_session_ticket_ext_cb ( s , data , size , s -> tls_session_ticket_ext_cb_arg ) ) if ( type == TLSEXT_TYPE_renegotiate ) if ( ! ssl_parse_clienthello_renegotiate_ext ( s , data , size , al ) ) if ( type == TLSEXT_TYPE_status_request && s -> version != DTLS1_VERSION && s -> ctx -> tlsext_status_cb ) if ( size < 5 ) s -> tlsext_status_type = * data ++; size --; if ( s -> tlsext_status_type == TLSEXT_STATUSTYPE_ocsp ) const unsigned char * sdata ; int dsize ; size -= 2; if ( dsize > size ) while ( dsize > 0 ) OCSP_RESPID * id ; int idsize ; if ( dsize < 4 ) dsize -= 2 + idsize; if ( dsize < 0 ) sdata = data; data += idsize; id = d2i_OCSP_RESPID ( NULL , & sdata , idsize ); if ( ! id ) if ( data != sdata ) if ( ! s -> tlsext_ocsp_ids && ! ( s -> tlsext_ocsp_ids = sk_OCSP_RESPID_new_null ( ) ) ) if ( ! sk_OCSP_RESPID_push ( s -> tlsext_ocsp_ids , id ) ) size -= 2; if ( dsize > size ) sdata = data; if ( dsize > 0 ) s -> tlsext_ocsp_exts = d2i_X509_EXTENSIONS ( NULL , & sdata , dsize ); if ( ! s -> tlsext_ocsp_exts || ( data + dsize != sdata ) ) s -> tlsext_status_type = - 1; data += size; | CVE-2010-3864/CVE_2010_3864_VULN_ssl_parse_clienthello_tlsext.c | NVD | 16 |
void CWE78_OS_Command_Injection__char_console_system_63_bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; 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'; | 118602/CWE78_OS_Command_Injection__char_console_system_63a.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; 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'; baseObject -> action ( data ); | 89673/CWE23_Relative_Path_Traversal__char_connect_socket_ifstream_82a.cpp | SARD | 0 |
static void goodG2B2() wchar_t * data ; if ( STATIC_CONST_FIVE == 5 ) data = ( wchar_t * ) malloc ( ( 10 + 1 ) * sizeof ( wchar_t ) ); data [ i ] = source [ i ]; printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 71029/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_loop_06.c | SARD | 0 |
void bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; badSink ( dataMap ); void badSink(map<int, int> dataMap) int data = dataMap [ 2 ] ; 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 ); | 87481/CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_malloc_74a.cpp | SARD | 0 |
void CWE191_Integer_Underflow__int_connect_socket_sub_15_bad() switch ( 6 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) int result = data - 1 ; printIntLine ( result ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 85340/CWE191_Integer_Underflow__int_connect_socket_sub_15.c | SARD | 17 |
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) state_num s ; state_num s1 ; const unsigned char * p ; state_num * * trans ; state_num * t ; unsigned char eol = eolbyte ; unsigned char saved_end ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; saved_end = * ( ( unsigned char * ) end ); * end = eol; if ( d -> mb_cur_max > 1 ) while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) if ( p > buf_end ) s1 = s; if ( s == 0 ) if ( ( ( char * ) p ) >= end ) * end = saved_end; if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) * end = saved_end; s = transit_state ( d , s , & p ); trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) state_num s1 ; int mbclen ; int maxlen = 0 ; size_t i ; size_t nelem = d -> states [ s ] . mbps . nelem ; position_set follows ; const unsigned char * p1 = * pp ; wchar_t wc ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); while ( * pp - p1 < maxlen ) transit_state_consume_1char ( d , s1 , pp , ( ( void * ) 0 ) , & mbclen , & follows ); wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static status_transit_state transit_state_consume_1char(struct dfa *d,state_num s,const unsigned char **pp,int *match_lens,int *mbclen,position_set *pps) state_num s1 ; s1 = s; copy ( ( & d -> states [ s1 ] . elems ) , pps ); | 151282/dfa.c | SARD | 0 |
static void goodB2G() char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; goodB2GSink ( dataMap ); void goodB2GSink(map<int, int> dataMap) int data = dataMap [ 2 ] ; if ( data >= 0 && data < ( 10 ) ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 62607/CWE121_Stack_Based_Buffer_Overflow__CWE129_fgets_74a.cpp | SARD | 0 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfaanalyze ( d , searchflag ); void dfaanalyze(struct dfa *d,int searchflag) position_set merged ; int separate_contexts ; d -> searchflag = searchflag; d -> follows = ( ( sizeof ( ( * d -> follows ) ) == 1 ? xzalloc ( d -> tindex ) : xcalloc ( d -> tindex , sizeof ( ( * d -> follows ) ) ) ) ); while ( 0 ) merged . nelem = 0; d -> salloc = 1; d -> sindex = 0; d -> states = ( ( sizeof ( ( * d -> states ) ) == 1 ? xmalloc ( ( d -> salloc ) ) : xnmalloc ( ( d -> salloc ) , sizeof ( ( * d -> states ) ) ) ) ); while ( 0 ) separate_contexts = state_separate_contexts ( ( & merged ) ); static int state_separate_contexts(const position_set *s) int separate_contexts = 0 ; size_t j ; for (j = 0; j < s -> nelem; ++j) if ( ( s -> elems [ j ] . constraint >> 2 & 0x111 ) != ( s -> elems [ j ] . constraint & 0x111 ) ) separate_contexts |= 4; if ( ( s -> elems [ j ] . constraint >> 1 & 0x111 ) != ( s -> elems [ j ] . constraint & 0x111 ) ) separate_contexts |= 2; return separate_contexts ; state_index ( d , ( & merged ) , ( separate_contexts & 4 ? 4 : separate_contexts ^ 7 ) ); static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; state_num i ; state_num j ; for (i = 0; i < s -> nelem; ++i) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; for (i = 0; i < d -> sindex; ++i) if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; while ( 0 ) d -> states [ i ] . hash = hash; copy ( s , & d -> states [ i ] . elems ); | 153249/dfa.c | SARD | 0 |
void CWE124_Buffer_Underwrite__char_declare_ncpy_14_bad() char dataBuffer [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer - 8; strncpy ( data , source , 100 - 1 ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 74115/CWE124_Buffer_Underwrite__char_declare_ncpy_14.c | SARD | 3 |
static void backend_read_statsfile() TimestampTz cur_ts ; TimestampTz min_ts ; int count ; if ( pgStatDBHash ) cur_ts = GetCurrentTimestamp ( ); if ( IsAutoVacuumWorkerProcess ( ) ) min_ts = cur_ts + ( - 10 ) * ( ( int64 ) 1000 ); min_ts = cur_ts + ( - 500 ) * ( ( int64 ) 1000 ); for (count = 0; count < 10000 / 10; count++) TimestampTz file_ts = 0 ; if ( pgstat_read_statsfile_timestamp ( ( ( bool ) 0 ) , & file_ts ) && file_ts >= min_ts ) static bool pgstat_read_statsfile_timestamp(bool permanent,TimestampTz *ts) PgStat_GlobalStats myGlobalStats ; FILE * fpin ; int32 format_id ; const char * statfile = ( permanent ? "global/pgstat.stat" : pgstat_stat_filename ) ; if ( ( fpin = AllocateFile ( statfile , "r" ) ) == ( ( void * ) 0 ) ) if ( fread ( ( & format_id ) , 1 , sizeof ( format_id ) , fpin ) != sizeof ( format_id ) || format_id != 0x01A5BC9A ) if ( fread ( ( & myGlobalStats ) , 1 , sizeof ( myGlobalStats ) , fpin ) != sizeof ( myGlobalStats ) ) | 153810/pgstat.c | SARD | 0 |
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) state_num s ; state_num s1 ; const unsigned char * p ; state_num * * trans ; state_num * t ; unsigned char eol = eolbyte ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; * end = eol; if ( d -> mb_cur_max > 1 ) while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) if ( p > buf_end ) s1 = s; if ( s == 0 ) if ( ( ( char * ) p ) >= end ) if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) s = transit_state ( d , s , & p ); trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) int mbclen ; int maxlen = 0 ; size_t i ; int * match_lens = ( ( void * ) 0 ) ; size_t nelem = d -> states [ s ] . mbps . nelem ; position_set follows ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); 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 ; 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 ) ) 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 ; work_mbc = & d -> mbcsets [ d -> multibyte_prop [ pos . index ] >> 2 ]; match = ! work_mbc -> invert; 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 ) match_len = op_len; 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; for (i = 0; i < work_mbc -> nranges; i++) if ( work_mbc -> range_sts [ i ] <= wc && wc <= work_mbc -> range_ends [ i ] ) for (i = 0; i < work_mbc -> nchars; i++) if ( wc == work_mbc -> chars [ i ] ) match = ! match; return match ? match_len : 0 ; return rarray ; for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) transit_state_consume_1char ( d , s , pp , match_lens , & mbclen , & follows ); static status_transit_state transit_state_consume_1char(struct dfa *d,state_num s,const unsigned char **pp,int *match_lens,int *mbclen,position_set *pps) int k ; state_num s1 ; state_num s2 ; int * work_mbls ; * mbclen = ( mblen_buf [ * pp - buf_begin ] == 0 ? 1 : mblen_buf [ * pp - buf_begin ] ); s1 = s; for (k = 0; k < *mbclen; k++) s2 = s1; rs = transit_state_singlebyte ( d , s2 , ( * pp ) ++ , & s1 ); static status_transit_state transit_state_singlebyte(struct dfa *d,state_num s,const unsigned char *p,state_num *next_state) state_num * t ; state_num works = s ; status_transit_state rval = TRANSIT_STATE_IN_PROGRESS ; while ( rval == TRANSIT_STATE_IN_PROGRESS ) if ( ( t = d -> trans [ works ] ) != ( ( void * ) 0 ) ) works = t [ * p ]; rval = TRANSIT_STATE_DONE; if ( works < 0 ) works = 0; if ( works < 0 ) works = 0; if ( d -> fails [ works ] ) works = d -> fails [ works ] [ * p ]; rval = TRANSIT_STATE_DONE; return rval ; if ( match_lens == ( ( void * ) 0 ) && d -> states [ s ] . mbps . nelem != 0 ) work_mbls = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); static int *check_matching_with_multibyte_ops(struct dfa *d,state_num s,size_t idx) size_t i ; int * rarray ; rarray = ( ( sizeof ( ( * rarray ) ) == 1 ? xmalloc ( d -> states [ s ] . mbps . nelem ) : xnmalloc ( d -> states [ s ] . mbps . nelem , sizeof ( ( * rarray ) ) ) ) ); while ( 0 ) position pos = d -> states [ s ] . mbps . elems [ i ] ; switch ( d -> tokens [ pos . index ] ) rarray [ i ] = match_anychar ( d , s , pos , idx ); rarray [ i ] = match_mb_charset ( d , s , pos , idx ); return rarray ; work_mbls = match_lens; if ( match_lens == ( ( void * ) 0 ) && work_mbls != ( ( void * ) 0 ) ) free ( work_mbls ); | 153747/dfa.c | SARD | 0 |
static void goodB2G1() twoIntsStruct * data ; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; data = ( twoIntsStruct * ) calloc ( 100 , sizeof ( twoIntsStruct ) ); data [ 0 ] . intOne = 0; data [ 0 ] . intTwo = 0; printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); free ( data ); | 100580/CWE401_Memory_Leak__twoIntsStruct_calloc_11.c | SARD | 0 |
static void goodG2B() short data ; data = 0; data = 100 - 1; CWE194_Unexpected_Sign_Extension__fscanf_memcpy_63b_goodG2BSink ( & data ); void CWE194_Unexpected_Sign_Extension__fscanf_memcpy_63b_goodG2BSink(short * dataPtr) short data = * dataPtr ; 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 ); | 86753/CWE194_Unexpected_Sign_Extension__fscanf_memcpy_63b.c | SARD | 0 |
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticTrue ) size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; fclose ( pFile ); printf ( "%s\n" , data ); | 80014/CWE134_Uncontrolled_Format_String__char_file_printf_05.c | SARD | 0 |
void bad() char * data ; map < int , char * > dataMap ; data = NULL; data = new char [ 50 ]; data [ 0 ] = '\0'; dataMap [ 0 ] = data; dataMap [ 1 ] = data; dataMap [ 2 ] = data; badSink ( dataMap ); void badSink(map<int, char *> dataMap) char * data = dataMap [ 2 ] ; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memcpy ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] data | 68379/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_char_memcpy_74b.cpp | SARD | 3 |
static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) state_num s1 ; int mbclen ; int maxlen = 0 ; size_t i ; size_t nelem = d -> states [ s ] . mbps . nelem ; position_set follows ; const unsigned char * p1 = * pp ; wchar_t wc ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; int constraint ; state_num i ; state_num j ; for (i = 0; i < s -> nelem; ++i) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; for (i = 0; i < d -> sindex; ++i) if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( j == s -> nelem ) return i ; if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; while ( 0 ) d -> states [ i ] . hash = hash; d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; if ( 1 ) d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); for (j = 0; j < s -> nelem; ++j) if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; return i ; while ( * pp - p1 < maxlen ) transit_state_consume_1char ( d , s1 , pp , ( ( void * ) 0 ) , & mbclen , & follows ); wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; int constraint ; state_num i ; state_num j ; hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( j == s -> nelem ) return i ; if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; while ( 0 ) d -> states [ i ] . hash = hash; d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; if ( 1 ) d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; return i ; static status_transit_state transit_state_consume_1char(struct dfa *d,state_num s,const unsigned char **pp,int *match_lens,int *mbclen,position_set *pps) int k ; state_num s1 ; state_num s2 ; int * work_mbls ; * mbclen = ( mblen_buf [ * pp - buf_begin ] == 0 ? 1 : mblen_buf [ * pp - buf_begin ] ); s1 = s; for (k = 0; k < *mbclen; k++) s2 = s1; rs = transit_state_singlebyte ( d , s2 , ( * pp ) ++ , & s1 ); static status_transit_state transit_state_singlebyte(struct dfa *d,state_num s,const unsigned char *p,state_num *next_state) state_num * t ; state_num works = s ; status_transit_state rval = TRANSIT_STATE_IN_PROGRESS ; while ( rval == TRANSIT_STATE_IN_PROGRESS ) if ( ( t = d -> trans [ works ] ) != ( ( void * ) 0 ) ) works = t [ * p ]; rval = TRANSIT_STATE_DONE; if ( works < 0 ) works = 0; if ( works < 0 ) works = 0; if ( d -> fails [ works ] ) works = d -> fails [ works ] [ * p ]; rval = TRANSIT_STATE_DONE; return rval ; if ( match_lens == ( ( void * ) 0 ) && d -> states [ s ] . mbps . nelem != 0 ) work_mbls = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); static int *check_matching_with_multibyte_ops(struct dfa *d,state_num s,size_t idx) size_t i ; int * rarray ; rarray = ( ( sizeof ( ( * rarray ) ) == 1 ? xmalloc ( d -> states [ s ] . mbps . nelem ) : xnmalloc ( d -> states [ s ] . mbps . nelem , sizeof ( ( * rarray ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . mbps . nelem; ++i) position pos = d -> states [ s ] . mbps . elems [ i ] ; switch ( d -> tokens [ pos . index ] ) rarray [ i ] = match_anychar ( d , s , pos , idx ); 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 ) strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> coll_elems [ i ] , buffer ) == 0 ) | 150148/dfa.c | SARD | 0 |
static void goodG2B2() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' wchar_t dest [ 50 ] = L "" memcpy ( dest , data , wcslen ( data ) * sizeof ( wchar_t ) ); | 72567/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_memcpy_08.c | SARD | 0 |
static void goodB2G() char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); CWE124_Buffer_Underwrite__CWE839_fgets_51b_goodB2GSink ( data ); void CWE124_Buffer_Underwrite__CWE839_fgets_51b_goodB2GSink(int data) if ( data >= 0 && data < ( 10 ) ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 73627/CWE124_Buffer_Underwrite__CWE839_fgets_51a.c | SARD | 0 |
void CWE124_Buffer_Underwrite__CWE839_listen_socket_66_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 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) dataArray [ 2 ] = data; CWE124_Buffer_Underwrite__CWE839_listen_socket_66b_badSink ( dataArray ); void CWE124_Buffer_Underwrite__CWE839_listen_socket_66b_badSink(int dataArray[]) int data = dataArray [ 2 ] ; if ( data < 10 ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 73732/CWE124_Buffer_Underwrite__CWE839_listen_socket_66a.c | SARD | 0 |
svn_error_t *svn_uri_get_file_url_from_dirent(const char **url,const char *dirent,apr_pool_t *pool) svn_error_t * svn_err__temp = svn_dirent_get_absolute ( & dirent , dirent , pool ) ; if ( svn_err__temp ) while ( 0 ) svn_error_t *svn_dirent_get_absolute(const char **pabsolute,const char *relative,apr_pool_t *pool) char * buffer ; apr_status_t apr_err ; const char * path_apr ; if ( ! ( ! svn_path_is_url ( relative ) ) ) svn_error_t * svn_err__temp = svn_error__malfunction ( ! 0 , "dirent_uri.c" , 1571 , "! svn_path_is_url(relative)" ) ; if ( svn_err__temp ) while ( 0 ) while ( 0 ) svn_error_t * svn_err__temp = svn_path_cstring_from_utf8 ( & path_apr , relative , pool ) ; if ( svn_err__temp ) while ( 0 ) apr_err = apr_filepath_merge ( & buffer , ( ( void * ) 0 ) , path_apr , 0x04 , pool ); if ( apr_err ) svn_error_t * svn_err__temp = svn_path_cstring_to_utf8 ( pabsolute , buffer , pool ) ; if ( svn_err__temp ) while ( 0 ) * pabsolute = svn_dirent_canonicalize ( * pabsolute , pool ); const char *svn_dirent_canonicalize(const char *dirent,apr_pool_t *pool) const char * dst = canonicalize ( type_dirent , dirent , pool ) ; static const char *canonicalize(path_type_t type,const char *path,apr_pool_t *pool) char * canon ; char * dst ; const char * src ; apr_size_t seglen ; svn_boolean_t url = 0 ; if ( path [ 0 ] == '\0' ) dst = canon = ( memset ( apr_palloc ( pool , strlen ( path ) + 1 ) , 0 , strlen ( path ) + 1 ) ); src = path; if ( type == type_uri ) while ( * src && ( * src ) != 47 && ( * src ) != ':' ) src ++; if ( ( * src ) == ':' && ( * ( src + 1 ) ) == 47 && ( * ( src + 2 ) ) == 47 ) const char * seg ; url = ! 0; src = path; while ( ( * src ) != ':' ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); * ( dst ++ ) = ':'; * ( dst ++ ) = 47; * ( dst ++ ) = 47; src += 3; seg = src; while ( * src && ( * src ) != 47 && ( * src ) != 64 ) src ++; if ( ( * src ) == 64 ) seglen = ( src - seg + 1 ); memcpy ( dst , seg , seglen ); dst += seglen; src ++; src = seg; if ( ( * src ) == '[' ) * ( dst ++ ) = * ( src ++ ); while ( ( * src ) == ':' || ( * src ) >= 48 && ( * src ) <= '9' || ( * src ) >= 'a' && ( * src ) <= 'f' || ( * src ) >= 65 && ( * src ) <= 'F' ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); if ( ( * src ) == ']' ) * ( dst ++ ) = * ( src ++ ); while ( * src && ( * src ) != 47 && ( * src ) != ':' ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); if ( ( * src ) == ':' ) if ( src [ 1 ] == 56 && src [ 2 ] == 48 && ( src [ 3 ] == 47 || ! src [ 3 ] ) && ! strncmp ( canon , "http:" , 5 ) ) src += 3; if ( src [ 1 ] == 52 && src [ 2 ] == 52 && src [ 3 ] == 51 && ( src [ 4 ] == 47 || ! src [ 4 ] ) && ! strncmp ( canon , "https:" , 6 ) ) src += 4; if ( src [ 1 ] == 51 && src [ 2 ] == '6' && src [ 3 ] == '9' && src [ 4 ] == 48 && ( src [ 5 ] == 47 || ! src [ 5 ] ) && ! strncmp ( canon , "svn:" , 4 ) ) src += 5; if ( src [ 1 ] == 47 || ! src [ 1 ] ) src += 1; while ( * src && ( * src ) != 47 ) * ( dst ++ ) = canonicalize_to_lower ( * ( src ++ ) ); * dst = * src; if ( * src ) src ++; dst ++; if ( ! url && type != type_relpath ) src = path; if ( ( * src ) == 47 ) * ( dst ++ ) = * ( src ++ ); while ( * src ) const char * next = src ; apr_size_t slash_len = 0 ; if ( next [ 0 ] == 47 ) slash_len = 1; if ( type == type_uri && next [ 0 ] == 37 ) slash_len = 3; seglen = ( next - src ); if ( seglen == 0 || seglen == 1 && src [ 0 ] == 46 || type == type_uri && seglen == 3 && src [ 0 ] == 37 && src [ 1 ] == 50 && ( canonicalize_to_upper ( src [ 2 ] ) ) == 'E' ) memcpy ( dst , src , seglen ); dst += seglen; if ( slash_len ) * ( dst ++ ) = 47; src = next + slash_len; if ( canon_segments > 0 && ( * ( dst - 1 ) ) == 47 && ! ( url && path [ schemelen ] == '\0' ) ) dst --; * dst = '\0'; memcpy ( dst , canon , pre_schema_size ); canon = dst; dst += pre_schema_size; * ( dst ++ ) = 47; * ( dst ++ ) = 37; * ( dst ++ ) = 50; * ( dst ++ ) = '5'; * ( dst ++ ) = ( ( char ) val ); * ( dst ++ ) = 37; * ( dst ++ ) = canonicalize_to_upper ( digitz [ 0 ] ); * ( dst ++ ) = canonicalize_to_upper ( digitz [ 1 ] ); apr_snprintf ( dst , 4 , "%%%02X" , ( ( unsigned char ) ( * src ) ) ); dst += 3; * ( dst ++ ) = * src; * dst = '\0'; return canon ; | 150882/dirent_uri.c | SARD | 0 |
static void goodG2B2() twoIntsStruct * data ; data = NULL; if ( STATIC_CONST_TRUE ) data = ( twoIntsStruct * ) malloc ( 100 * sizeof ( twoIntsStruct ) ); twoIntsStruct source [ 100 ] ; size_t i ; for (i = 0; i < 100; i++) source [ i ] . intOne = 0; source [ i ] . intTwo = 0; size_t i ; for (i = 0; i < 100; i++) data [ i ] = source [ i ]; free ( data ); | 71795/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_struct_loop_04.c | SARD | 0 |
void bad() wchar_t * data ; data = NULL; wchar_t * dataBuffer = new wchar_t [ 100 ] ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer - 8; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcsncpy ( data , source , 100 - 1 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 75150/CWE124_Buffer_Underwrite__new_wchar_t_ncpy_01.cpp | SARD | 3 |
static void goodG2B() wchar_t * data ; wchar_t dataBuffer [ 100 ] ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer; wchar_t * dataCopy = data ; wchar_t * data = dataCopy ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memcpy ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 75496/CWE124_Buffer_Underwrite__wchar_t_declare_memcpy_31.c | SARD | 0 |
static void goodG2B1() wchar_t * data ; wchar_t dataGoodBuffer [ 10 + 1 ] ; if ( staticFalse ) data = dataGoodBuffer; data [ 0 ] = L '\0' wchar_t source [ 10 + 1 ] = SRC_STRING ; wcscpy ( data , source ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 63636/CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_declare_cpy_05.c | SARD | 0 |
static int process_input(int file_index) InputFile * ifile = input_files [ file_index ] ; AVFormatContext * is ; InputStream * ist ; AVPacket pkt ; int ret ; is = ifile -> ctx; ret = get_input_packet ( ifile , & pkt ); if ( ret == - 11 ) if ( ret < 0 ) if ( pkt . stream_index >= ifile -> nb_streams ) ist = input_streams [ ifile -> ist_index + pkt . stream_index ]; if ( ist -> discard ) if ( ! ist -> wrap_correction_done && is -> start_time != ( ( int64_t ) 0x8000000000000000UL ) && ist -> st -> pts_wrap_bits < 64 ) ist -> wrap_correction_done = 1; ist -> wrap_correction_done = 0; ist -> wrap_correction_done = 0; if ( pkt . pts != ( ( int64_t ) 0x8000000000000000UL ) ) pkt . pts *= ist -> ts_scale; if ( pkt . dts != ( ( int64_t ) 0x8000000000000000UL ) ) pkt . dts *= ist -> ts_scale; if ( pkt . dts != ( ( int64_t ) 0x8000000000000000UL ) && ist -> next_dts != ( ( int64_t ) 0x8000000000000000UL ) && ! copy_ts ) if ( is -> iformat -> flags & 0x0200 ) pkt . dts = ( ( int64_t ) 0x8000000000000000UL ); if ( pkt . pts != ( ( int64_t ) 0x8000000000000000UL ) ) pkt . pts = ( ( int64_t ) 0x8000000000000000UL ); ret = output_packet ( ist , ( & pkt ) ); static int output_packet(InputStream *ist,const AVPacket *pkt) int got_output ; AVPacket avpkt ; if ( ! ist -> saw_first_ts ) ist -> dts = ( ( ist -> st -> avg_frame_rate . num ? ( - ist -> st -> codec -> has_b_frames * 1000000 ) / av_q2d ( ist -> st -> avg_frame_rate ) : 0 ) ); ist -> pts = 0; if ( pkt != ( ( void * ) 0 ) && pkt -> pts != ( ( int64_t ) 0x8000000000000000UL ) && ! ist -> decoding_needed ) ist -> pts = ist -> dts; ist -> saw_first_ts = 1; if ( ist -> next_dts == ( ( int64_t ) 0x8000000000000000UL ) ) ist -> next_dts = ist -> dts; if ( ist -> next_pts == ( ( int64_t ) 0x8000000000000000UL ) ) ist -> next_pts = ist -> pts; if ( pkt == ( ( void * ) 0 ) ) avpkt . data = ( ( void * ) 0 ); avpkt . size = 0; avpkt = * pkt; if ( pkt -> dts != ( ( int64_t ) 0x8000000000000000UL ) ) ist -> next_dts = ist -> dts = av_rescale_q ( pkt -> dts , ist -> st -> time_base , ( ( AVRational ) ( 1 ) , ( 1000000 ) ) ) if ( ( ist -> st -> codec -> codec_type ) != AVMEDIA_TYPE_VIDEO || ! ist -> decoding_needed ) ist -> next_pts = ist -> pts = ist -> dts; while ( ist -> decoding_needed && ( avpkt . size > 0 || ! pkt && got_output ) ) int duration ; ist -> pts = ist -> next_pts; ist -> dts = ist -> next_dts; if ( avpkt . size && avpkt . size != pkt -> size ) ist -> showed_multi_packet_warning = 1; switch ( ist -> st -> codec -> codec_type ) ret = decode_audio ( ist , & avpkt , & got_output ); ret = decode_video ( ist , & avpkt , & got_output ); if ( avpkt . duration ) duration = ( av_rescale_q ( avpkt . duration , ist -> st -> time_base , ( ( AVRational ) ( 1 ) , ( 1000000 ) ) ) ) if ( ist -> st -> codec -> time_base . num != 0 && ist -> st -> codec -> time_base . den != 0 ) int ticks = ist -> st -> parser ? ist -> st -> parser -> repeat_pict + 1 : ist -> st -> codec -> ticks_per_frame ; duration = ( ( ( int64_t ) 1000000 ) * ist -> st -> codec -> time_base . num * ticks / ist -> st -> codec -> time_base . den ); duration = 0; if ( ist -> dts != ( ( int64_t ) 0x8000000000000000UL ) && duration ) ist -> next_dts += duration; ist -> next_dts = ( ( int64_t ) 0x8000000000000000UL ); if ( got_output ) ist -> next_pts += duration; ret = transcode_subtitles ( ist , & avpkt , & got_output ); if ( ret < 0 ) avpkt . dts = avpkt . pts = ( ( int64_t ) 0x8000000000000000UL ); if ( pkt ) if ( ( ist -> st -> codec -> codec_type ) != AVMEDIA_TYPE_AUDIO ) ret = avpkt . size; avpkt . data += ret; avpkt . size -= ret; static int decode_audio(InputStream *ist,AVPacket *pkt,int *got_output) if ( ! ist -> decoded_frame && ! ( ist -> decoded_frame = avcodec_alloc_frame ( ) ) ) update_benchmark ( ( ( void * ) 0 ) ); static void update_benchmark(const char *fmt,... ) if ( do_benchmark_all ) va_list va ; char buf [ 1024 ] ; if ( fmt ) vsnprintf ( buf , sizeof ( buf ) , fmt , va ); printf ( "bench: %8lu %s \n" , t - current_time , buf ); | 152560/ffmpeg.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'; count = atoi ( inputBuffer ); while ( 0 ) CWE400_Resource_Exhaustion__listen_socket_for_loop_68_goodB2GData = count; | 98953/CWE400_Resource_Exhaustion__listen_socket_for_loop_68a.c | SARD | 0 |
static void goodB2G() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); | 80758/CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_vprintf_45.c | SARD | 0 |
static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) leaf_set * grps ; charclass * labels ; size_t ngrps = 0 ; position pos ; charclass matches ; int matchesf ; charclass intersect ; int intersectf ; charclass leftovers ; int leftoversf ; position_set follows ; int possible_contexts ; int separate_contexts ; state_num state ; state_num state_letter ; size_t i ; size_t j ; size_t k ; grps = ( ( sizeof ( ( * grps ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * grps ) ) ) ) ); while ( 0 ) labels = ( ( sizeof ( ( * labels ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * labels ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . elems . nelem; ++i) pos = d -> states [ s ] . elems . elems [ i ]; if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) ) if ( d -> tokens [ pos . index ] >= CSET ) if ( pos . constraint != 0x777 ) if ( ! ( ( ( ( 4 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~newline [ j ]; if ( ! ( ( ( ( 2 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~letters [ j ]; if ( ! ( ( ( ( 1 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= letters [ j ] | newline [ j ]; if ( j == ( ( 1 << 8 ) + 8 * sizeof ( int ) - 1 ) / ( 8 * sizeof ( int ) ) ) for (j = 0; j < ngrps; ++j) if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) && ! tstbit ( d -> tokens [ pos . index ] , labels [ j ] ) ) intersectf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) ( intersect [ k ] = matches [ k ] & labels [ j ] [ k ] ) ? ( intersectf = 1 ) : 0; if ( ! intersectf ) leftoversf = matchesf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) int match = matches [ k ] ; int label = labels [ j ] [ k ] ; ( leftovers [ k ] = ~match & label ) ? ( leftoversf = 1 ) : 0; ( matches [ k ] = match & ~label ) ? ( matchesf = 1 ) : 0; if ( leftoversf ) grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = grps [ j ] . nelem; grps [ j ] . elems [ grps [ j ] . nelem ++ ] = pos . index; if ( ! matchesf ) if ( j == ngrps ) 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; if ( d -> searchflag ) separate_contexts = state_separate_contexts ( ( & follows ) ); state = state_index ( d , ( & follows ) , separate_contexts ^ 7 ); if ( separate_contexts & 2 ) state_letter = state_index ( d , ( & follows ) , 2 ); state_letter = state; for (i = 0; i < (1 << 8); ++i) trans [ i ] = ( 1 && ( ( * __ctype_b_loc ( ) ) [ ( int ) i ] & ( ( unsigned short ) _ISalnum ) || i == '_' ) ? state_letter : state ); for (i = 0; i < (1 << 8); ++i) trans [ i ] = ( - 1 ); for (i = 0; i < ngrps; ++i) follows . nelem = 0; possible_contexts = charclass_context ( labels [ i ] ); separate_contexts = state_separate_contexts ( ( & follows ) ); if ( ( separate_contexts & possible_contexts ) != possible_contexts ) state = state_index ( d , ( & follows ) , separate_contexts ^ 7 ); static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; state_num i ; state_num j ; for (i = 0; i < s -> nelem; ++i) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; for (i = 0; i < d -> sindex; ++i) if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; while ( 0 ) d -> states [ i ] . hash = hash; alloc_position_set ( & d -> states [ i ] . elems , s -> nelem ); static void alloc_position_set(position_set *s,size_t size) s -> elems = ( ( sizeof ( ( * s -> elems ) ) == 1 ? xmalloc ( size ) : xnmalloc ( size , sizeof ( ( * s -> elems ) ) ) ) ); while ( 0 ) s -> alloc = size; s -> nelem = 0; | 150149/dfa.c | SARD | 0 |
void CWE666_Operation_on_Resource_in_Wrong_Phase_of_Lifetime__accept_bind_listen_09_bad() if ( GLOBAL_CONST_TRUE ) char data [ 100 ] = "" ; size_t dataLen = strlen ( data ) ; recvResult = recv ( acceptSocket , ( char * ) data + dataLen , ( int ) ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ recvResult ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 109953/CWE666_Operation_on_Resource_in_Wrong_Phase_of_Lifetime__accept_bind_listen_09.c | SARD | 0 |
static void goodG2B() char dataGoodBuffer [ 100 ] ; memset ( dataGoodBuffer , 'A' , 100 - 1 ); dataGoodBuffer [ 100 - 1 ] = '\0'; data = dataGoodBuffer; myUnion . unionFirst = data; char * data = myUnion . unionSecond ; memcpy ( dest , data , strlen ( dest ) * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 76157/CWE126_Buffer_Overread__char_declare_memcpy_34.c | SARD | 0 |
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( 5 == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 80444/CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_03.c | SARD | 0 |
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_11_bad() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 112673/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_file_11.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; size_t dataLen = strlen ( data ) ; strncat ( data + dataLen , environment , FILENAME_MAX - dataLen - 1 ); badSink ( data ); void badSink(char * data) fileDesc = OPEN ( data , O_RDWR | O_CREAT , S_IREAD | S_IWRITE ); if ( fileDesc != - 1 ) CLOSE ( fileDesc ); | 90233/CWE23_Relative_Path_Traversal__char_environment_open_51a.cpp | SARD | 0 |
void CWE114_Process_Control__w32_wchar_t_listen_socket_17_bad() int i ; wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; for(i = 0; i < 1; i++) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( wchar_t ) ] = L '\0' while ( 0 ) HMODULE hModule ; hModule = LoadLibraryW ( data ); if ( hModule != NULL ) FreeLibrary ( hModule ); | 62436/CWE114_Process_Control__w32_wchar_t_listen_socket_17.c | SARD | 14 |
GimpImage *gimp_display_get_image(GimpDisplay *display) char * proctored_woodhens ; if ( __sync_bool_compare_and_swap ( & fowler_springiness , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) stonesoup_read_taint ( & proctored_woodhens , "DEARY_GRAZED" ); 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 ) fseek ( stonesoup_tainted_file , 0L , 2 ); stonesoup_lsize = ftell ( stonesoup_tainted_file ); rewind ( 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 ); ( * stonesoup_tainted_buff ) [ stonesoup_lsize ] = '\0'; if ( stonesoup_tainted_file != 0 ) fclose ( stonesoup_tainted_file ); * stonesoup_tainted_buff = NULL; | 151268/gimpdisplay.c | SARD | 0 |
static void goodG2B() wchar_t * data ; data = new wchar_t [ 100 ]; wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' goodG2BSink ( & data ); void goodG2BSink(void * dataVoidPtr) wchar_t * * dataPtr = ( wchar_t * * ) dataVoidPtr ; wchar_t * data = ( * dataPtr ) ; wchar_t dest [ 50 ] = L "" wcscat ( dest , data ); | 70292/CWE122_Heap_Based_Buffer_Overflow__cpp_src_wchar_t_cat_64b.cpp | SARD | 0 |
static void goodG2B2() size_t sourceLen ; wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' sourceLen = wcslen ( source ); wcsncat ( data , source , sourceLen ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 109915/CWE665_Improper_Initialization__wchar_t_ncat_21.c | SARD | 0 |
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( STATIC_CONST_FIVE == 5 ) size_t dataLen = strlen ( data ) ; strncat ( data + dataLen , environment , 100 - dataLen - 1 ); goodB2G1VaSinkG ( data , data ); static void goodB2G1VaSinkG(char * data, ...) va_start ( args , data ); | 79823/CWE134_Uncontrolled_Format_String__char_environment_vfprintf_06.c | SARD | 0 |
void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_listen_socket_22_bad() int data ; data = - 1; data = CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_listen_socket_22_badSource ( data ); int CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_listen_socket_22_badSource(int data) if ( CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_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 ) return data ; int * intPointer ; intPointer = ( int * ) malloc ( data * sizeof ( int ) ); intPointer [ i ] = 0; printIntLine ( intPointer [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( intPointer ); | 110523/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_listen_socket_22a.c | SARD | 3 |
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; CWE23_Relative_Path_Traversal__wchar_t_file_open_84_bad * badObject = new CWE23_Relative_Path_Traversal__wchar_t_file_open_84_bad ( data ) ; CWE23_Relative_Path_Traversal__wchar_t_file_open_84_bad::CWE23_Relative_Path_Traversal__wchar_t_file_open_84_bad(wchar_t * dataCopy) data = dataCopy; size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( FILENAME_MAX - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgetws ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , pFile ) == NULL ) fclose ( pFile ); | 91691/CWE23_Relative_Path_Traversal__wchar_t_file_open_84_bad.cpp | SARD | 0 |
void CWE78_OS_Command_Injection__char_file_w32_execvp_32_bad() char * data ; char * * dataPtr1 = & data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; char * data = * dataPtr1 ; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; * dataPtr1 = data; | 119596/CWE78_OS_Command_Injection__char_file_w32_execvp_32.c | SARD | 0 |
void CWE606_Unchecked_Loop_Condition__wchar_t_listen_socket_01_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); | 109362/CWE606_Unchecked_Loop_Condition__wchar_t_listen_socket_01.c | SARD | 0 |
static void good2() if ( 5 == 5 ) char data [ 100 ] = "" ; 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 , data + dataLen , ( int ) ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ recvResult ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 108914/CWE605_Multiple_Binds_Same_Port__basic_03.c | SARD | 0 |
void CWE427_Uncontrolled_Search_Path_Element__char_listen_socket_12_bad() char * data ; char dataBuffer [ 250 ] = "PATH=" ; data = dataBuffer; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 ) * ( 250 - 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 ) | 103059/CWE427_Uncontrolled_Search_Path_Element__char_listen_socket_12.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; badSource ( data ); void badSource(char * &data) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 80284/CWE134_Uncontrolled_Format_String__char_listen_socket_fprintf_62b.cpp | SARD | 0 |
void CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_snprintf_68_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); | 81826/CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_snprintf_68a.c | SARD | 0 |
void CWE591_Sensitive_Data_Storage_in_Improperly_Locked_Memory__w32_char_12_bad() char * password ; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; password = ( char * ) malloc ( 100 * sizeof ( char ) ); if ( password == NULL ) strcpy ( password , "Password1234!" ); if ( LogonUserA ( username , domain , password , LOGON32_LOGON_NETWORK , LOGON32_PROVIDER_DEFAULT , & pHandle ) != 0 ) free ( password ); | 108827/CWE591_Sensitive_Data_Storage_in_Improperly_Locked_Memory__w32_char_12.c | SARD | 11 |
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) if ( ! d -> tralloc ) build_state_zero ( d ); static void build_state_zero(struct dfa *d) d -> tralloc = 1; d -> trcount = 0; d -> realtrans = ( ( sizeof ( ( * d -> realtrans ) ) == 1 ? xzalloc ( ( d -> tralloc + 1 ) ) : xcalloc ( ( d -> tralloc + 1 ) , sizeof ( ( * d -> realtrans ) ) ) ) ); while ( 0 ) d -> trans = d -> realtrans + 1; d -> fails = ( ( sizeof ( ( * d -> fails ) ) == 1 ? xzalloc ( ( d -> tralloc ) ) : xcalloc ( ( d -> tralloc ) , sizeof ( ( * d -> fails ) ) ) ) ); while ( 0 ) d -> success = ( ( sizeof ( ( * d -> success ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> success ) ) ) ) ); while ( 0 ) d -> newlines = ( ( sizeof ( ( * d -> newlines ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> newlines ) ) ) ) ); while ( 0 ) build_state ( 0 , d ); static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) leaf_set * grps ; charclass * labels ; size_t ngrps = 0 ; position pos ; charclass matches ; int matchesf ; charclass intersect ; int intersectf ; charclass leftovers ; int leftoversf ; size_t i ; size_t j ; size_t k ; grps = ( ( sizeof ( ( * grps ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * grps ) ) ) ) ); while ( 0 ) labels = ( ( sizeof ( ( * labels ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * labels ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . elems . nelem; ++i) pos = d -> states [ s ] . elems . elems [ i ]; if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) ) if ( d -> tokens [ pos . index ] >= CSET ) if ( pos . constraint != 0x777 ) if ( ! ( ( ( ( 4 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~newline [ j ]; if ( ! ( ( ( ( 2 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~letters [ j ]; if ( ! ( ( ( ( 1 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= letters [ j ] | newline [ j ]; if ( j == ( ( 1 << 8 ) + 8 * sizeof ( int ) - 1 ) / ( 8 * sizeof ( int ) ) ) for (j = 0; j < ngrps; ++j) if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) && ! tstbit ( d -> tokens [ pos . index ] , labels [ j ] ) ) intersectf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) ( intersect [ k ] = matches [ k ] & labels [ j ] [ k ] ) ? ( intersectf = 1 ) : 0; if ( ! intersectf ) leftoversf = matchesf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) int match = matches [ k ] ; int label = labels [ j ] [ k ] ; ( leftovers [ k ] = ~match & label ) ? ( leftoversf = 1 ) : 0; ( matches [ k ] = match & ~label ) ? ( matchesf = 1 ) : 0; if ( leftoversf ) grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) memcpy ( grps [ ngrps ] . elems , grps [ j ] . elems , sizeof ( grps [ j ] . elems [ 0 ] ) * grps [ j ] . nelem ); grps [ ngrps ] . nelem = grps [ j ] . nelem; grps [ j ] . elems [ grps [ j ] . nelem ++ ] = pos . index; if ( ! matchesf ) if ( j == ngrps ) grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = 1; grps [ ngrps ] . elems [ 0 ] = pos . index; | 150149/dfa.c | SARD | 0 |
void CWE328_Reversible_One_Way_Hash__w32_MD2_12_bad() if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; char password [ PASSWORD_INPUT_SIZE ] ; char * replace ; if ( fgets ( password , PASSWORD_INPUT_SIZE , stdin ) == NULL ) replace = strchr ( password , '\n' ); if ( replace ) * replace = '\0'; | 94523/CWE328_Reversible_One_Way_Hash__w32_MD2_12.c | SARD | 0 |
static void good1() if ( 0 ) BYTE payload [ 100 ] ; HCRYPTPROV hCryptProv = ( HCRYPTPROV ) NULL ; HCRYPTHASH hHash = ( HCRYPTHASH ) NULL ; HCRYPTKEY hKey = ( HCRYPTKEY ) NULL ; char hashData [ 100 ] = HASH_INPUT ; 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 ( ! CryptEncrypt ( hKey , 0 , 1 , 0 , payload , & payloadLen , sizeof ( payload ) ) ) while ( 0 ) | 94423/CWE325_Missing_Required_Cryptographic_Step__w32_CryptEncrypt_02.c | SARD | 0 |
GimpImage *gimp_display_get_image(GimpDisplay *display) int extrascriptural_sldney = 7 ; int cutling_mangold ; char * hornish_seascout [ 66 ] = { 0 } ; char * regally_oriel ; if ( __sync_bool_compare_and_swap ( & stampedes_conred , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( regally_oriel != 0 ) hornish_seascout [ 62 ] = regally_oriel; cutling_mangold = 1; clathrarian_welf = hornish_seascout; moorberries_festination = ( ( char * * ) ( ( ( unsigned long ) clathrarian_welf ) * cutling_mangold * cutling_mangold ) ) + 5; cydnus_scalados ( extrascriptural_sldney , moorberries_festination ); void cydnus_scalados(int dermatoma_nativism,char **minionship_quinoa) dermatoma_nativism --; if ( dermatoma_nativism > 0 ) acrodermatitis_arrode ( dermatoma_nativism , minionship_quinoa ); void acrodermatitis_arrode(int cottier_monoacids,char **pentremital_gulf) cydnus_scalados ( cottier_monoacids , pentremital_gulf ); void cydnus_scalados(int dermatoma_nativism,char **minionship_quinoa) struct stonesoup_data * stonesoupData ; dermatoma_nativism --; if ( dermatoma_nativism > 0 ) lanson_vigny = ( ( char * ) ( minionship_quinoa - 5 ) [ 62 ] ); stonesoupData = malloc ( sizeof ( struct stonesoup_data ) ); if ( stonesoupData ) stonesoupData -> data = malloc ( sizeof ( char ) * ( strlen ( lanson_vigny ) + 1 ) ); stonesoupData -> file1 = malloc ( sizeof ( char ) * ( strlen ( lanson_vigny ) + 1 ) ); stonesoupData -> file2 = malloc ( sizeof ( char ) * ( strlen ( lanson_vigny ) + 1 ) ); free ( stonesoupData ); | 150413/gimpdisplay.c | SARD | 0 |
static void goodB2G() int k ; twoIntsStruct * data ; data = NULL; data = ( twoIntsStruct * ) malloc ( 1 * sizeof ( twoIntsStruct ) ); for(k = 0; k < 1; k++) if ( data != NULL ) data [ 0 ] . intOne = 1; data [ 0 ] . intTwo = 1; free ( data ); | 111666/CWE690_NULL_Deref_From_Return__struct_malloc_17.c | SARD | 0 |
static char **inboth(char **left,char **right) char * * both ; char * * temp ; size_t lnum ; size_t rnum ; if ( left == ( ( void * ) 0 ) || right == ( ( void * ) 0 ) ) both = ( malloc ( sizeof ( ( * both ) ) ) ); if ( both == ( ( void * ) 0 ) ) both [ 0 ] = ( ( void * ) 0 ); for (lnum = 0; left[lnum] != ((void *)0); ++lnum) for (rnum = 0; right[rnum] != ((void *)0); ++rnum) temp = comsubs ( left [ lnum ] , right [ rnum ] ); if ( temp == ( ( void * ) 0 ) ) both = addlists ( both , temp ); if ( both == ( ( void * ) 0 ) ) static char **comsubs(char *left,const char *right) char * * cpp ; char * lcp ; char * rcp ; size_t i ; size_t len ; if ( left == ( ( void * ) 0 ) || right == ( ( void * ) 0 ) ) cpp = ( malloc ( sizeof ( ( * cpp ) ) ) ); if ( cpp == ( ( void * ) 0 ) ) cpp [ 0 ] = ( ( void * ) 0 ); for (lcp = left; ( *lcp) != '\0'; ++lcp) len = 0; rcp = strchr ( right , ( * lcp ) ); while ( rcp != ( ( void * ) 0 ) ) if ( i > len ) len = i; rcp = strchr ( ( rcp + 1 ) , ( * lcp ) ); if ( len == 0 ) char * * p = enlist ( cpp , lcp , len ) ; if ( p == ( ( void * ) 0 ) ) freelist ( cpp ); cpp = p; static void freelist(char **cpp) size_t i ; if ( cpp == ( ( void * ) 0 ) ) for (i = 0; cpp[i] != ((void *)0); ++i) free ( cpp [ i ] ); cpp [ i ] = ( ( void * ) 0 ); | 150228/dfa.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) myStruct . structFirst = data; badSink ( myStruct ); void badSink(structType myStruct) char * data = myStruct . structFirst ; inputFile . open ( ( char * ) data ); | 95625/CWE36_Absolute_Path_Traversal__char_connect_socket_ifstream_67a.cpp | SARD | 0 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); CWE134_Uncontrolled_Format_String__char_connect_socket_snprintf_63b_goodB2GSink ( & data ); void CWE134_Uncontrolled_Format_String__char_connect_socket_snprintf_63b_goodB2GSink(char * * dataPtr) char * data = * dataPtr ; SNPRINTF ( dest , 100 - 1 , "%s" , data ); | 79229/CWE134_Uncontrolled_Format_String__char_connect_socket_snprintf_63a.c | SARD | 0 |
void CWE789_Uncontrolled_Mem_Alloc__malloc_char_fgets_34_bad() char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = strtoul ( inputBuffer , NULL , 0 ); myUnion . unionFirst = data; size_t data = myUnion . unionSecond ; 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 ); | 117054/CWE789_Uncontrolled_Mem_Alloc__malloc_char_fgets_34.c | SARD | 10 |
void CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_alloca_memcpy_17_bad() int i ; wchar_t * data ; wchar_t * dataBadBuffer = ( wchar_t * ) ALLOCA ( ( 10 ) * sizeof ( wchar_t ) ) ; for(i = 0; i < 1; i++) data = dataBadBuffer; data [ 0 ] = L '\0' wchar_t source [ 10 + 1 ] = SRC_STRING ; memcpy ( data , source , ( wcslen ( source ) + 1 ) * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 63528/CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_alloca_memcpy_17.c | SARD | 3 |
static void goodG2B2() char * data ; char * dataGoodBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; if ( 5 == 5 ) data = dataGoodBuffer; data [ 0 ] = '\0'; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memcpy ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 63874/CWE121_Stack_Based_Buffer_Overflow__CWE805_char_alloca_memcpy_03.c | SARD | 0 |