func
stringlengths 181
23.6k
| path
stringlengths 12
123
| source
stringclasses 2
values | label
int64 0
40
|
---|---|---|---|
static void goodB2G() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; size_t dataLen = wcslen ( data ) ; recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) | 80645/CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_snprintf_12.c | SARD | 0 |
static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) int mbclen ; int maxlen = 0 ; size_t i ; int * match_lens = ( ( void * ) 0 ) ; size_t nelem = d -> states [ s ] . mbps . nelem ; position_set follows ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) transit_state_consume_1char ( d , s , pp , match_lens , & mbclen , & follows ); static status_transit_state transit_state_consume_1char(struct dfa *d,state_num s,const unsigned char **pp,int *match_lens,int *mbclen,position_set *pps) int k ; state_num s1 ; state_num s2 ; * 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; build_state ( works , d ); static void build_state(state_num s,struct dfa *d) state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) free ( d -> fails [ i ] ); d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); | 152165/dfa.c | SARD | 0 |
static void goodG2B2() wchar_t * data ; wchar_t dataGoodBuffer [ 100 ] ; if ( 1 ) data = dataGoodBuffer; data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcsncat ( data , source , 100 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 65393/CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_declare_ncat_02.c | SARD | 0 |
static void goodB2G1() size_t data ; data = 0; 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 = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) switch ( 8 ) if ( data > wcslen ( HELLO_STRING ) && data < 100 ) | 117717/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_connect_socket_15.cpp | SARD | 0 |
static void goodG2B2() int * data ; data = NULL; if ( globalFive == 5 ) data = ( int * ) malloc ( 10 * sizeof ( int ) ); int source [ 10 ] = { 0 } ; memmove ( data , source , 10 * sizeof ( int ) ); printIntLine ( data [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( data ); | 70365/CWE122_Heap_Based_Buffer_Overflow__CWE131_memmove_14.c | SARD | 0 |
static void goodB2G2() char * password ; char passwordBuffer [ 100 ] = "" ; password = passwordBuffer; if ( 1 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t passwordLen = strlen ( password ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( password + passwordLen ) , ( 100 - passwordLen - 1 ) * sizeof ( char ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) password [ passwordLen + recvResult / sizeof ( char ) ] = '\0'; while ( 0 ) if ( 1 ) HCRYPTPROV hCryptProv = 0 ; HCRYPTHASH hHash = 0 ; HCRYPTKEY hKey = 0 ; char hashData [ 100 ] = HASH_INPUT ; BYTE payload [ ( 100 - 1 ) * sizeof ( char ) ] ; DWORD payloadBytes ; payloadBytes = decodeHexChars ( payload , sizeof ( payload ) , password ); size_t decodeHexChars(unsigned char * bytes, size_t numBytes, const char * hex) size_t numWritten = 0 ; while ( numWritten < numBytes && isxdigit ( hex [ 2 * numWritten ] ) && isxdigit ( hex [ 2 * numWritten + 1 ] ) ) int byte ; bytes [ numWritten ] = ( unsigned char ) byte; return numWritten ; if ( ! CryptAcquireContext ( & hCryptProv , NULL , MS_ENH_RSA_AES_PROV , PROV_RSA_AES , 0 ) ) if ( ! CryptCreateHash ( hCryptProv , CALG_SHA_256 , 0 , 0 , & hHash ) ) if ( ! CryptHashData ( hHash , ( BYTE * ) hashData , strlen ( hashData ) , 0 ) ) if ( ! CryptDeriveKey ( hCryptProv , CALG_AES_256 , hHash , 0 , & hKey ) ) if ( ! CryptDecrypt ( hKey , 0 , 1 , 0 , payload , & payloadBytes ) ) memcpy ( password , payload , payloadBytes ); password [ payloadBytes / sizeof ( char ) ] = '\0'; while ( 0 ) if ( LogonUserA ( username , domain , password , LOGON32_LOGON_NETWORK , LOGON32_PROVIDER_DEFAULT , & pHandle ) != 0 ) | 94099/CWE319_Cleartext_Tx_Sensitive_Info__w32_char_connect_socket_02.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_vprintf_66_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 ); | 81920/CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_vprintf_66a.c | SARD | 0 |
static void goodG2B1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticFalse ) strcpy ( data , "fixedstringtest" ); if ( staticTrue ) goodG2B1VaSinkB ( data , data ); static void goodG2B1VaSinkB(char * data, ...) char dest [ 100 ] = "" ; va_list args ; vsnprintf ( dest , 100 - 1 , data , args ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 80206/CWE134_Uncontrolled_Format_String__char_file_w32_vsnprintf_05.c | SARD | 0 |
int color(u_short mode,char *name,bool orphan,bool islink) if ( orphan ) if ( islink ) if ( missing_flgs ) if ( orphan_flgs ) switch ( mode & 0170000 ) if ( mode & 01000 ) if ( mode & 0200 >> 3 >> 3 && stickyow_flgs ) if ( ! ( mode & 0200 >> 3 >> 3 ) && sticky_flgs ) if ( mode & 0200 >> 3 >> 3 && otherwr_flgs ) if ( ! dir_flgs ) fprintf ( outfile , "%s%s%s" , leftcode , dir_flgs , rightcode ); fprintf ( outfile , "%s%s%s" , leftcode , block_flgs , rightcode ); fprintf ( outfile , "%s%s%s" , leftcode , link_flgs , rightcode ); fprintf ( outfile , "%s%s%s" , leftcode , sock_flgs , rightcode ); fprintf ( outfile , "%s%s%s" , leftcode , suid_flgs , rightcode ); | 152365/color.c | SARD | 0 |
void bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) pipe = POPEN ( data , "wb" ); if ( pipe != NULL ) PCLOSE ( pipe ); | 119981/CWE78_OS_Command_Injection__char_listen_socket_popen_33.cpp | SARD | 15 |
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 ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) transit_state_consume_1char ( d , s , pp , match_lens , & mbclen , & follows ); static status_transit_state transit_state_consume_1char(struct dfa *d,state_num s,const unsigned char **pp,int *match_lens,int *mbclen,position_set *pps) int k ; state_num s1 ; state_num s2 ; int * work_mbls ; * mbclen = ( mblen_buf [ * pp - buf_begin ] == 0 ? 1 : mblen_buf [ * pp - buf_begin ] ); s1 = s; for (k = 0; k < *mbclen; k++) s2 = s1; rs = transit_state_singlebyte ( d , s2 , ( * pp ) ++ , & s1 ); if ( match_lens == ( ( void * ) 0 ) && d -> states [ s ] . mbps . nelem != 0 ) work_mbls = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); work_mbls = match_lens; if ( match_lens == ( ( void * ) 0 ) && work_mbls != ( ( void * ) 0 ) ) free ( work_mbls ); | 150889/dfa.c | SARD | 0 |
static void goodG2B() int64_t * data ; data = NULL; data = ( int64_t * ) malloc ( 100 * sizeof ( int64_t ) ); CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int64_t_loop_53b_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int64_t_loop_53b_goodG2BSink(int64_t * data) CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int64_t_loop_53c_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int64_t_loop_53c_goodG2BSink(int64_t * data) CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int64_t_loop_53d_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int64_t_loop_53d_goodG2BSink(int64_t * data) int64_t source [ 100 ] = { 0 } ; size_t i ; for (i = 0; i < 100; i++) data [ i ] = source [ i ]; free ( data ); | 71535/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_int64_t_loop_53d.c | SARD | 0 |
static token parse_bracket_exp() charclass ccl ; memset ( ccl , 0 , sizeof ( ccl ) ); setbit_case_fold_c ( c2 , ccl ); static void setbit_case_fold_c(int b,charclass c) wint_t wc = btowc ( b ) ; if ( wc == 0xffffffffu ) setbit ( b , c ); static void setbit(unsigned int b,charclass c) c [ b / ( 8 * sizeof ( int ) ) ] |= 1 << b % ( 8 * sizeof ( int ) ); if ( case_fold && iswalpha ( wc ) ) setbit_wc ( ( iswupper ( wc ) ? towlower ( wc ) : towupper ( wc ) ) , c ); static _Bool setbit_wc(wint_t wc,charclass c) int b = wctob ( wc ) ; if ( b == - 1 ) setbit ( b , c ); static void setbit(unsigned int b,charclass c) c [ b / ( 8 * sizeof ( int ) ) ] |= 1 << b % ( 8 * sizeof ( int ) ); setbit ( b , c ); static void setbit(unsigned int b,charclass c) c [ b / ( 8 * sizeof ( int ) ) ] |= 1 << b % ( 8 * sizeof ( int ) ); if ( case_fold && ( * __ctype_b_loc ( ) ) [ ( int ) b ] & ( ( unsigned short ) _ISalpha ) ) setbit_c ( ( ( * __ctype_b_loc ( ) ) [ ( int ) b ] & ( ( unsigned short ) _ISupper ) ? tolower ( b ) : toupper ( b ) ) , c ); static void setbit_c(int b,charclass c) if ( __ctype_get_mb_cur_max ( ) > 1 && btowc ( b ) == 0xffffffffu ) setbit ( b , c ); static void setbit(unsigned int b,charclass c) c [ b / ( 8 * sizeof ( int ) ) ] |= 1 << b % ( 8 * sizeof ( int ) ); setbit_case_fold_c ( c , ccl ); static void setbit_case_fold_c(int b,charclass c) wint_t wc = btowc ( b ) ; if ( wc == 0xffffffffu ) setbit ( b , c ); if ( case_fold && iswalpha ( wc ) ) setbit_wc ( ( iswupper ( wc ) ? towlower ( wc ) : towupper ( wc ) ) , c ); setbit ( b , c ); if ( case_fold && ( * __ctype_b_loc ( ) ) [ ( int ) b ] & ( ( unsigned short ) _ISalpha ) ) setbit_c ( ( ( * __ctype_b_loc ( ) ) [ ( int ) b ] & ( ( unsigned short ) _ISupper ) ? tolower ( b ) : toupper ( b ) ) , c ); setbit_case_fold_c ( c , ccl ); static void setbit_case_fold_c(int b,charclass c) wint_t wc = btowc ( b ) ; if ( wc == 0xffffffffu ) setbit ( b , c ); if ( case_fold && iswalpha ( wc ) ) setbit_wc ( ( iswupper ( wc ) ? towlower ( wc ) : towupper ( wc ) ) , c ); setbit ( b , c ); if ( case_fold && ( * __ctype_b_loc ( ) ) [ ( int ) b ] & ( ( unsigned short ) _ISalpha ) ) setbit_c ( ( ( * __ctype_b_loc ( ) ) [ ( int ) b ] & ( ( unsigned short ) _ISupper ) ? tolower ( b ) : toupper ( b ) ) , c ); if ( ! setbit_wc ( wc , ccl ) ) static _Bool setbit_wc(wint_t wc,charclass c) int b = wctob ( wc ) ; if ( b == - 1 ) setbit ( b , c ); if ( ! setbit_wc ( wc , ccl ) ) static _Bool setbit_wc(wint_t wc,charclass c) int b = wctob ( wc ) ; if ( b == - 1 ) setbit ( b , c ); work_mbc -> cset = ( ( equal ( ccl , zeroclass ) ? ( - 1 ) : charclass_index ( ccl ) ) ); static size_t charclass_index(const int s[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) if ( equal ( s , dfa -> charclasses [ i ] ) ) static int equal(const int s1[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],const int s2[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) return memcmp ( s1 , s2 , sizeof ( charclass ) ) == 0 ; copyset ( s , dfa -> charclasses [ i ] ); static void copyset(const int src[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],charclass dst) memcpy ( dst , src , sizeof ( charclass ) ); static int equal(const int s1[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))],const int s2[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) return memcmp ( s1 , s2 , sizeof ( charclass ) ) == 0 ; notset ( ccl ); static void notset(charclass s) s [ i ] = ~s [ i ]; clrbit ( eolbyte , ccl ); static void clrbit(unsigned int b,charclass c) c [ b / ( 8 * sizeof ( int ) ) ] &= ~ ( 1 << b % ( 8 * sizeof ( int ) ) ); return ( CSET + charclass_index ( ccl ) ) ; static size_t charclass_index(const int s[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) if ( equal ( s , dfa -> charclasses [ i ] ) ) copyset ( s , dfa -> charclasses [ i ] ); | 152346/dfa.c | SARD | 0 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 ) | 79361/CWE134_Uncontrolled_Format_String__char_connect_socket_w32_vsnprintf_34.c | SARD | 0 |
int avformat_find_stream_info(AVFormatContext *ic,AVDictionary **options) int i ; int ret ; int read_size ; int j ; AVStream * st ; AVPacket * pkt ; for (i = 0; i < ic -> nb_streams; i++) st = ic -> streams [ i ]; if ( ( st -> codec -> codec_type ) == AVMEDIA_TYPE_VIDEO || ( st -> codec -> codec_type ) == AVMEDIA_TYPE_SUBTITLE ) if ( ! st -> codec -> time_base . num ) st -> codec -> time_base = st -> time_base; if ( ! st -> parser && ! ( ic -> flags & 0x20 ) ) st -> parser = av_parser_init ( ( st -> codec -> codec_id ) ); if ( st -> parser ) if ( ( st -> need_parsing ) == AVSTREAM_PARSE_HEADERS ) st -> parser -> flags |= 0x1; if ( ( st -> need_parsing ) == AVSTREAM_PARSE_FULL_RAW ) st -> parser -> flags |= 0x1000; for (i = 0; i < ic -> nb_streams; i++) ic -> streams [ i ] -> info -> last_dts = ( ( int64_t ) 0x8000000000000000UL ); ic -> streams [ i ] -> info -> fps_first_dts = ( ( int64_t ) 0x8000000000000000UL ); ic -> streams [ i ] -> info -> fps_last_dts = ( ( int64_t ) 0x8000000000000000UL ); read_size = 0; if ( ff_check_interrupt ( & ic -> interrupt_callback ) ) for (i = 0; i < ic -> nb_streams; i++) int fps_analyze_framecount = 20 ; st = ic -> streams [ i ]; if ( ! has_codec_parameters ( st , ( ( void * ) 0 ) ) ) static int has_codec_parameters(AVStream *st,const char **errmsg_ptr) return 0 ; while ( 0 ) if ( ( avctx -> codec_id ) == AV_CODEC_ID_NONE ) return 0 ; while ( 0 ) return 1 ; if ( av_q2d ( st -> time_base ) > 0.0005 ) fps_analyze_framecount *= 2; if ( ic -> fps_probe_size >= 0 ) fps_analyze_framecount = ic -> fps_probe_size; if ( st -> disposition & 0x0400 ) fps_analyze_framecount = 0; if ( tb_unreliable ( st -> codec ) && ! ( st -> r_frame_rate . num && st -> avg_frame_rate . num ) && st -> info -> duration_count < fps_analyze_framecount && ( st -> codec -> codec_type ) == AVMEDIA_TYPE_VIDEO ) static int tb_unreliable(AVCodecContext *c) if ( c -> time_base . den >= 101L * c -> time_base . num || c -> time_base . den < 5L * c -> time_base . num || c -> codec_tag == ( ( const union unaligned_32 * ) "mp4v" ) -> l || ( c -> codec_id ) == AV_CODEC_ID_MPEG2VIDEO || ( c -> codec_id ) == AV_CODEC_ID_H264 ) return 1 ; return 0 ; if ( st -> parser && st -> parser -> parser -> split && ! st -> codec -> extradata ) if ( st -> first_dts == ( ( int64_t ) 0x8000000000000000UL ) && ( ( st -> codec -> codec_type ) == AVMEDIA_TYPE_VIDEO || ( st -> codec -> codec_type ) == AVMEDIA_TYPE_AUDIO ) ) if ( i == ic -> nb_streams ) if ( ! ( ic -> ctx_flags & 0x1 ) ) if ( read_size >= ic -> probesize ) ret = read_frame_internal ( ic , & pkt1 ); if ( ret == - '\v' ) if ( ret < 0 ) if ( ic -> flags & 0x0040 ) pkt = & pkt1; pkt = add_to_pktbuf ( & ic -> packet_buffer , & pkt1 , & ic -> packet_buffer_end ); static AVPacket *add_to_pktbuf(AVPacketList **packet_buffer,AVPacket *pkt,AVPacketList **plast_pktl) AVPacketList * pktl = ( av_mallocz ( sizeof ( AVPacketList ) ) ) ; if ( ! pktl ) return ( ( void * ) 0 ) ; pktl -> pkt = * pkt; return & pktl -> pkt ; if ( ( ret = av_dup_packet ( pkt ) ) < 0 ) read_size += pkt -> size; st = ic -> streams [ pkt -> stream_index ]; if ( pkt -> dts != ( ( int64_t ) 0x8000000000000000UL ) && st -> codec_info_nb_frames > 1 ) if ( st -> info -> fps_last_dts != ( ( int64_t ) 0x8000000000000000UL ) && st -> info -> fps_last_dts >= pkt -> dts ) st -> info -> fps_first_dts = st -> info -> fps_last_dts = ( ( int64_t ) 0x8000000000000000UL ); if ( st -> info -> fps_last_dts != ( ( int64_t ) 0x8000000000000000UL ) && st -> info -> fps_last_dts_idx > st -> info -> fps_first_dts_idx && ( pkt -> dts - st -> info -> fps_last_dts ) / 1000 > ( st -> info -> fps_last_dts - st -> info -> fps_first_dts ) / ( st -> info -> fps_last_dts_idx - st -> info -> fps_first_dts_idx ) ) st -> info -> fps_first_dts = st -> info -> fps_last_dts = ( ( int64_t ) 0x8000000000000000UL ); if ( st -> info -> fps_first_dts == ( ( int64_t ) 0x8000000000000000UL ) ) st -> info -> fps_first_dts = pkt -> dts; st -> info -> fps_first_dts_idx = st -> codec_info_nb_frames; st -> info -> fps_last_dts = pkt -> dts; st -> info -> fps_last_dts_idx = st -> codec_info_nb_frames; if ( st -> codec_info_nb_frames > 1 ) int64_t t = 0 ; if ( st -> time_base . den > 0 ) t = av_rescale_q ( st -> info -> codec_info_duration , st -> time_base , ( ( AVRational ) ( 1 ) , ( 1000000 ) ) ) if ( st -> avg_frame_rate . num > 0 ) t = ( t > av_rescale_q ( ( st -> codec_info_nb_frames ) , av_inv_q ( st -> avg_frame_rate ) , ( ( AVRational ) ( 1 ) , ( 1000000 ) ) ) ? t : av_rescale_q ( ( st -> codec_info_nb_frames ) , av_inv_q ( st -> avg_frame_rate ) , ( ( AVRational ) ( 1 ) , ( 1000000 ) ) ) ) if ( t >= ( ic -> max_analyze_duration ) ) if ( pkt -> duration ) st -> info -> codec_info_duration += ( pkt -> duration ); st -> info -> codec_info_duration_fields += ( ( st -> parser && st -> codec -> ticks_per_frame == 2 ? st -> parser -> repeat_pict + 1 : 2 ) ); int64_t last = st -> info -> last_dts ; if ( pkt -> dts != ( ( int64_t ) 0x8000000000000000UL ) && last != ( ( int64_t ) 0x8000000000000000UL ) && pkt -> dts > last && ( pkt -> dts ) - ( ( uint64_t ) last ) < 9223372036854775807L ) double dts = ( ( is_relative ( pkt -> dts ) ? ( pkt -> dts ) - ( 9223372036854775807L - ( 1L L << 48 ) ) : ( pkt -> dts ) ) ) * av_q2d ( st -> time_base ) int64_t duration = pkt -> dts - last ; if ( ! st -> info -> duration_error ) st -> info -> duration_error = ( av_mallocz ( sizeof ( st -> info -> duration_error [ 0 ] ) * 2 ) ); for (i = 0; i < 60 * 12 + 6; i++) int framerate = get_std_framerate ( i ) ; static int get_std_framerate(int i) if ( i < 60 * 12 ) return ( i + 1 ) * 1001 ; double sdts = dts * framerate / ( 1001 * 12 ) ; for (j = 0; j < 2; j++) int64_t ticks = ( llrint ( sdts + j * 0.5 ) ) ; double error = sdts - ticks + j * 0.5 ; st -> info -> duration_error [ j ] [ 0 ] [ i ] += error; st -> info -> duration_error [ j ] [ 1 ] [ i ] += error * error; st -> info -> duration_count ++; if ( st -> info -> duration_count > 3 && is_relative ( pkt -> dts ) == is_relative ( last ) ) st -> info -> duration_gcd = av_gcd ( st -> info -> duration_gcd , duration ); if ( pkt -> dts != ( ( int64_t ) 0x8000000000000000UL ) ) st -> info -> last_dts = pkt -> dts; if ( st -> parser && st -> parser -> parser -> split && ! st -> codec -> extradata ) int i = ( st -> parser -> parser -> split ) ( st -> codec , ( pkt -> data ) , pkt -> size ) ; if ( i > 0 && i < ( 1 << 28 ) - 16 ) st -> codec -> extradata_size = i; st -> codec -> extradata = ( av_malloc ( ( st -> codec -> extradata_size + 16 ) ) ); if ( ! st -> codec -> extradata ) memcpy ( ( st -> codec -> extradata ) , ( pkt -> data ) , ( st -> codec -> extradata_size ) ); memset ( ( st -> codec -> extradata + i ) , 0 , 16 ); st -> codec_info_nb_frames ++; static int read_frame_internal(AVFormatContext *s,AVPacket *pkt) int got_packet = 0 ; while ( ! got_packet && ! s -> parse_queue ) AVStream * st ; AVPacket cur_pkt ; ret = ff_read_packet ( s , & cur_pkt ); if ( ret < 0 ) st = s -> streams [ cur_pkt . stream_index ]; if ( st -> need_parsing && ! st -> parser && ! ( s -> flags & 0x20 ) ) st -> parser = av_parser_init ( ( st -> codec -> codec_id ) ); if ( ! st -> parser ) st -> need_parsing = AVSTREAM_PARSE_NONE; if ( ( st -> need_parsing ) == AVSTREAM_PARSE_HEADERS ) st -> parser -> flags |= 0x1; if ( ( st -> need_parsing ) == AVSTREAM_PARSE_FULL_ONCE ) st -> parser -> flags |= 0x0002; if ( ( st -> need_parsing ) == AVSTREAM_PARSE_FULL_RAW ) st -> parser -> flags |= 0x1000; if ( ! st -> need_parsing || ! st -> parser ) * pkt = cur_pkt; if ( s -> iformat -> flags & 0x0100 && pkt -> flags & 0x1 && pkt -> dts != ( ( int64_t ) 0x8000000000000000UL ) ) av_add_index_entry ( st , pkt -> pos , pkt -> dts , 0 , 0 , 0x1 ); got_packet = 1; if ( ( st -> discard ) < AVDISCARD_ALL ) if ( ( ret = parse_packet ( s , & cur_pkt , cur_pkt . stream_index ) ) < 0 ) if ( pkt -> flags & 0x1 ) st -> skip_to_keyframe = 0; if ( st -> skip_to_keyframe ) if ( got_packet ) * pkt = cur_pkt; got_packet = 0; int av_add_index_entry(AVStream *st,int64_t pos,int64_t timestamp,int size,int distance,int flags) timestamp = wrap_timestamp ( st , timestamp ); return ff_add_index_entry ( & st -> index_entries , & st -> nb_index_entries , & st -> index_entries_allocated_size , pos , timestamp , size , distance , flags ) ; int ff_add_index_entry(AVIndexEntry **index_entries,int *nb_index_entries,unsigned int *index_entries_allocated_size,int64_t pos,int64_t timestamp,int size,int distance,int flags) AVIndexEntry * entries ; AVIndexEntry * ie ; int index ; if ( ( ( ( unsigned int ) ( * nb_index_entries ) ) + 1 ) >= ( 2147483647 * 2U + 1U ) / sizeof ( AVIndexEntry ) ) if ( timestamp == ( ( int64_t ) 0x8000000000000000UL ) ) entries = ( av_fast_realloc ( ( * index_entries ) , index_entries_allocated_size , ( * nb_index_entries + 1 ) * sizeof ( AVIndexEntry ) ) ); if ( ! entries ) * index_entries = entries; index = ff_index_search_timestamp ( ( * index_entries ) , * nb_index_entries , timestamp , 4 ); if ( index < 0 ) ie = & entries [ index ]; if ( ie -> timestamp != timestamp ) if ( ie -> timestamp <= timestamp ) memmove ( ( entries + index + 1 ) , ( entries + index ) , sizeof ( AVIndexEntry ) * ( * nb_index_entries - index ) ); | 149542/utils.c | SARD | 0 |
static void goodG2B1() int data ; data = - 1; if ( staticReturnsFalse ( ) ) static int staticReturnsFalse() return 0 ; data = 100 - 1; char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) memmove ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 88501/CWE195_Signed_to_Unsigned_Conversion_Error__rand_memmove_08.c | SARD | 0 |
static int transcode_init() int i ; int j ; AVFormatContext * oc ; AVCodecContext * codec ; OutputStream * ost ; InputStream * ist ; for (i = 0; i < nb_input_files; i++) InputFile * ifile = input_files [ i ] ; if ( ifile -> rate_emu ) for (j = 0; j < ifile -> nb_streams; j++) input_streams [ j + ifile -> ist_index ] -> start = av_gettime ( ); for (i = 0; i < nb_output_files; i++) oc = output_files [ i ] -> ctx; if ( ! oc -> nb_streams && ! ( oc -> oformat -> flags & 0x1000 ) ) for (i = 0; i < nb_filtergraphs; i++) if ( ( ret = avfilter_graph_config ( filtergraphs [ i ] -> graph , ( ( void * ) 0 ) ) ) < 0 ) for (i = 0; i < nb_output_streams; i++) AVCodecContext * icodec = ( ( void * ) 0 ) ; ost = output_streams [ i ]; oc = output_files [ ost -> file_index ] -> ctx; ist = get_input_stream ( ost ); static InputStream *get_input_stream(OutputStream *ost) if ( ost -> source_index >= 0 ) return input_streams [ ost -> source_index ] ; return ( ( void * ) 0 ) ; if ( ost -> attachment_filename ) codec = ost -> st -> codec; if ( ist ) icodec = ist -> st -> codec; ost -> st -> disposition = ist -> st -> disposition; codec -> bits_per_raw_sample = icodec -> bits_per_raw_sample; codec -> chroma_sample_location = icodec -> chroma_sample_location; if ( ost -> stream_copy ) uint64_t extra_size ; extra_size = ( ( uint64_t ) ( icodec -> extradata_size ) ) + 16; if ( extra_size > 2147483647 ) codec -> codec_id = icodec -> codec_id; codec -> codec_type = icodec -> codec_type; if ( ! codec -> codec_tag ) unsigned int codec_tag ; if ( ! oc -> oformat -> codec_tag || ( av_codec_get_id ( oc -> oformat -> codec_tag , icodec -> codec_tag ) ) == ( codec -> codec_id ) || ! av_codec_get_tag2 ( oc -> oformat -> codec_tag , icodec -> codec_id , & codec_tag ) ) codec -> codec_tag = icodec -> codec_tag; codec -> bit_rate = icodec -> bit_rate; codec -> rc_max_rate = icodec -> rc_max_rate; codec -> rc_buffer_size = icodec -> rc_buffer_size; codec -> field_order = icodec -> field_order; codec -> extradata = ( av_mallocz ( extra_size ) ); if ( ! codec -> extradata ) memcpy ( ( codec -> extradata ) , ( icodec -> extradata ) , ( icodec -> extradata_size ) ); codec -> extradata_size = icodec -> extradata_size; codec -> bits_per_coded_sample = icodec -> bits_per_coded_sample; codec -> time_base = ist -> st -> time_base; if ( ! strcmp ( oc -> oformat -> name , "avi" ) ) if ( copy_tb < 0 && av_q2d ( ist -> st -> r_frame_rate ) >= av_q2d ( ist -> st -> avg_frame_rate ) && 0.5 / av_q2d ( ist -> st -> r_frame_rate ) > av_q2d ( ist -> st -> time_base ) && 0.5 / av_q2d ( ist -> st -> r_frame_rate ) > av_q2d ( icodec -> time_base ) && av_q2d ( ist -> st -> time_base ) < 1.0 / 500 && av_q2d ( icodec -> time_base ) < 1.0 / 500 || copy_tb == 2 ) codec -> time_base . num = ist -> st -> r_frame_rate . den; codec -> time_base . den = 2 * ist -> st -> r_frame_rate . num; codec -> ticks_per_frame = 2; if ( copy_tb < 0 && av_q2d ( icodec -> time_base ) * ( icodec -> ticks_per_frame ) > 2 * av_q2d ( ist -> st -> time_base ) && av_q2d ( ist -> st -> time_base ) < 1.0 / 500 || copy_tb == 0 ) codec -> time_base = icodec -> time_base; codec -> time_base . num *= icodec -> ticks_per_frame; codec -> time_base . den *= 2; codec -> ticks_per_frame = 2; if ( ! ( oc -> oformat -> flags & 0002000 ) && strcmp ( oc -> oformat -> name , "mov" ) && strcmp ( oc -> oformat -> name , "mp4" ) && strcmp ( oc -> oformat -> name , "3gp" ) && strcmp ( oc -> oformat -> name , "3g2" ) && strcmp ( oc -> oformat -> name , "psp" ) && strcmp ( oc -> oformat -> name , "ipod" ) && strcmp ( oc -> oformat -> name , "f4v" ) ) if ( copy_tb < 0 && icodec -> time_base . den && av_q2d ( icodec -> time_base ) * ( icodec -> ticks_per_frame ) > av_q2d ( ist -> st -> time_base ) && av_q2d ( ist -> st -> time_base ) < 1.0 / 500 || copy_tb == 0 ) codec -> time_base = icodec -> time_base; codec -> time_base . num *= icodec -> ticks_per_frame; codec -> time_base = icodec -> time_base; if ( ost -> frame_rate . num ) codec -> time_base = av_inv_q ( ost -> frame_rate ); switch ( codec -> codec_type ) codec -> channel_layout = icodec -> channel_layout; codec -> sample_rate = icodec -> sample_rate; codec -> channels = icodec -> channels; codec -> frame_size = icodec -> frame_size; codec -> audio_service_type = icodec -> audio_service_type; codec -> block_align = icodec -> block_align; if ( ( codec -> block_align == 1 || codec -> block_align == 1152 || codec -> block_align == 576 ) && ( codec -> codec_id ) == AV_CODEC_ID_MP3 ) codec -> block_align = 0; if ( ( codec -> codec_id ) == AV_CODEC_ID_AC3 ) codec -> block_align = 0; codec -> pix_fmt = icodec -> pix_fmt; codec -> width = icodec -> width; codec -> height = icodec -> height; codec -> has_b_frames = icodec -> has_b_frames; if ( ! codec -> sample_aspect_ratio . num ) codec -> sample_aspect_ratio = ost -> st -> sample_aspect_ratio = ( ist -> st -> sample_aspect_ratio . num ? ist -> st -> sample_aspect_ratio : ( ( ist -> st -> codec -> sample_aspect_ratio . num ? ist -> st -> codec -> sample_aspect_ratio : ( ( AVRational ) ( 0 ) , ( 1 ) ) ) ) ) ost -> st -> avg_frame_rate = ist -> st -> avg_frame_rate; codec -> width = icodec -> width; codec -> height = icodec -> height; if ( ! ost -> enc ) ost -> enc = avcodec_find_encoder ( codec -> codec_id ); if ( ! ost -> enc ) ret = - 22; if ( ist ) ist -> decoding_needed ++; ost -> encoding_needed = 1; if ( ( codec -> codec_type ) == AVMEDIA_TYPE_VIDEO ) if ( ost -> filter && ! ost -> frame_rate . num ) ost -> frame_rate = av_buffersink_get_frame_rate ( ost -> filter -> filter ); if ( ist && ! ost -> frame_rate . num ) ost -> frame_rate = ist -> framerate; if ( ist && ! ost -> frame_rate . num ) ost -> frame_rate = ( ist -> st -> r_frame_rate . num ? ist -> st -> r_frame_rate : ( ( AVRational ) ( 25 ) , ( 1 ) ) ) if ( ost -> enc && ost -> enc -> supported_framerates && ! ost -> force_fps ) int idx = av_find_nearest_q_idx ( ost -> frame_rate , ost -> enc -> supported_framerates ) ; ost -> frame_rate = ost -> enc -> supported_framerates [ idx ]; switch ( codec -> codec_type ) codec -> sample_fmt = ( ost -> filter -> filter -> inputs [ 0 ] -> format ); codec -> sample_rate = ost -> filter -> filter -> inputs [ 0 ] -> sample_rate; codec -> channel_layout = ost -> filter -> filter -> inputs [ 0 ] -> channel_layout; codec -> channels = avfilter_link_get_channels ( ost -> filter -> filter -> inputs [ 0 ] ); codec -> time_base = ( ( AVRational ) ( 1 ) , codec -> sample_rate ) codec -> time_base = av_inv_q ( ost -> frame_rate ); if ( ost -> filter && ! ( codec -> time_base . num && codec -> time_base . den ) ) codec -> time_base = ost -> filter -> filter -> inputs [ 0 ] -> time_base; codec -> width = ost -> filter -> filter -> inputs [ 0 ] -> w; codec -> height = ost -> filter -> filter -> inputs [ 0 ] -> h; codec -> sample_aspect_ratio = ost -> st -> sample_aspect_ratio = ( ost -> frame_aspect_ratio ? av_d2q ( ( ost -> frame_aspect_ratio * ( codec -> height ) / ( codec -> width ) ) , 255 ) : ost -> filter -> filter -> inputs [ 0 ] -> sample_aspect_ratio ); codec -> pix_fmt = ( ost -> filter -> filter -> inputs [ 0 ] -> format ); if ( ! icodec || codec -> width != icodec -> width || codec -> height != icodec -> height || ( codec -> pix_fmt ) != ( icodec -> pix_fmt ) ) codec -> bits_per_raw_sample = frame_bits_per_raw_sample; if ( ost -> forced_keyframes ) if ( ! strncmp ( ( ost -> forced_keyframes ) , "expr:" , 5 ) ) ret = av_expr_parse ( & ost -> forced_keyframes_pexpr , ( ost -> forced_keyframes + 5 ) , forced_keyframes_const_names , ( ( void * ) 0 ) , ( ( void * ) 0 ) , ( ( void * ) 0 ) , ( ( void * ) 0 ) , 0 , ( ( void * ) 0 ) ); if ( ret < 0 ) ost -> forced_keyframes_expr_const_values [ FKF_N ] = 0; ost -> forced_keyframes_expr_const_values [ FKF_N_FORCED ] = 0; ost -> forced_keyframes_expr_const_values [ FKF_PREV_FORCED_N ] = ( __builtin_nanf ( "" ) ); ost -> forced_keyframes_expr_const_values [ FKF_PREV_FORCED_T ] = ( __builtin_nanf ( "" ) ); codec -> time_base = ( ( AVRational ) ( 1 ) , ( 1000 ) ) if ( ! codec -> width ) codec -> width = input_streams [ ost -> source_index ] -> st -> codec -> width; codec -> height = input_streams [ ost -> source_index ] -> st -> codec -> height; if ( codec -> flags & ( 0x0200 | 0002000 ) ) char logfilename [ 1024 ] ; FILE * f ; snprintf ( logfilename , sizeof ( logfilename ) , "%s-%d.log" , ( ost -> logfile_prefix ? ost -> logfile_prefix : "ffmpeg2pass" ) , i ); if ( ! strcmp ( ost -> enc -> name , "libx264" ) ) if ( codec -> flags & 0002000 ) char * logbuffer ; codec -> stats_in = logbuffer; if ( codec -> flags & 0x0200 ) f = fopen ( logfilename , "wb" ); ost -> logfile = f; | 149790/ffmpeg.c | SARD | 0 |
static void goodB2G() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( wchar_t ) ] = L '\0' while ( 0 ) CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_connect_socket_82_base * baseObject = new CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_connect_socket_82_goodB2G baseObject -> action ( data ); void CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_connect_socket_82_goodB2G::action(wchar_t * data) size_t i ; for (i=0; i < wcslen(data); i++) if ( data [ i ] == SEARCH_CHAR ) | 112852/CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_connect_socket_82_goodB2G.cpp | SARD | 0 |
void CWE690_NULL_Deref_From_Return__char_calloc_34_bad() char * data ; CWE690_NULL_Deref_From_Return__char_calloc_34_unionType myUnion ; data = NULL; data = ( char * ) calloc ( 20 , sizeof ( char ) ); myUnion . unionFirst = data; char * data = myUnion . unionSecond ; strcpy ( data , "Initialize" ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 111001/CWE690_NULL_Deref_From_Return__char_calloc_34.c | SARD | 2 |
static void good1() if ( globalReturnsFalse ( ) ) int globalReturnsFalse() return 0 ; WSADATA wsaData ; struct sockaddr_in service ; char username [ USERNAME_SIZE + 1 ] ; if ( 0 != WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) ) listenSocket = socket ( PF_INET , SOCK_STREAM , 0 ); 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 ( LISTEN_PORT ); if ( SOCKET_ERROR == bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) ) if ( SOCKET_ERROR == listen ( listenSocket , LISTEN_BACKLOG ) ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == INVALID_SOCKET ) if ( sizeof ( username ) - sizeof ( char ) != recv ( acceptSocket , username , sizeof ( username ) - sizeof ( char ) , 0 ) ) while ( 0 ) | 89482/CWE222_Truncation_of_Security_Relevant_Information__w32_11.c | SARD | 0 |
void CWE121_Stack_Based_Buffer_Overflow__dest_char_alloca_cat_05_bad() char * data ; char * dataBadBuffer = ( char * ) ALLOCA ( 50 * sizeof ( char ) ) ; if ( staticTrue ) data = dataBadBuffer; data [ 0 ] = '\0'; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcat ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 66668/CWE121_Stack_Based_Buffer_Overflow__dest_char_alloca_cat_05.c | SARD | 3 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; if ( 1 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 96595/CWE36_Absolute_Path_Traversal__char_listen_socket_ofstream_02.cpp | SARD | 0 |
static void goodB2G2() size_t data ; data = 0; if ( STATIC_CONST_TRUE ) data = rand ( ); if ( STATIC_CONST_TRUE ) char * myString ; if ( data > strlen ( HELLO_STRING ) && data < 100 ) myString = ( char * ) malloc ( data * sizeof ( char ) ); strcpy ( myString , HELLO_STRING ); printLine ( myString ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( myString ); | 117178/CWE789_Uncontrolled_Mem_Alloc__malloc_char_rand_04.c | SARD | 0 |
static int stonesoup_ev_handler(struct mg_connection *conn, enum mg_event ev) char * ifmatch_header ; char * stonesoup_tainted_buff ; int buffer_size = 1000 ; if ( ev == MG_REQUEST ) ifmatch_header = ( char * ) mg_get_header ( conn , "if-match" ); if ( strcmp ( ifmatch_header , "weak_taint_source_value" ) == 0 ) while ( 1 ) stonesoup_tainted_buff = ( char * ) malloc ( buffer_size * sizeof ( char ) ); data_size = mg_get_var ( conn , "data" , stonesoup_tainted_buff , buffer_size * sizeof ( char ) ); if ( data_size < buffer_size ) buffer_size = buffer_size * 2; stonesoup_handle_taint ( stonesoup_tainted_buff ); void stonesoup_handle_taint(char *klino_fractiously) int stonesoup_oc_i = 0 ; int stonesoup_ptr_deref ; char * ( * simpled_unpunctual ) [ 4 ] = 0; char * sheetfed_trituration [ 4 ] = { 0 } ; if ( klino_fractiously != 0 ) sheetfed_trituration [ 1 ] = klino_fractiously; simpled_unpunctual = & sheetfed_trituration; unlibidinously_osmolal = ( ( char * ) ( * simpled_unpunctual ) [ 1 ] ); stonesoup_data = ( struct stonesoup_struct * ) malloc ( sizeof ( struct stonesoup_struct ) ); if ( stonesoup_data != NULL ) stonesoup_data -> buff_pointer = stonesoup_data -> buffer; strncpy ( stonesoup_data -> buffer , unlibidinously_osmolal , strlen ( unlibidinously_osmolal ) + 1 ); stonesoup_ptr_deref = strlen ( stonesoup_data -> buff_pointer ); for (; stonesoup_oc_i < stonesoup_ptr_deref; ++stonesoup_oc_i) stonesoup_data -> buffer [ stonesoup_oc_i ] = stonesoup_toupper ( stonesoup_data -> buffer [ stonesoup_oc_i ] ); int stonesoup_toupper(int c) if ( c >= 97 && c <= 122 ) return c - 32 ; return c ; free ( stonesoup_data ); | 153569/column-utils.c | SARD | 3 |
void goodG2BSink(char * dataArray[]) char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memcpy ( dest , data , strlen ( dest ) * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 76608/CWE126_Buffer_Overread__new_char_memcpy_66b.cpp | SARD | 0 |
static dissect_catapult_dct2000(tvbuff_t *tvb, packet_info *pinfo, proto_tree *tree) gint offset = 0 ; gint context_length ; gint protocol_length ; gint timestamp_length ; gint variant_length ; gint outhdr_length ; int encap ; dissector_handle_t protocol_handle = 0 ; const char * protocol_name ; offset += context_length; offset ++; offset += timestamp_length; protocol_name = tvb_get_const_stringz ( tvb , offset , & protocol_length ); offset += protocol_length; offset += variant_length; offset += outhdr_length; offset ++; encap = tvb_get_guint8 ( tvb , offset ); offset ++; if ( ( strcmp ( protocol_name , "fp" ) == 0 ) || ( strncmp ( protocol_name , "fp_r" , 4 ) == 0 ) || ( strcmp ( protocol_name , "fpiur_r5" ) == 0 ) ) if ( ( strcmp ( protocol_name , "rlc" ) == 0 ) || ( strcmp ( protocol_name , "rlc_r4" ) == 0 ) || ( strcmp ( protocol_name , "rlc_r5" ) == 0 ) || ( strcmp ( protocol_name , "rlc_r6" ) == 0 ) || ( strcmp ( protocol_name , "rlc_r7" ) == 0 ) || ( strcmp ( protocol_name , "rlc_r8" ) == 0 ) || ( strcmp ( protocol_name , "rlc_r9" ) == 0 ) ) if ( ( strcmp ( protocol_name , "mac_r8_lte" ) == 0 ) || ( strcmp ( protocol_name , "mac_r9_lte" ) == 0 ) || ( strcmp ( protocol_name , "mac_r10_lte" ) == 0 ) ) if ( ( strcmp ( protocol_name , "rlc_r8_lte" ) == 0 ) || ( strcmp ( protocol_name , "rlc_r9_lte" ) == 0 ) || ( strcmp ( protocol_name , "rlc_r10_lte" ) == 0 ) ) if ( ( strcmp ( protocol_name , "pdcp_r8_lte" ) == 0 ) || ( strcmp ( protocol_name , "pdcp_r9_lte" ) == 0 ) || ( strcmp ( protocol_name , "pdcp_r10_lte" ) == 0 ) ) if ( ( strcmp ( protocol_name , "nas_rrc_r8_lte" ) == 0 ) || ( strcmp ( protocol_name , "nas_rrc_r9_lte" ) == 0 ) || ( strcmp ( protocol_name , "nas_rrc_r10_lte" ) == 0 ) ) gboolean nas_body_found = TRUE ; guint8 opcode = tvb_get_guint8 ( tvb , offset ) ; switch ( opcode ) nas_body_found = FALSE; if ( nas_body_found ) protocol_handle = find_dissector ( "nas-eps" ); switch ( encap ) protocol_handle = find_dissector ( "ip" ); protocol_handle = find_dissector ( "eth_withoutfcs" ); protocol_handle = find_dissector ( "lapd" ); protocol_handle = find_dissector ( "atm_untruncated" ); protocol_handle = find_dissector ( "ppp_hdlc" ); protocol_handle = find_dissector ( "sscop" ); protocol_handle = find_dissector ( "fr" ); protocol_handle = find_dissector ( "mtp2" ); protocol_handle = find_dissector ( "nbap" ); if ( ( strcmp ( protocol_name , "rlc" ) == 0 ) || ( strcmp ( protocol_name , "rlc_r4" ) == 0 ) || ( strcmp ( protocol_name , "rlc_r5" ) == 0 ) || ( strcmp ( protocol_name , "rlc_r6" ) == 0 ) || ( strcmp ( protocol_name , "rlc_r7" ) == 0 ) || ( strcmp ( protocol_name , "rlc_r8" ) == 0 ) || ( strcmp ( protocol_name , "rlc_r9" ) == 0 ) ) if ( ( strcmp ( protocol_name , "mac_r8_lte" ) == 0 ) || ( strcmp ( protocol_name , "mac_r9_lte" ) == 0 ) || ( strcmp ( protocol_name , "mac_r10_lte" ) == 0 ) ) protocol_handle = mac_lte_handle; if ( ( strcmp ( protocol_name , "rlc_r8_lte" ) == 0 ) || ( strcmp ( protocol_name , "rlc_r9_lte" ) == 0 ) || ( strcmp ( protocol_name , "rlc_r10_lte" ) == 0 ) ) protocol_handle = rlc_lte_handle; if ( ( strcmp ( protocol_name , "pdcp_r8_lte" ) == 0 ) || ( strcmp ( protocol_name , "pdcp_r9_lte" ) == 0 ) || ( strcmp ( protocol_name , "pdcp_r10_lte" ) == 0 ) ) if ( strcmp ( protocol_name , "xml" ) == 0 ) protocol_handle = find_dissector ( "xml" ); if ( strcmp ( protocol_name , "tty" ) == 0 ) if ( strcmp ( protocol_name , "sipprim" ) == 0 ) protocol_handle = find_dissector ( "sipprim" ); if ( strcmp ( protocol_name , "comment" ) == 0 ) if ( strcmp ( protocol_name , "sprint" ) == 0 ) if ( catapult_dct2000_dissect_lte_rrc && ( ( strcmp ( protocol_name , "rrc_r8_lte" ) == 0 ) || ( strcmp ( protocol_name , "rrcpdcpprim_r8_lte" ) == 0 ) || ( strcmp ( protocol_name , "rrc_r9_lte" ) == 0 ) || ( strcmp ( protocol_name , "rrcpdcpprim_r9_lte" ) == 0 ) || ( strcmp ( protocol_name , "rrc_r10_lte" ) == 0 ) ) ) if ( ( strcmp ( protocol_name , "ccpri_r8_lte" ) == 0 ) || ( strcmp ( protocol_name , "ccpri_r9_lte" ) == 0 ) ) if ( ! protocol_handle && catapult_dct2000_try_ipprim_heuristic ) heur_protocol_handle = look_for_dissector ( protocol_name ); static dissector_handle_t look_for_dissector(const char *protocol_name) if ( strcmp ( protocol_name , "tbcp" ) == 0 ) if ( strncmp ( protocol_name , "diameter" , strlen ( "diameter" ) ) == 0 ) if ( ( strcmp ( protocol_name , "xcap_caps" ) == 0 ) || ( strcmp ( protocol_name , "soap" ) == 0 ) || ( strcmp ( protocol_name , "mm1" ) == 0 ) || ( strcmp ( protocol_name , "mm3" ) == 0 ) || ( strcmp ( protocol_name , "mm7" ) == 0 ) ) if ( ( strcmp ( protocol_name , "fp" ) == 0 ) || ( strncmp ( protocol_name , "fp_r" , 4 ) == 0 ) || ( strcmp ( protocol_name , "fpiur_r5" ) == 0 ) ) if ( ( strcmp ( protocol_name , "iuup_rtp_r5" ) == 0 ) || ( strcmp ( protocol_name , "iuup_rtp_r6" ) == 0 ) ) if ( strcmp ( protocol_name , "sipt" ) == 0 ) if ( strncmp ( protocol_name , "nbap_sctp" , strlen ( "nbap_sctp" ) ) == 0 ) if ( strncmp ( protocol_name , "gtp" , strlen ( "gtp" ) ) == 0 ) if ( strcmp ( protocol_name , "dhcpv4" ) == 0 ) if ( strcmp ( protocol_name , "wimax" ) == 0 ) if ( strncmp ( protocol_name , "sabp" , strlen ( "sabp" ) ) == 0 ) if ( strcmp ( protocol_name , "wtp" ) == 0 ) if ( catapult_dct2000_dissect_lte_s1ap && strncmp ( protocol_name , "s1ap" , strlen ( "s1ap" ) ) == 0 ) if ( ( strncmp ( protocol_name , "x2ap_r8_lte" , strlen ( "x2ap_r8_lte" ) ) == 0 ) || ( strncmp ( protocol_name , "x2ap_r9_lte" , strlen ( "x2ap_r9_lte" ) ) == 0 ) ) if ( ( strcmp ( protocol_name , "gtpv2_r8_lte" ) == 0 ) || ( strcmp ( protocol_name , "gtpv2_r9_lte" ) == 0 ) ) | CVE-2016-7179/Wireshark_2.0.5_CVE_2016_7179_epan_dissectors_packet-catapult-dct2000.c | NVD | 0 |
static void goodG2B2() char * data ; char * dataGoodBuffer = ( char * ) ALLOCA ( ( 10 + 1 ) * sizeof ( char ) ) ; if ( 1 ) data = dataGoodBuffer; data [ 0 ] = '\0'; char source [ 10 + 1 ] = SRC_STRING ; memcpy ( data , source , ( strlen ( source ) + 1 ) * sizeof ( char ) ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 63113/CWE121_Stack_Based_Buffer_Overflow__CWE193_char_alloca_memcpy_02.c | SARD | 0 |
void CWE197_Numeric_Truncation_Error__int_listen_socket_to_char_53_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 ) CWE197_Numeric_Truncation_Error__int_listen_socket_to_char_53b_badSink ( data ); void CWE197_Numeric_Truncation_Error__int_listen_socket_to_char_53b_badSink(int data) CWE197_Numeric_Truncation_Error__int_listen_socket_to_char_53c_badSink ( data ); void CWE197_Numeric_Truncation_Error__int_listen_socket_to_char_53c_badSink(int data) CWE197_Numeric_Truncation_Error__int_listen_socket_to_char_53d_badSink ( data ); void CWE197_Numeric_Truncation_Error__int_listen_socket_to_char_53d_badSink(int data) char charData = ( char ) data ; printHexCharLine ( charData ); void printHexCharLine (char charHex) printf ( "%02x\n" , charHex ); | 89023/CWE197_Numeric_Truncation_Error__int_listen_socket_to_char_53a.c | SARD | 0 |
static void *skinny_session(void *data) int res ; struct skinny_req * req ; struct skinnysession * s = data ; res = get_input ( s ); static int get_input(struct skinnysession *s) int res ; int timeout = keep_alive * 1100 ; time_t now ; int * bufaddr ; struct pollfd fds [ 1 ] ; if ( ! s -> device ) if ( time ( & now ) == - 1 ) return - 1 ; timeout = ( auth_timeout - ( now - s -> start ) ) * 1000; if ( timeout < 0 ) return - 1 ; fds [ 0 ] . fd = s -> fd; fds [ 0 ] . events = POLLIN; fds [ 0 ] . revents = 0; res = ast_poll ( fds , 1 , timeout ); if ( res < 0 ) if ( errno != EINTR ) return res ; if ( res == 0 ) return - 1 ; if ( fds [ 0 ] . revents ) memset ( s -> inbuf , 0 , sizeof ( s -> inbuf ) ); res = read ( s -> fd , s -> inbuf , 4 ); if ( res < 0 ) return res ; if ( res != 4 ) return - 1 ; bufaddr = ( int * ) s -> inbuf; dlen = letohl ( * bufaddr ); if ( dlen < 4 ) return - 1 ; if ( dlen + 8 > sizeof ( s -> inbuf ) ) dlen = sizeof ( s -> inbuf ) - 8; res = read ( s -> fd , s -> inbuf + 4 , dlen + 4 ); if ( res < 0 ) return res ; if ( res != ( dlen + 4 ) ) return - 1 ; return res ; return 0 ; if ( res < 0 ) if ( res > 0 ) if ( ! ( req = skinny_req_parse ( s ) ) ) static struct skinny_req *skinny_req_parse(struct skinnysession *s) struct skinny_req * req ; int * bufaddr ; if ( ! ( req = ast_calloc ( 1 , SKINNY_MAX_PACKET ) ) ) return NULL ; memcpy ( req , s -> inbuf , skinny_header_size ); bufaddr = ( int * ) ( s -> inbuf ); memcpy ( & req -> data , s -> inbuf + skinny_header_size , letohl ( * bufaddr ) - 4 ); if ( letohl ( req -> e ) < 0 ) return NULL ; return req ; res = handle_message ( req , s ); if ( res < 0 ) static int handle_message(struct skinny_req *req, struct skinnysession *s) if ( ( ! s -> device ) && ( letohl ( req -> e ) != REGISTER_MESSAGE && letohl ( req -> e ) != ALARM_MESSAGE ) ) switch ( letohl ( req -> e ) ) struct skinny_device * d = s -> device ; struct skinny_subchannel * sub ; int lineInstance ; int callReference ; lineInstance = letohl ( req -> data . keypad . lineInstance ); callReference = letohl ( req -> data . keypad . callReference ); if ( lineInstance ) sub = find_subchannel_by_instance_reference ( d , lineInstance , callReference ); static struct skinny_subchannel *find_subchannel_by_instance_reference(struct skinny_device *d, int instance, int reference) struct skinny_line * l = find_line_by_instance ( d , instance ) ; static struct skinny_line *find_line_by_instance(struct skinny_device *d, int instance) struct skinny_line * l ; return l ; struct skinny_subchannel * sub ; if ( ! l ) return NULL ; if ( ! reference ) sub = AST_LIST_FIRST ( & l -> sub ); return sub ; sub = d -> activeline -> activesub; if ( sub && ( ( sub -> owner && sub -> owner -> _state < AST_STATE_UP ) || sub -> substate == SUBSTATE_HOLD ) ) char dgt ; int digit = letohl ( req -> data . keypad . button ) ; if ( digit == 14 ) dgt = '*'; if ( digit == 15 ) dgt = '#'; if ( digit >= 0 && digit <= 9 ) dgt = '0' + digit; dgt = '0' + digit; sub -> exten [ strlen ( sub -> exten ) ] = dgt; sub -> exten [ strlen ( sub -> exten ) + 1 ] = '\0'; | 148809/chan_skinny.c | SARD | 0 |
static void goodG2B() char * data ; char * & dataRef = data ; data = NULL; char * dataBuffer = new char [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; char * data = dataRef ; char dest [ 100 * 2 ] ; memset ( dest , 'C' , 100 * 2 - 1 ); dest [ 100 * 2 - 1 ] = '\0'; strcpy ( dest , data ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 78240/CWE127_Buffer_Underread__new_char_cpy_33.cpp | SARD | 0 |
static void goodB2G() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) fclose ( pFile ); | 81470/CWE134_Uncontrolled_Format_String__wchar_t_file_printf_31.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__char_type_overrun_memmove_16_bad() while ( 1 ) charVoid * structCharVoid = ( charVoid * ) malloc ( sizeof ( charVoid ) ) ; structCharVoid -> voidSecond = ( void * ) SRC_STR; memmove ( structCharVoid -> charFirst , SRC_STR , sizeof ( * structCharVoid ) ); structCharVoid -> charFirst [ ( sizeof ( structCharVoid -> charFirst ) / sizeof ( char ) ) - 1 ] = '\0'; printLine ( ( char * ) structCharVoid -> charFirst ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); printLine ( ( char * ) structCharVoid -> voidSecond ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 67517/CWE122_Heap_Based_Buffer_Overflow__char_type_overrun_memmove_16.c | SARD | 3 |
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 ); static int get_input_packet(InputFile *f,AVPacket *pkt) if ( nb_input_files > 1 ) return get_input_packet_mt ( f , pkt ) ; static int get_input_packet_mt(InputFile *f,AVPacket *pkt) int ret = 0 ; if ( av_fifo_size ( f -> fifo ) ) if ( f -> finished ) ret = - ( ( int ) ( ( 'E' | 'O' << 8 | 'F' << 16 ) | ( ( unsigned int ) 32 ) << 24 ) ); ret = - 11; return ret ; return av_read_frame ( f -> ctx , 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 i ; 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; if ( ! ist -> decoding_needed ) ist -> dts = ist -> next_dts; switch ( ist -> st -> codec -> codec_type ) ist -> next_dts += ( ( int64_t ) 1000000 ) * ( ist -> st -> codec -> frame_size ) / ( ist -> st -> codec -> sample_rate ); if ( pkt -> duration ) if ( ist -> st -> codec -> time_base . num != 0 ) int ticks = ist -> st -> parser ? ist -> st -> parser -> repeat_pict + 1 : ist -> st -> codec -> ticks_per_frame ; ist -> next_dts += ( ( int64_t ) 1000000 ) * ist -> st -> codec -> time_base . num * ticks / ist -> st -> codec -> time_base . den; ist -> pts = ist -> dts; ist -> next_pts = ist -> next_dts; for (i = 0; pkt && i < nb_output_streams; i++) OutputStream * ost = output_streams [ i ] ; if ( ! check_output_constraints ( ist , ost ) || ost -> encoding_needed ) do_streamcopy ( ist , ost , pkt ); static void do_streamcopy(InputStream *ist,OutputStream *ost,const AVPacket *pkt) OutputFile * of = output_files [ ost -> file_index ] ; int64_t ost_tb_start_time = av_rescale_q ( of -> start_time , ( ( AVRational ) ( 1 ) , ( 1000000 ) ) , ost -> st -> time_base ) AVPacket opkt ; if ( ! ost -> frame_number && ! ( pkt -> flags & 0000001 ) && ! ost -> copy_initial_nonkeyframes ) if ( ! ost -> frame_number && ist -> pts < of -> start_time && ! ost -> copy_prior_start ) if ( of -> recording_time != 9223372036854775807L && ist -> pts >= of -> recording_time + of -> start_time ) if ( ( ost -> st -> codec -> codec_type ) == AVMEDIA_TYPE_AUDIO ) if ( ( ost -> st -> codec -> codec_type ) == AVMEDIA_TYPE_VIDEO ) ost -> sync_opts ++; if ( pkt -> pts != ( ( int64_t ) 0x8000000000000000UL ) ) opkt . pts = av_rescale_q ( pkt -> pts , ist -> st -> time_base , ost -> st -> time_base ) - ost_tb_start_time; opkt . pts = ( ( int64_t ) 0x8000000000000000UL ); if ( pkt -> dts == ( ( int64_t ) 0x8000000000000000UL ) ) opkt . dts = av_rescale_q ( ist -> dts , ( ( AVRational ) ( 1 ) , ( 1000000 ) ) , ost -> st -> time_base ) opkt . dts = av_rescale_q ( pkt -> dts , ist -> st -> time_base , ost -> st -> time_base ); opkt . dts -= ost_tb_start_time; if ( ( ost -> st -> codec -> codec_type ) == AVMEDIA_TYPE_AUDIO && pkt -> dts != ( ( int64_t ) 0x8000000000000000UL ) ) opkt . dts = opkt . pts = av_rescale_delta ( ist -> st -> time_base , pkt -> dts , ( ( AVRational ) ( 1 ) , ist -> st -> codec -> sample_rate ) , duration , & ist -> filter_in_rescale_delta_last , ost -> st -> time_base ) - ost_tb_start_time opkt . duration = ( av_rescale_q ( ( pkt -> duration ) , ist -> st -> time_base , ost -> st -> time_base ) ); opkt . flags = pkt -> flags; if ( ( ost -> st -> codec -> codec_id ) != AV_CODEC_ID_H264 && ( ost -> st -> codec -> codec_id ) != AV_CODEC_ID_MPEG1VIDEO && ( ost -> st -> codec -> codec_id ) != AV_CODEC_ID_MPEG2VIDEO && ( ost -> st -> codec -> codec_id ) != AV_CODEC_ID_VC1 ) if ( av_parser_change ( ist -> st -> parser , ost -> st -> codec , & opkt . data , & opkt . size , ( pkt -> data ) , pkt -> size , pkt -> flags & 0000001 ) ) opkt . destruct = av_destruct_packet; opkt . data = pkt -> data; opkt . size = pkt -> size; if ( ( ost -> st -> codec -> codec_type ) == AVMEDIA_TYPE_VIDEO && of -> ctx -> oformat -> flags & 0x20 ) opkt . data = ( ( uint8_t * ) ( & pict ) ); opkt . size = ( sizeof ( AVPicture ) ); opkt . flags |= 0000001; write_frame ( of -> ctx , & opkt , ost ); static void write_frame(AVFormatContext *s,AVPacket *pkt,OutputStream *ost) AVBitStreamFilterContext * bsfc = ost -> bitstream_filters ; AVCodecContext * avctx = ost -> st -> codec ; if ( ( avctx -> codec_type ) == AVMEDIA_TYPE_VIDEO && video_sync_method == 0xFF || ( avctx -> codec_type ) == AVMEDIA_TYPE_AUDIO && audio_sync_method < 0 ) pkt -> pts = pkt -> dts = ( ( int64_t ) 0x8000000000000000UL ); if ( ( ( avctx -> codec_type ) == AVMEDIA_TYPE_AUDIO || ( avctx -> codec_type ) == AVMEDIA_TYPE_VIDEO ) && pkt -> dts != ( ( int64_t ) 0x8000000000000000UL ) ) int64_t max = ost -> st -> cur_dts + ( ! ( s -> oformat -> flags & 0x8020000 ) ) ; if ( ost -> st -> cur_dts && ost -> st -> cur_dts != ( ( int64_t ) 0x8000000000000000UL ) && max > pkt -> dts ) if ( pkt -> pts >= pkt -> dts ) pkt -> pts = ( pkt -> pts > max ? pkt -> pts : max ); pkt -> dts = max; if ( ! ( ( avctx -> codec_type ) == AVMEDIA_TYPE_VIDEO && avctx -> codec ) ) if ( ( ost -> frame_number ) >= ost -> max_frames ) while ( bsfc ) AVPacket new_pkt = * pkt ; int a = av_bitstream_filter_filter ( bsfc , avctx , ( ( void * ) 0 ) , & new_pkt . data , & new_pkt . size , ( pkt -> data ) , pkt -> size , pkt -> flags & 0000001 ) ; if ( a == 0 && new_pkt . data != pkt -> data && new_pkt . destruct ) uint8_t * t = ( av_malloc ( ( new_pkt . size + 16 ) ) ) ; if ( t ) memcpy ( t , new_pkt . data , new_pkt . size ); memset ( ( t + new_pkt . size ) , 0 , 16 ); new_pkt . data = t; a = 1; a = - 12; if ( a > 0 ) new_pkt . destruct = av_destruct_packet; if ( a < 0 ) av_log ( ( ( void * ) 0 ) , 16 , "Failed to open bitstream filter %s for stream %d with codec %s" , bsfc -> filter -> name , pkt -> stream_index , ( avctx -> codec ? avctx -> codec -> name : "copy" ) ); print_error ( "" , a ); * pkt = new_pkt; bsfc = bsfc -> next; pkt -> stream_index = ost -> index; av_log ( ( ( void * ) 0 ) , 32 , "muxer <- type:%s pkt_pts:%s pkt_pts_time:%s pkt_dts:%s pkt_dts_time:%s size:%d\n" , av_get_media_type_string ( ost -> st -> codec -> codec_type ) , av_ts_make_string ( ( ( char [ 32 ] ) ( 0 ) ) , pkt -> pts ) , av_ts_make_time_string ( ( ( char [ 32 ] ) ( 0 ) ) , pkt -> pts , & ost -> st -> time_base ) , av_ts_make_string ( ( ( char [ 32 ] ) ( 0 ) ) , pkt -> dts ) , av_ts_make_time_string ( ( ( char [ 32 ] ) ( 0 ) ) , pkt -> dts , & ost -> st -> time_base ) , pkt -> size ) ret = av_interleaved_write_frame ( s , pkt ); if ( ret < 0 ) print_error ( "av_interleaved_write_frame()" , ret ); | 150702/ffmpeg.c | SARD | 0 |
static void goodG2B() char * data ; char * dataArray [ 5 ] ; char * dataGoodBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataGoodBuffer; data [ 0 ] = '\0'; dataArray [ 2 ] = data; CWE121_Stack_Based_Buffer_Overflow__CWE805_char_alloca_ncpy_66b_goodG2BSink ( dataArray ); void CWE121_Stack_Based_Buffer_Overflow__CWE805_char_alloca_ncpy_66b_goodG2BSink(char * dataArray[]) char * data = dataArray [ 2 ] ; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncpy ( data , source , 100 - 1 ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 64024/CWE121_Stack_Based_Buffer_Overflow__CWE805_char_alloca_ncpy_66b.c | SARD | 0 |
static void goodB2G() twoIntsStruct * data ; data = ( twoIntsStruct * ) calloc ( 1 , sizeof ( twoIntsStruct ) ); CWE690_NULL_Deref_From_Return__struct_calloc_53b_goodB2GSink ( data ); void CWE690_NULL_Deref_From_Return__struct_calloc_53b_goodB2GSink(twoIntsStruct * data) CWE690_NULL_Deref_From_Return__struct_calloc_53c_goodB2GSink ( data ); void CWE690_NULL_Deref_From_Return__struct_calloc_53c_goodB2GSink(twoIntsStruct * data) CWE690_NULL_Deref_From_Return__struct_calloc_53d_goodB2GSink ( data ); void CWE690_NULL_Deref_From_Return__struct_calloc_53d_goodB2GSink(twoIntsStruct * data) if ( data != NULL ) data [ 0 ] . intOne = 1; data [ 0 ] . intTwo = 1; printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); free ( data ); | 111633/CWE690_NULL_Deref_From_Return__struct_calloc_53a.c | SARD | 0 |
static void goodG2B() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; CWE127_Buffer_Underread__char_alloca_cpy_51b_goodG2BSink ( data ); void CWE127_Buffer_Underread__char_alloca_cpy_51b_goodG2BSink(char * data) char dest [ 100 * 2 ] ; memset ( dest , 'C' , 100 * 2 - 1 ); dest [ 100 * 2 - 1 ] = '\0'; strcpy ( dest , data ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77267/CWE127_Buffer_Underread__char_alloca_cpy_51b.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_42_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; data = badSource ( data ); static char * 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 , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 80467/CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_42.c | SARD | 0 |
static void goodB2G1() size_t data ; data = 0; if ( globalTrue ) data = rand ( ); if ( globalFalse ) char * myString ; if ( data > strlen ( HELLO_STRING ) && data < 100 ) myString = ( char * ) malloc ( data * sizeof ( char ) ); strcpy ( myString , HELLO_STRING ); free ( myString ); | 117184/CWE789_Uncontrolled_Mem_Alloc__malloc_char_rand_10.c | SARD | 0 |
static void goodG2B() char * dataBuffer = ( char * ) malloc ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; CWE124_Buffer_Underwrite__malloc_char_loop_51b_goodG2BSink ( data ); void CWE124_Buffer_Underwrite__malloc_char_loop_51b_goodG2BSink(char * data) data [ i ] = source [ i ]; data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 74315/CWE124_Buffer_Underwrite__malloc_char_loop_51a.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_listen_socket_w32_vsnprintf_66_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 ) | 80528/CWE134_Uncontrolled_Format_String__char_listen_socket_w32_vsnprintf_66a.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( FILENAME_MAX - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; baseObject -> action ( data ); void CWE23_Relative_Path_Traversal__char_file_fopen_82_bad::action(char * data) pFile = FOPEN ( data , "wb+" ); if ( pFile != NULL ) fclose ( pFile ); | 90345/CWE23_Relative_Path_Traversal__char_file_fopen_82a.cpp | SARD | 0 |
void CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_w32_vsnprintf_05_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( staticTrue ) 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 ); | 80782/CWE134_Uncontrolled_Format_String__wchar_t_connect_socket_w32_vsnprintf_05.c | SARD | 0 |
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_61_bad() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' data = CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_61b_badSource ( data ); wchar_t * CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_61b_badSource(wchar_t * data) size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = L '\0' return data ; free ( data ); | 112984/CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_61a.c | SARD | 0 |
static void goodG2B2() size_t data ; data = 0; if ( globalFive == 5 ) data = 20; if ( globalFive == 5 ) char * myString ; if ( data > strlen ( HELLO_STRING ) ) myString = ( char * ) malloc ( data * sizeof ( char ) ); strcpy ( myString , HELLO_STRING ); free ( myString ); | 117092/CWE789_Uncontrolled_Mem_Alloc__malloc_char_fscanf_14.c | SARD | 0 |
void badSink(char * data) char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; dest [ i ] = data [ i ]; dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 78295/CWE127_Buffer_Underread__new_char_loop_51b.cpp | SARD | 3 |
int color(u_short mode,char *name,bool orphan,bool islink) if ( orphan ) if ( islink ) if ( missing_flgs ) if ( orphan_flgs ) switch ( mode & 0170000 ) if ( ! fifo_flgs ) fprintf ( outfile , "%s%s%s" , leftcode , fifo_flgs , rightcode ); if ( ! char_flgs ) fprintf ( outfile , "%s%s%s" , leftcode , char_flgs , rightcode ); fprintf ( outfile , "%s%s%s" , leftcode , stickyow_flgs , rightcode ); | 153162/color.c | SARD | 0 |
static void goodG2B1() char * data ; data = new char [ 100 ]; data = goodG2B1Source ( data ); char * goodG2B1Source(char * data) if ( goodG2B1Global ) memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; return data ; char dest [ 50 ] = "" ; strncpy ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0'; | 69507/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_char_ncpy_22a.cpp | SARD | 0 |
void CWE127_Buffer_Underread__malloc_wchar_t_cpy_64_bad() wchar_t * data ; data = NULL; wchar_t * dataBuffer = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer - 8; CWE127_Buffer_Underread__malloc_wchar_t_cpy_64b_badSink ( & data ); void CWE127_Buffer_Underread__malloc_wchar_t_cpy_64b_badSink(void * dataVoidPtr) wchar_t * * dataPtr = ( wchar_t * * ) dataVoidPtr ; wchar_t * data = ( * dataPtr ) ; 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 ) | 78014/CWE127_Buffer_Underread__malloc_wchar_t_cpy_64b.c | SARD | 3 |
void CWE114_Process_Control__w32_char_file_21_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; data = badSource ( data ); static char * badSource(char * data) if ( badStatic ) size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; return data ; | 62102/CWE114_Process_Control__w32_char_file_21.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_connect_socket_snprintf_34_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 79217/CWE134_Uncontrolled_Format_String__char_connect_socket_snprintf_34.c | SARD | 0 |
void CWE126_Buffer_Overread__CWE170_char_strncpy_02_bad() if ( 1 ) char data [ 150 ] , dest [ 100 ] ; memset ( data , 'A' , 149 ); data [ 149 ] = '\0'; strncpy ( dest , data , 99 ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 75923/CWE126_Buffer_Overread__CWE170_char_strncpy_02.c | SARD | 3 |
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 ; d -> searchflag = searchflag; d -> follows = ( ( sizeof ( ( * d -> follows ) ) == 1 ? xzalloc ( d -> tindex ) : xcalloc ( d -> tindex , sizeof ( ( * d -> follows ) ) ) ) ); while ( 0 ) merged . nelem = 0; epsclosure ( & merged , d ); static void epsclosure(position_set *s,const struct dfa *d) char * visited ; visited = ( ( sizeof ( ( * visited ) ) == 1 ? xzalloc ( d -> tindex ) : xcalloc ( d -> tindex , sizeof ( ( * visited ) ) ) ) ); while ( 0 ) free ( visited ); | 153579/dfa.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_console_w32_execvp_44_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; data [ dataLen ] = '\0'; funcPtr ( data ); | 118690/CWE78_OS_Command_Injection__char_console_w32_execvp_44.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_file_snprintf_54_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; fclose ( pFile ); CWE134_Uncontrolled_Format_String__char_file_snprintf_54b_badSink ( data ); void CWE134_Uncontrolled_Format_String__char_file_snprintf_54b_badSink(char * data) CWE134_Uncontrolled_Format_String__char_file_snprintf_54c_badSink ( data ); void CWE134_Uncontrolled_Format_String__char_file_snprintf_54c_badSink(char * data) CWE134_Uncontrolled_Format_String__char_file_snprintf_54d_badSink ( data ); void CWE134_Uncontrolled_Format_String__char_file_snprintf_54d_badSink(char * data) CWE134_Uncontrolled_Format_String__char_file_snprintf_54e_badSink ( data ); void CWE134_Uncontrolled_Format_String__char_file_snprintf_54e_badSink(char * data) SNPRINTF ( dest , 100 - 1 , data ); | 80090/CWE134_Uncontrolled_Format_String__char_file_snprintf_54a.c | SARD | 0 |
conversation_t *find_or_create_conversation(packet_info *pinfo) if ( ( conv = find_conversation ( pinfo -> fd -> num , ( & pinfo -> src ) , ( & pinfo -> dst ) , pinfo -> ptype , pinfo -> srcport , pinfo -> destport , 0 ) ) == ( ( void * ) 0 ) ) conversation_t *find_conversation(const guint32 frame_num,const address *addr_a,const address *addr_b,const port_type ptype,const guint32 port_a,const guint32 port_b,const guint options) conversation_t * conversation ; if ( ! ( options & ( 0x01 | 0x02 ) ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_exact , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( options & 0x02 ) ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); if ( conversation == ( ( void * ) 0 ) && ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); if ( conversation != ( ( void * ) 0 ) ) if ( ! ( 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 ); static conversation_t *conversation_lookup_hashtable(GHashTable *hashtable,const guint32 frame_num,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2) conversation_t * match = ( ( void * ) 0 ) ; conversation_key key ; key . addr1 = * addr1; key . addr2 = * addr2; key . ptype = ptype; key . port1 = port1; key . port2 = port2; chain_head = ( g_hash_table_lookup ( hashtable , ( & key ) ) ); if ( chain_head && chain_head -> setup_frame <= frame_num ) match = chain_head; if ( chain_head -> last && chain_head -> last -> setup_frame <= frame_num ) return chain_head -> last ; if ( chain_head -> latest_found && chain_head -> latest_found -> setup_frame <= frame_num ) match = chain_head -> latest_found; for (convo = match; convo && convo -> setup_frame <= frame_num; convo = convo -> next) if ( convo -> setup_frame > match -> setup_frame ) match = convo; return match ; 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 ); static conversation_t *conversation_lookup_hashtable(GHashTable *hashtable,const guint32 frame_num,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2) conversation_t * match = ( ( void * ) 0 ) ; conversation_key key ; key . addr1 = * addr1; key . addr2 = * addr2; key . ptype = ptype; key . port1 = port1; key . port2 = port2; chain_head = ( g_hash_table_lookup ( hashtable , ( & key ) ) ); if ( chain_head && chain_head -> setup_frame <= frame_num ) match = chain_head; if ( chain_head -> last && chain_head -> last -> setup_frame <= frame_num ) return chain_head -> last ; if ( chain_head -> latest_found && chain_head -> latest_found -> setup_frame <= frame_num ) match = chain_head -> latest_found; if ( convo -> setup_frame > match -> setup_frame ) match = convo; return match ; 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 ); static conversation_t *conversation_lookup_hashtable(GHashTable *hashtable,const guint32 frame_num,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2) conversation_t * match = ( ( void * ) 0 ) ; conversation_key key ; key . addr1 = * addr1; key . addr2 = * addr2; key . ptype = ptype; key . port1 = port1; key . port2 = port2; chain_head = ( g_hash_table_lookup ( hashtable , ( & key ) ) ); if ( chain_head && chain_head -> setup_frame <= frame_num ) match = chain_head; if ( chain_head -> last && chain_head -> last -> setup_frame <= frame_num ) return chain_head -> last ; if ( chain_head -> latest_found && chain_head -> latest_found -> setup_frame <= frame_num ) match = chain_head -> latest_found; if ( convo -> setup_frame > match -> setup_frame ) match = convo; return match ; if ( conversation != ( ( void * ) 0 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation = conversation_create_from_template ( conversation , 0 , port_a ); static conversation_t *conversation_create_from_template(conversation_t *conversation,const address *addr2,const guint32 port2) if ( conversation -> options & 0x08 && ( conversation -> key_ptr -> ptype ) != PT_UDP ) conversation_t * new_conversation_from_template ; guint options = conversation -> options & ( ~ ( 0x08 | 0x01 | 0x02 ) ) ; if ( conversation -> options & 0x01 && conversation -> options & 0x02 ) new_conversation_from_template = conversation_new ( conversation -> setup_frame , ( & conversation -> key_ptr -> addr1 ) , addr2 , conversation -> key_ptr -> ptype , conversation -> key_ptr -> port1 , port2 , options ); conversation_t *conversation_new(const guint32 setup_frame,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2,const guint options) conversation_key * new_key ; new_key = ( se_alloc ( sizeof ( struct conversation_key ) ) ); new_key -> next = conversation_keys; guint8 * SE_COPY_ADDRESS_data ; ( & new_key -> addr1 ) -> type = addr1 -> type; ( & new_key -> addr1 ) -> len = addr1 -> len; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr1 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr1 -> data , ( addr1 -> len ) ); ( & new_key -> addr1 ) -> data = SE_COPY_ADDRESS_data; guint8 * SE_COPY_ADDRESS_data ; ( & new_key -> addr2 ) -> type = addr2 -> type; ( & new_key -> addr2 ) -> len = addr2 -> len; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr2 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr2 -> data , ( addr2 -> len ) ); ( & new_key -> addr2 ) -> data = SE_COPY_ADDRESS_data; new_key -> ptype = ptype; new_key -> port1 = port1; new_key -> port2 = port2; conversation = ( ( conversation_t * ) ( se_alloc ( sizeof ( conversation_t ) ) ) ); memset ( conversation , 0 , sizeof ( conversation_t ) ); conversation -> index = new_index; conversation -> setup_frame = setup_frame; conversation -> data_list = ( ( void * ) 0 ); conversation -> dissector_handle = ( ( void * ) 0 ); conversation -> options = options; conversation -> key_ptr = new_key; return conversation ; if ( conversation -> options & 0x02 ) new_conversation_from_template = conversation_new ( conversation -> setup_frame , ( & conversation -> key_ptr -> addr1 ) , ( & conversation -> key_ptr -> addr2 ) , conversation -> key_ptr -> ptype , conversation -> key_ptr -> port1 , port2 , options ); conversation_t *conversation_new(const guint32 setup_frame,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2,const guint options) conversation_key * new_key ; new_key = ( se_alloc ( sizeof ( struct conversation_key ) ) ); new_key -> next = conversation_keys; guint8 * SE_COPY_ADDRESS_data ; ( & new_key -> addr1 ) -> type = addr1 -> type; ( & new_key -> addr1 ) -> len = addr1 -> len; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr1 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr1 -> data , ( addr1 -> len ) ); ( & new_key -> addr1 ) -> data = SE_COPY_ADDRESS_data; guint8 * SE_COPY_ADDRESS_data ; ( & new_key -> addr2 ) -> type = addr2 -> type; ( & new_key -> addr2 ) -> len = addr2 -> len; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr2 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr2 -> data , ( addr2 -> len ) ); ( & new_key -> addr2 ) -> data = SE_COPY_ADDRESS_data; new_key -> ptype = ptype; new_key -> port1 = port1; new_key -> port2 = port2; conversation = ( ( conversation_t * ) ( se_alloc ( sizeof ( conversation_t ) ) ) ); memset ( conversation , 0 , sizeof ( conversation_t ) ); conversation -> index = new_index; conversation -> setup_frame = setup_frame; conversation -> data_list = ( ( void * ) 0 ); conversation -> dissector_handle = ( ( void * ) 0 ); conversation -> options = options; conversation -> key_ptr = new_key; return conversation ; if ( conversation -> options & 0x01 ) new_conversation_from_template = conversation_new ( conversation -> setup_frame , ( & conversation -> key_ptr -> addr1 ) , addr2 , conversation -> key_ptr -> ptype , conversation -> key_ptr -> port1 , conversation -> key_ptr -> port2 , options ); conversation_t *conversation_new(const guint32 setup_frame,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2,const guint options) conversation_key * new_key ; new_key = ( se_alloc ( sizeof ( struct conversation_key ) ) ); new_key -> next = conversation_keys; guint8 * SE_COPY_ADDRESS_data ; ( & new_key -> addr1 ) -> type = addr1 -> type; ( & new_key -> addr1 ) -> len = addr1 -> len; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr1 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr1 -> data , ( addr1 -> len ) ); ( & new_key -> addr1 ) -> data = SE_COPY_ADDRESS_data; guint8 * SE_COPY_ADDRESS_data ; ( & new_key -> addr2 ) -> type = addr2 -> type; ( & new_key -> addr2 ) -> len = addr2 -> len; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr2 -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr2 -> data , ( addr2 -> len ) ); ( & new_key -> addr2 ) -> data = SE_COPY_ADDRESS_data; new_key -> ptype = ptype; new_key -> port1 = port1; new_key -> port2 = port2; conversation = ( ( conversation_t * ) ( se_alloc ( sizeof ( conversation_t ) ) ) ); memset ( conversation , 0 , sizeof ( conversation_t ) ); conversation -> index = new_index; conversation -> setup_frame = setup_frame; conversation -> data_list = ( ( void * ) 0 ); conversation -> dissector_handle = ( ( void * ) 0 ); conversation -> options = options; conversation -> key_ptr = new_key; return conversation ; return conversation ; return new_conversation_from_template ; return conversation ; conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2_or_port2 , frame_num , addr_a , addr_b , ptype , port_a , port_b ); static conversation_t *conversation_lookup_hashtable(GHashTable *hashtable,const guint32 frame_num,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2) conversation_t * match = ( ( void * ) 0 ) ; conversation_key key ; key . addr1 = * addr1; key . addr2 = * addr2; key . ptype = ptype; key . port1 = port1; key . port2 = port2; chain_head = ( g_hash_table_lookup ( hashtable , ( & key ) ) ); if ( chain_head && chain_head -> setup_frame <= frame_num ) match = chain_head; if ( chain_head -> last && chain_head -> last -> setup_frame <= frame_num ) return chain_head -> last ; if ( chain_head -> latest_found && chain_head -> latest_found -> setup_frame <= frame_num ) match = chain_head -> latest_found; if ( convo -> setup_frame > match -> setup_frame ) match = convo; return match ; if ( conversation != ( ( void * ) 0 ) ) if ( ( addr_a -> type ) == AT_FC ) conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2_or_port2 , frame_num , addr_b , addr_a , ptype , port_a , port_b ); static conversation_t *conversation_lookup_hashtable(GHashTable *hashtable,const guint32 frame_num,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2) conversation_t * match = ( ( void * ) 0 ) ; conversation_key key ; key . addr1 = * addr1; key . addr2 = * addr2; key . ptype = ptype; key . port1 = port1; key . port2 = port2; chain_head = ( g_hash_table_lookup ( hashtable , ( & key ) ) ); if ( chain_head && chain_head -> setup_frame <= frame_num ) match = chain_head; if ( chain_head -> last && chain_head -> last -> setup_frame <= frame_num ) return chain_head -> last ; if ( chain_head -> latest_found && chain_head -> latest_found -> setup_frame <= frame_num ) match = chain_head -> latest_found; if ( convo -> setup_frame > match -> setup_frame ) match = convo; return match ; conversation = conversation_lookup_hashtable ( conversation_hashtable_no_addr2_or_port2 , frame_num , addr_b , addr_a , ptype , port_b , port_a ); static conversation_t *conversation_lookup_hashtable(GHashTable *hashtable,const guint32 frame_num,const address *addr1,const address *addr2,const port_type ptype,const guint32 port1,const guint32 port2) conversation_t * match = ( ( void * ) 0 ) ; conversation_key key ; key . addr1 = * addr1; key . addr2 = * addr2; key . ptype = ptype; key . port1 = port1; key . port2 = port2; chain_head = ( g_hash_table_lookup ( hashtable , ( & key ) ) ); if ( chain_head && chain_head -> setup_frame <= frame_num ) match = chain_head; if ( chain_head -> last && chain_head -> last -> setup_frame <= frame_num ) return chain_head -> last ; if ( chain_head -> latest_found && chain_head -> latest_found -> setup_frame <= frame_num ) match = chain_head -> latest_found; if ( convo -> setup_frame > match -> setup_frame ) match = convo; return match ; if ( conversation != ( ( void * ) 0 ) ) if ( ptype != PT_UDP ) if ( ! ( conversation -> options & 0x08 ) ) conversation_set_addr2 ( conversation , addr_a ); void conversation_set_addr2(conversation_t *conv,const address *addr) if ( ! ( conv -> options & 0x01 ) ) guint8 * SE_COPY_ADDRESS_data ; SE_COPY_ADDRESS_data = ( se_alloc ( ( addr -> len ) ) ); memcpy ( SE_COPY_ADDRESS_data , addr -> data , ( addr -> len ) ); ( & conv -> key_ptr -> addr2 ) -> data = SE_COPY_ADDRESS_data; if ( conv -> options & 0x02 ) conversation_insert_into_hashtable ( conversation_hashtable_no_port2 , conv ); conversation_insert_into_hashtable ( conversation_hashtable_exact , conv ); | 152372/conversation.c | SARD | 0 |
static void goodG2B2() char * data ; data = new char [ 100 ]; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; char dest [ 50 ] = "" ; strncat ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0'; | 69450/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_char_ncat_11.cpp | SARD | 0 |
void svn_fspath__split(const char **dirpath,const char **base_name,const char *fspath,apr_pool_t *result_pool) if ( base_name ) * base_name = svn_fspath__basename ( fspath , result_pool ); const char *svn_fspath__basename(const char *fspath,apr_pool_t *pool) const char * result ; result = svn_relpath_basename ( fspath + 1 , pool ); const char *svn_relpath_basename(const char *relpath,apr_pool_t *pool) apr_size_t len = strlen ( relpath ) ; apr_size_t start ; start = len; if ( pool ) return ( apr_pstrmemdup ( pool , relpath + start , len - start ) ) ; return relpath + start ; strchr ( result , 47 ) == ( ( void * ) 0 ) ? ( ( void ) 0 ) : __assert_fail ( "strchr(result, '/') == ((void *)0)" , "dirent_uri.c" , 2518 , __PRETTY_FUNCTION__ ); | 150048/dirent_uri.c | SARD | 0 |
static void goodG2B2() int data ; data = - 1; if ( globalFive == 5 ) data = 100 - 1; char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) memmove ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 88123/CWE195_Signed_to_Unsigned_Conversion_Error__listen_socket_memmove_14.c | SARD | 0 |
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) state_num s ; state_num s1 ; const unsigned char * p ; state_num * * trans ; state_num * t ; unsigned char eol = eolbyte ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; * end = eol; if ( d -> mb_cur_max > 1 ) while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) if ( p > buf_end ) s1 = s; if ( s == 0 ) if ( ( ( char * ) p ) >= end ) if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) s = transit_state ( d , s , & p ); trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) state_num s1 ; int mbclen ; int maxlen = 0 ; size_t i ; size_t nelem = d -> states [ s ] . mbps . nelem ; position_set follows ; const unsigned char * p1 = * pp ; wchar_t wc ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; int constraint ; state_num i ; state_num j ; for (i = 0; i < s -> nelem; ++i) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; for (i = 0; i < d -> sindex; ++i) if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( j == s -> nelem ) return i ; if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; while ( 0 ) d -> states [ i ] . hash = hash; d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; if ( 1 ) d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); for (j = 0; j < s -> nelem; ++j) if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; return i ; while ( * pp - p1 < maxlen ) transit_state_consume_1char ( d , s1 , pp , ( ( void * ) 0 ) , & mbclen , & follows ); wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; int constraint ; state_num i ; state_num j ; hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( j == s -> nelem ) return i ; if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; while ( 0 ) d -> states [ i ] . hash = hash; d -> states [ i ] . context = context; d -> states [ i ] . backref = 0; d -> states [ i ] . constraint = 0; d -> states [ i ] . first_end = 0; if ( 1 ) d -> states [ i ] . mbps . nelem = 0; d -> states [ i ] . mbps . elems = ( ( void * ) 0 ); if ( d -> tokens [ s -> elems [ j ] . index ] < 0 ) constraint = s -> elems [ j ] . constraint; if ( ( ( ( 7 & 1 ? constraint & 0xf : 0 ) ) | ( ( 7 & 2 ? constraint >> 4 & 0xf : 0 ) ) | ( ( 7 & 4 ? constraint >> 8 & 0xf : 0 ) ) ) & context ) d -> states [ i ] . constraint |= constraint; if ( ! d -> states [ i ] . first_end ) d -> states [ i ] . first_end = d -> tokens [ s -> elems [ j ] . index ]; if ( d -> tokens [ s -> elems [ j ] . index ] == BACKREF ) d -> states [ i ] . constraint = 0x777; d -> states [ i ] . backref = 1; return i ; static status_transit_state transit_state_consume_1char(struct dfa *d,state_num s,const unsigned char **pp,int *match_lens,int *mbclen,position_set *pps) int k ; state_num s1 ; state_num s2 ; int * work_mbls ; * mbclen = ( mblen_buf [ * pp - buf_begin ] == 0 ? 1 : mblen_buf [ * pp - buf_begin ] ); s1 = s; for (k = 0; k < *mbclen; k++) s2 = s1; rs = transit_state_singlebyte ( d , s2 , ( * pp ) ++ , & s1 ); if ( match_lens == ( ( void * ) 0 ) && d -> states [ s ] . mbps . nelem != 0 ) work_mbls = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); static int *check_matching_with_multibyte_ops(struct dfa *d,state_num s,size_t idx) 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 ; | 153568/dfa.c | SARD | 0 |
void stonesoup_setup_printf_context() ss_tc_root = getenv ( "SS_TC_ROOT" ); if ( ss_tc_root != NULL ) size_dirpath = strlen ( ss_tc_root ) + strlen ( "testData" ) + 2; dirpath = ( char * ) malloc ( size_dirpath * sizeof ( char ) ); if ( dirpath != NULL ) sprintf ( dirpath , "%s/%s" , ss_tc_root , "testData" ); retval = 0; if ( stat ( dirpath , & st ) == - 1 ) retval = mkdir ( dirpath , 0700 ); if ( retval == 0 ) size_filepath = strlen ( dirpath ) + strlen ( "logfile.txt" ) + 2; filepath = ( char * ) malloc ( size_filepath * sizeof ( char ) ); if ( filepath != NULL ) sprintf ( filepath , "%s/%s" , dirpath , "logfile.txt" ); stonesoup_printf_context = fopen ( filepath , "w" ); if ( stonesoup_printf_context == NULL ) | 149790/ffmpeg.c | SARD | 0 |
static void goodG2B() short data ; data = 0; data = 100 - 1; short dataCopy = data ; short data = dataCopy ; if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; free ( dataBuffer ); | 86498/CWE194_Unexpected_Sign_Extension__fgets_malloc_31.c | SARD | 0 |
void bad() char * data ; data = new char [ 100 ]; memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; badSink_b ( data ); void badSink_b(char * data) badSink_c ( data ); void badSink_c(char * data) badSink_d ( data ); void badSink_d(char * data) strncpy ( dest , data , strlen ( data ) ); dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] data | 69519/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE806_char_ncpy_53a.cpp | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_console_printf_44_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; data [ dataLen ] = '\0'; funcPtr ( data ); | 79461/CWE134_Uncontrolled_Format_String__char_console_printf_44.c | SARD | 0 |
void CWE124_Buffer_Underwrite__malloc_char_loop_52c_badSink(char * data) char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; data [ i ] = source [ i ]; data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 74316/CWE124_Buffer_Underwrite__malloc_char_loop_52c.c | SARD | 3 |
void CWE124_Buffer_Underwrite__malloc_wchar_t_cpy_54_bad() wchar_t * dataBuffer = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; data = dataBuffer - 8; CWE124_Buffer_Underwrite__malloc_wchar_t_cpy_54b_badSink ( data ); void CWE124_Buffer_Underwrite__malloc_wchar_t_cpy_54b_badSink(wchar_t * data) CWE124_Buffer_Underwrite__malloc_wchar_t_cpy_54c_badSink ( data ); void CWE124_Buffer_Underwrite__malloc_wchar_t_cpy_54c_badSink(wchar_t * data) CWE124_Buffer_Underwrite__malloc_wchar_t_cpy_54d_badSink ( data ); void CWE124_Buffer_Underwrite__malloc_wchar_t_cpy_54d_badSink(wchar_t * data) CWE124_Buffer_Underwrite__malloc_wchar_t_cpy_54e_badSink ( data ); void CWE124_Buffer_Underwrite__malloc_wchar_t_cpy_54e_badSink(wchar_t * data) wcscpy ( data , source ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 74510/CWE124_Buffer_Underwrite__malloc_wchar_t_cpy_54a.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 ) build_state ( s , d ); trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) int separate_contexts ; state_num state_letter ; if ( d -> searchflag ) separate_contexts = state_separate_contexts ( ( & follows ) ); if ( separate_contexts & 2 ) state_letter = state_index ( d , ( & follows ) , 2 ); static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; state_num i ; state_num j ; for (i = 0; i < s -> nelem; ++i) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; for (i = 0; i < d -> sindex; ++i) if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; while ( 0 ) d -> states [ i ] . hash = hash; copy ( s , & d -> states [ i ] . elems ); | 153747/dfa.c | SARD | 0 |
static void goodG2B() wchar_t * data ; data = NULL; 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 ) free ( data ); | 72154/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncpy_43.cpp | SARD | 0 |
void CWE78_OS_Command_Injection__char_listen_socket_w32_execvp_51_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) CWE78_OS_Command_Injection__char_listen_socket_w32_execvp_51b_badSink ( data ); void CWE78_OS_Command_Injection__char_listen_socket_w32_execvp_51b_badSink(char * data) | 120132/CWE78_OS_Command_Injection__char_listen_socket_w32_execvp_51a.c | SARD | 0 |
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticFive == 5 ) 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 ) | 80448/CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_07.c | SARD | 0 |
void bad() wchar_t * data ; data = NULL; data = new wchar_t [ 50 ]; data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' wcsncat ( data , source , 100 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) delete [ ] data | 69169/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_wchar_t_ncat_18.cpp | SARD | 3 |
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) state_num s ; state_num s1 ; const unsigned char * p ; state_num * * trans ; state_num * t ; unsigned char eol = eolbyte ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; * end = eol; if ( d -> mb_cur_max > 1 ) while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) if ( p > buf_end ) s1 = s; if ( s == 0 ) if ( ( ( char * ) p ) >= end ) if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) s = transit_state ( d , s , & p ); trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) size_t nelem = d -> states [ s ] . mbps . nelem ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); static int *check_matching_with_multibyte_ops(struct dfa *d,state_num s,size_t idx) size_t i ; int * rarray ; rarray = ( ( sizeof ( ( * rarray ) ) == 1 ? xmalloc ( d -> states [ s ] . mbps . nelem ) : xnmalloc ( d -> states [ s ] . mbps . nelem , sizeof ( ( * rarray ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . mbps . nelem; ++i) position pos = d -> states [ s ] . mbps . elems [ i ] ; switch ( d -> tokens [ pos . index ] ) rarray [ i ] = match_anychar ( d , s , pos , idx ); rarray [ i ] = match_mb_charset ( d , s , pos , idx ); static int match_mb_charset(struct dfa *d,state_num s,position pos,size_t idx) size_t i ; int match_len ; int op_len ; char buffer [ 128 ] ; struct mb_char_classes * work_mbc ; int context ; wchar_t wc ; wc = inputwcs [ idx ]; if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) context = wchar_context ( wc ); if ( ! ( ( ( ( context & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( context & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( context & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) work_mbc = & d -> mbcsets [ d -> multibyte_prop [ pos . index ] >> 2 ]; match_len = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc < 1 << 8 && work_mbc -> cset != ( - 1 ) && tstbit ( ( ( unsigned char ) wc ) , d -> charclasses [ work_mbc -> cset ] ) ) for (i = 0; i < work_mbc -> nch_classes; i++) if ( iswctype ( ( ( wint_t ) wc ) , work_mbc -> ch_classes [ i ] ) ) strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , match_len ); buffer [ match_len ] = '\0'; for (i = 0; i < work_mbc -> nequivs; i++) op_len = ( strlen ( work_mbc -> equivs [ i ] ) ); strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> equivs [ i ] , buffer ) == 0 ) | 153516/dfa.c | SARD | 0 |
static void backend_read_statsfile() if ( pgStatDBHash ) if ( IsAutoVacuumLauncherProcess ( ) ) pgStatDBHash = pgstat_read_statsfile ( ( ( Oid ) 0 ) , ( ( bool ) 0 ) ); static HTAB *pgstat_read_statsfile(Oid onlydb,bool permanent) PgStat_StatDBEntry * dbentry ; PgStat_StatDBEntry dbbuf ; PgStat_StatTabEntry tabbuf ; PgStat_StatFuncEntry funcbuf ; HASHCTL hash_ctl ; HTAB * dbhash ; HTAB * tabhash = ( ( void * ) 0 ) ; HTAB * funchash = ( ( void * ) 0 ) ; FILE * fpin ; int32 format_id ; bool found ; const char * statfile = ( permanent ? "global/pgstat.stat" : pgstat_stat_filename ) ; hash_ctl . keysize = sizeof ( Oid ); hash_ctl . entrysize = sizeof ( PgStat_StatDBEntry ); hash_ctl . hash = oid_hash; hash_ctl . hcxt = pgStatLocalContext; dbhash = hash_create ( "Databases hash" , 16 , & hash_ctl , 0x020 | 0x010 | 0x200 ); globalStats . stat_reset_timestamp = GetCurrentTimestamp ( ); if ( ( fpin = AllocateFile ( statfile , "r" ) ) == ( ( void * ) 0 ) ) if ( fread ( ( & format_id ) , 1 , sizeof ( format_id ) , fpin ) != sizeof ( format_id ) || format_id != 0x01A5BC9A ) if ( fread ( ( & globalStats ) , 1 , sizeof ( globalStats ) , fpin ) != sizeof ( globalStats ) ) switch ( fgetc ( fpin ) ) if ( fread ( ( & dbbuf ) , 1 , ( ( size_t ) ( & ( ( PgStat_StatDBEntry * ) 0 ) -> tables ) ) , fpin ) != ( ( size_t ) ( & ( ( PgStat_StatDBEntry * ) 0 ) -> tables ) ) ) dbentry = ( ( PgStat_StatDBEntry * ) ( hash_search ( dbhash , ( ( void * ) ( & dbbuf . databaseid ) ) , HASH_ENTER , & found ) ) ); if ( found ) memcpy ( dbentry , ( & dbbuf ) , sizeof ( PgStat_StatDBEntry ) ); dbentry -> tables = ( ( void * ) 0 ); dbentry -> functions = ( ( void * ) 0 ); if ( onlydb != ( ( Oid ) 0 ) ) if ( dbbuf . databaseid != onlydb && dbbuf . databaseid != ( ( Oid ) 0 ) ) hash_ctl . keysize = sizeof ( Oid ); hash_ctl . entrysize = sizeof ( PgStat_StatTabEntry ); hash_ctl . hash = oid_hash; hash_ctl . hcxt = pgStatLocalContext; dbentry -> tables = hash_create ( "Per-database table" , 512 , & hash_ctl , 0x020 | 0x010 | 0x200 ); hash_ctl . keysize = sizeof ( Oid ); hash_ctl . entrysize = sizeof ( PgStat_StatFuncEntry ); hash_ctl . hash = oid_hash; hash_ctl . hcxt = pgStatLocalContext; dbentry -> functions = hash_create ( "Per-database function" , 512 , & hash_ctl , 0x020 | 0x010 | 0x200 ); tabhash = dbentry -> tables; funchash = dbentry -> functions; tabhash = ( ( void * ) 0 ); funchash = ( ( void * ) 0 ); if ( fread ( ( & tabbuf ) , 1 , sizeof ( PgStat_StatTabEntry ) , fpin ) != sizeof ( PgStat_StatTabEntry ) ) if ( tabhash == ( ( void * ) 0 ) ) tabentry = ( ( PgStat_StatTabEntry * ) ( hash_search ( tabhash , ( ( void * ) ( & tabbuf . tableid ) ) , HASH_ENTER , & found ) ) ); if ( found ) memcpy ( tabentry , ( & tabbuf ) , sizeof ( tabbuf ) ); if ( fread ( ( & funcbuf ) , 1 , sizeof ( PgStat_StatFuncEntry ) , fpin ) != sizeof ( PgStat_StatFuncEntry ) ) if ( funchash == ( ( void * ) 0 ) ) funcentry = ( ( PgStat_StatFuncEntry * ) ( hash_search ( funchash , ( ( void * ) ( & funcbuf . functionid ) ) , HASH_ENTER , & found ) ) ); if ( found ) memcpy ( funcentry , ( & funcbuf ) , sizeof ( funcbuf ) ); | 153393/pgstat.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; badSource ( data ); static void badSource(char * &data) 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'; | 119601/CWE78_OS_Command_Injection__char_file_w32_execvp_43.cpp | SARD | 0 |
int avio_open2(AVIOContext **s,const char *filename,int flags,const AVIOInterruptCB *int_cb,AVDictionary **options) int exobasidium_chemult = 596 ; char * spreadability_chamfrain ; if ( __sync_bool_compare_and_swap ( & markhor_ecus , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) stonesoup_read_taint ( & spreadability_chamfrain , "2873" , exobasidium_chemult ); void stonesoup_read_taint(char** stonesoup_tainted_buff, char* stonesoup_envKey, int stonesoup_shmsz) int stonesoup_shmid ; key_t stonesoup_key ; char * stonesoup_shm , * stonesoup_s ; * stonesoup_tainted_buff = NULL; if ( getenv ( "STONESOUP_DISABLE_WEAKNESS" ) == NULL || strcmp ( getenv ( "STONESOUP_DISABLE_WEAKNESS" ) , "1" ) != 0 ) if ( stonesoup_envKey != NULL ) if ( sscanf ( stonesoup_envKey , "%d" , & stonesoup_key ) > 0 ) if ( ( stonesoup_shmid = shmget ( stonesoup_key , stonesoup_shmsz , 0666 ) ) >= 0 ) if ( ( stonesoup_shm = shmat ( stonesoup_shmid , NULL , 0 ) ) != ( char * ) - 1 ) * stonesoup_tainted_buff = ( char * ) calloc ( stonesoup_shmsz , sizeof ( char ) ); for (stonesoup_s = stonesoup_shm; *stonesoup_s != (char)0; stonesoup_s++) ( * stonesoup_tainted_buff ) [ stonesoup_s - stonesoup_shm ] = * stonesoup_s; * stonesoup_tainted_buff = NULL; | 153443/aviobuf.c | SARD | 0 |
void CWE15_External_Control_of_System_or_Configuration_Setting__w32_09_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( GLOBAL_CONST_TRUE ) WSADATA wsaData ; struct sockaddr_in service ; int recvResult ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( PF_INET , SOCK_STREAM , 0 ); 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 ( LISTEN_PORT ); if ( SOCKET_ERROR == bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) ) if ( SOCKET_ERROR == listen ( listenSocket , LISTEN_BACKLOG ) ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == INVALID_SOCKET ) recvResult = recv ( acceptSocket , data , 100 - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ recvResult ] = '\0'; while ( 0 ) if ( ! SetComputerNameA ( data ) ) | 81986/CWE15_External_Control_of_System_or_Configuration_Setting__w32_09.c | SARD | 19 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 80366/CWE134_Uncontrolled_Format_String__char_listen_socket_snprintf_31.c | SARD | 0 |
void CWE590_Free_Memory_Not_on_Heap__free_char_static_67_bad() static char dataBuffer [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; myStruct . structFirst = data; CWE590_Free_Memory_Not_on_Heap__free_char_static_67b_badSink ( myStruct ); void CWE590_Free_Memory_Not_on_Heap__free_char_static_67b_badSink(CWE590_Free_Memory_Not_on_Heap__free_char_static_67_structType myStruct) char * data = myStruct . structFirst ; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 108209/CWE590_Free_Memory_Not_on_Heap__free_char_static_67a.c | SARD | 0 |
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) state_num s ; state_num s1 ; const unsigned char * p ; state_num * * trans ; state_num * t ; unsigned char eol = eolbyte ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; * end = eol; if ( d -> mb_cur_max > 1 ) while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) if ( p > buf_end ) s1 = s; if ( s == 0 ) if ( ( ( char * ) p ) >= end ) if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) s = transit_state ( d , s , & p ); trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) size_t nelem = d -> states [ s ] . mbps . nelem ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); static int *check_matching_with_multibyte_ops(struct dfa *d,state_num s,size_t idx) size_t i ; int * rarray ; rarray = ( ( sizeof ( ( * rarray ) ) == 1 ? xmalloc ( d -> states [ s ] . mbps . nelem ) : xnmalloc ( d -> states [ s ] . mbps . nelem , sizeof ( ( * rarray ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . mbps . nelem; ++i) position pos = d -> states [ s ] . mbps . elems [ i ] ; switch ( d -> tokens [ pos . index ] ) rarray [ i ] = match_anychar ( d , s , pos , idx ); rarray [ i ] = match_mb_charset ( d , s , pos , idx ); static int match_mb_charset(struct dfa *d,state_num s,position pos,size_t idx) size_t i ; int match_len ; int op_len ; char buffer [ 128 ] ; struct mb_char_classes * work_mbc ; int context ; wchar_t wc ; wc = inputwcs [ idx ]; if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) context = wchar_context ( wc ); if ( ! ( ( ( ( context & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( context & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( context & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) work_mbc = & d -> mbcsets [ d -> multibyte_prop [ pos . index ] >> 2 ]; match_len = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc < 1 << 8 && work_mbc -> cset != ( - 1 ) && tstbit ( ( ( unsigned char ) wc ) , d -> charclasses [ work_mbc -> cset ] ) ) for (i = 0; i < work_mbc -> nch_classes; i++) if ( iswctype ( ( ( wint_t ) wc ) , work_mbc -> ch_classes [ i ] ) ) strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , match_len ); buffer [ match_len ] = '\0'; for (i = 0; i < work_mbc -> nequivs; i++) op_len = ( strlen ( work_mbc -> equivs [ i ] ) ); strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> equivs [ i ] , buffer ) == 0 ) strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> coll_elems [ i ] , buffer ) == 0 ) | 149548/dfa.c | SARD | 0 |
static void goodG2B2() size_t data ; data = 0; switch ( 6 ) data = 20; switch ( 7 ) char * myString ; if ( data > strlen ( HELLO_STRING ) ) myString = new char [ data ]; strcpy ( myString , HELLO_STRING ); printLine ( myString ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] myString | 117621/CWE789_Uncontrolled_Mem_Alloc__new_char_listen_socket_15.cpp | SARD | 0 |
void CWE114_Process_Control__w32_wchar_t_file_34_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 62395/CWE114_Process_Control__w32_wchar_t_file_34.c | SARD | 0 |
void bad() wchar_t * data ; data = NULL; if ( globalTrue ) data = new wchar_t [ 10 ]; wchar_t source [ 10 + 1 ] = SRC_STRING ; wcsncpy ( data , source , wcslen ( source ) + 1 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) delete [ ] data | 68249/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE193_wchar_t_ncpy_10.cpp | SARD | 3 |
void pavestone_minni(char **xylenes_bursautee) char stonesoup_stack_buff_64 [ 64 ] ; memset ( stonesoup_stack_buff_64 , 'A' , 63 ); stonesoup_stack_buff_64 [ 63 ] = '\0'; tracepoint ( stonesoup_trace , variable_buffer , "stonesoup_stack_buff_64" , stonesoup_stack_buff_64 , "INITIAL-STATE" ); stonesoup_printf ( "%c" , stonesoup_stack_buff_64 [ stonesoup_ss_i ] ); void stonesoup_printf(char * format, ...) va_start ( argptr , format ); mg_vprintf_data ( ( struct mg_connection * ) stonesoup_printf_context , format , argptr ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoup_stack_buff_64" , stonesoup_stack_buff_64 , "CROSSOVER-STATE" ); tracepoint ( stonesoup_trace , variable_buffer , "stonesoup_stack_buff_64" , stonesoup_stack_buff_64 , "FINAL-STATE" ); | 153248/xact.c | SARD | 3 |
void CWE606_Unchecked_Loop_Condition__char_listen_socket_07_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticFive == 5 ) 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 ) | 109128/CWE606_Unchecked_Loop_Condition__char_listen_socket_07.c | SARD | 0 |
void CWE194_Unexpected_Sign_Extension__rand_memcpy_13_bad() char source [ 100 ] ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memcpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 87306/CWE194_Unexpected_Sign_Extension__rand_memcpy_13.c | SARD | 20 |
static void goodG2B() char * data ; data = NULL; char * dataBuffer = new char [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; goodG2BSink_b ( data ); void goodG2BSink_b(char * data) goodG2BSink_c ( data ); void goodG2BSink_c(char * data) char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memcpy ( dest , data , 100 * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 78344/CWE127_Buffer_Underread__new_char_memcpy_52c.cpp | SARD | 0 |
nestegg_init(nestegg ** context, nestegg_io io, nestegg_log callback, int64_t max_offset) int r ; uint64_t id , version , docversion ; char * doctype ; nestegg * ctx ; if ( ! ( io . read && io . seek && io . tell ) ) ctx = ne_alloc ( sizeof ( * ctx ) ); if ( ! ctx ) ctx -> io = ne_alloc ( sizeof ( * ctx -> io ) ); if ( ! ctx -> io ) * ctx -> io = io; ctx -> log = callback; ctx -> alloc_pool = ne_pool_init ( ); if ( ! ctx -> alloc_pool ) if ( ! ctx -> log ) ctx -> log = ne_null_log_callback; r = ne_peek_element ( ctx , & id , NULL ); if ( r != 1 ) if ( id != ID_EBML ) r = ne_parse ( ctx , NULL , max_offset ); if ( r != 1 ) if ( ne_get_uint ( ctx -> ebml . ebml_read_version , & version ) != 0 ) version = 1; if ( version != 1 ) if ( ne_get_string ( ctx -> ebml . doctype , & doctype ) != 0 ) doctype = "matroska"; if ( strcmp ( doctype , "webm" ) != 0 ) nestegg_destroy ( ctx ); nestegg_destroy(nestegg * ctx) free ( ctx ); | CVE-2015-4511/Firefox_40.0b9_CVE_2015_4511__media_libnestegg_src_nestegg.c | NVD | 0 |
static void goodG2B2() wchar_t * data ; data = NULL; if ( globalFive == 5 ) data = new wchar_t [ 10 + 1 ]; wchar_t source [ 10 + 1 ] = SRC_STRING ; memcpy ( data , source , ( wcslen ( source ) + 1 ) * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) delete [ ] data | 68157/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE193_wchar_t_memcpy_14.cpp | SARD | 0 |
void CWE134_Uncontrolled_Format_String__wchar_t_environment_printf_63_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; size_t dataLen = wcslen ( data ) ; wcsncat ( data + dataLen , environment , 100 - dataLen - 1 ); CWE134_Uncontrolled_Format_String__wchar_t_environment_printf_63b_badSink ( & data ); void CWE134_Uncontrolled_Format_String__wchar_t_environment_printf_63b_badSink(wchar_t * * dataPtr) wchar_t * data = * dataPtr ; wprintf ( data ); | 81197/CWE134_Uncontrolled_Format_String__wchar_t_environment_printf_63a.c | SARD | 0 |
static void goodG2B2() char * password ; password = ""; password = CWE591_Sensitive_Data_Storage_in_Improperly_Locked_Memory__w32_char_22_goodG2B2Source ( password ); char * CWE591_Sensitive_Data_Storage_in_Improperly_Locked_Memory__w32_char_22_goodG2B2Source(char * password) if ( CWE591_Sensitive_Data_Storage_in_Improperly_Locked_Memory__w32_char_22_goodG2B2Global ) password = ( char * ) malloc ( 100 * sizeof ( char ) ); if ( password == NULL ) if ( ! VirtualLock ( password , 100 * sizeof ( char ) ) ) strcpy ( password , "Password1234!" ); return password ; | 108835/CWE591_Sensitive_Data_Storage_in_Improperly_Locked_Memory__w32_char_22b.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_listen_socket_popen_11_bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 119969/CWE78_OS_Command_Injection__char_listen_socket_popen_11.c | SARD | 15 |
void bad() size_t data ; data = 0; if ( 1 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( 1 ) if ( data > wcslen ( HELLO_STRING ) ) | 117848/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_listen_socket_02.cpp | SARD | 0 |
void CWE126_Buffer_Overread__malloc_char_memmove_05_bad() char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memmove ( dest , data , strlen ( dest ) * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 76334/CWE126_Buffer_Overread__malloc_char_memmove_05.c | SARD | 3 |
void CWE124_Buffer_Underwrite__char_declare_cpy_17_bad() char dataBuffer [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer - 8; strcpy ( data , source ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 73958/CWE124_Buffer_Underwrite__char_declare_cpy_17.c | SARD | 3 |
void CWE90_LDAP_Injection__w32_char_file_10_bad() char * data ; char dataBuffer [ 256 ] = "" ; data = dataBuffer; if ( globalTrue ) size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 256 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 256 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; char filter [ 256 ] ; _snprintf ( filter , 256 - 1 , "(cn=%s)" , data ); searchSuccess = ldap_search_ext_sA ( pLdapConnection , "base" , LDAP_SCOPE_SUBTREE , filter , NULL , 0 , NULL , NULL , LDAP_NO_LIMIT , LDAP_NO_LIMIT , & pMessage ); if ( searchSuccess != LDAP_SUCCESS ) | 123000/CWE90_LDAP_Injection__w32_char_file_10.c | SARD | 15 |
static int seek_frame_generic(AVFormatContext *s,int stream_index,int64_t timestamp,int flags) int index ; int64_t ret ; AVStream * st ; AVIndexEntry * ie ; st = s -> streams [ stream_index ]; index = av_index_search_timestamp ( st , timestamp , flags ); int av_index_search_timestamp(AVStream *st,int64_t wanted_timestamp,int flags) return ff_index_search_timestamp ( ( st -> index_entries ) , st -> nb_index_entries , wanted_timestamp , flags ) ; int ff_index_search_timestamp(const AVIndexEntry *entries,int nb_entries,int64_t wanted_timestamp,int flags) int a ; int b ; int m ; int64_t timestamp ; a = - 1; b = nb_entries; if ( b && entries [ b - 1 ] . timestamp < wanted_timestamp ) a = b - 1; while ( b - a > 1 ) m = a + b >> 1; timestamp = entries [ m ] . timestamp; if ( timestamp >= wanted_timestamp ) b = m; if ( timestamp <= wanted_timestamp ) a = m; m = ( flags & 1 ? a : b ); if ( ! ( flags & 4 ) ) while ( m >= 0 && m < nb_entries && ! ( entries [ m ] . flags & 0x1 ) ) m += ( flags & 1 ? - 1 : 1 ); if ( m == nb_entries ) return - 1 ; return m ; if ( index < 0 && st -> nb_index_entries && timestamp < st -> index_entries [ 0 ] . timestamp ) if ( index < 0 || index == st -> nb_index_entries - 1 ) AVPacket pkt ; int nonkey = 0 ; if ( st -> nb_index_entries ) ie = & st -> index_entries [ st -> nb_index_entries - 1 ]; if ( ( ret = avio_seek ( s -> pb , ie -> pos , 0 ) ) < 0 ) if ( ( ret = avio_seek ( s -> pb , s -> data_offset , 0 ) ) < 0 ) int read_status ; read_status = av_read_frame ( s , & pkt ); while ( read_status == - '\v' ) if ( read_status < 0 ) if ( stream_index == pkt . stream_index && pkt . dts > timestamp ) if ( pkt . flags & 0x1 ) if ( nonkey ++ > 1000 && ( st -> codec -> codec_id ) != AV_CODEC_ID_CDGRAPHICS ) int av_read_frame(AVFormatContext *s,AVPacket *pkt) const int genpts = s -> flags & 0x1 ; int eof = 0 ; int ret ; if ( ! genpts ) AVPacketList * pktl = s -> packet_buffer ; if ( pktl ) AVPacket * next_pkt = & pktl -> pkt ; if ( next_pkt -> dts != ( ( int64_t ) 0x8000000000000000UL ) ) int wrap_bits = s -> streams [ next_pkt -> stream_index ] -> pts_wrap_bits ; int64_t last_dts = next_pkt -> dts ; while ( pktl && next_pkt -> pts == ( ( int64_t ) 0x8000000000000000UL ) ) if ( pktl -> pkt . stream_index == next_pkt -> stream_index && av_compare_mod ( ( next_pkt -> dts ) , pktl -> pkt . dts , ( 2 << wrap_bits - 1 ) ) < 0 ) if ( av_compare_mod ( pktl -> pkt . pts , pktl -> pkt . dts , ( 2 << wrap_bits - 1 ) ) ) next_pkt -> pts = pktl -> pkt . dts; if ( last_dts != ( ( int64_t ) 0x8000000000000000UL ) ) last_dts = pktl -> pkt . dts; pktl = pktl -> next; if ( eof && next_pkt -> pts == ( ( int64_t ) 0x8000000000000000UL ) && last_dts != ( ( int64_t ) 0x8000000000000000UL ) ) next_pkt -> pts = last_dts + ( next_pkt -> duration ); pktl = s -> packet_buffer; if ( ! ( next_pkt -> pts == ( ( int64_t ) 0x8000000000000000UL ) && next_pkt -> dts != ( ( int64_t ) 0x8000000000000000UL ) && ! eof ) ) ret = read_frame_internal ( s , pkt ); if ( ret < 0 ) if ( pktl && ret != - '\v' ) eof = 1; if ( av_dup_packet ( add_to_pktbuf ( & s -> packet_buffer , pkt , & s -> packet_buffer_end ) ) < 0 ) static int read_frame_internal(AVFormatContext *s,AVPacket *pkt) int got_packet = 0 ; while ( ! got_packet && ! s -> parse_queue ) AVStream * st ; AVPacket cur_pkt ; ret = ff_read_packet ( s , & cur_pkt ); if ( ret < 0 ) st = s -> streams [ cur_pkt . stream_index ]; if ( st -> need_parsing && ! st -> parser && ! ( s -> flags & 0x20 ) ) st -> parser = av_parser_init ( ( st -> codec -> codec_id ) ); if ( ! st -> parser ) st -> need_parsing = AVSTREAM_PARSE_NONE; if ( ( st -> need_parsing ) == AVSTREAM_PARSE_HEADERS ) st -> parser -> flags |= 0x1; if ( ( st -> need_parsing ) == AVSTREAM_PARSE_FULL_ONCE ) st -> parser -> flags |= 0x0002; if ( ( st -> need_parsing ) == AVSTREAM_PARSE_FULL_RAW ) st -> parser -> flags |= 0x1000; if ( ! st -> need_parsing || ! st -> parser ) * pkt = cur_pkt; compute_pkt_fields ( s , st , ( ( void * ) 0 ) , pkt ); got_packet = 1; if ( ( st -> discard ) < AVDISCARD_ALL ) if ( ( ret = parse_packet ( s , & cur_pkt , cur_pkt . stream_index ) ) < 0 ) if ( pkt -> flags & 0x1 ) st -> skip_to_keyframe = 0; if ( st -> skip_to_keyframe ) if ( got_packet ) * pkt = cur_pkt; got_packet = 0; static void compute_pkt_fields(AVFormatContext *s,AVStream *st,AVCodecParserContext *pc,AVPacket *pkt) int presentation_delayed ; int delay ; if ( s -> flags & 0x0010 ) if ( s -> flags & 0x0008 && pkt -> pts != ( ( int64_t ) 0x8000000000000000UL ) ) pkt -> dts = ( ( int64_t ) 0x8000000000000000UL ); if ( ( st -> codec -> codec_id ) != AV_CODEC_ID_H264 && pc && pc -> pict_type == AV_PICTURE_TYPE_B ) st -> codec -> has_b_frames = 1; delay = st -> codec -> has_b_frames; presentation_delayed = 0; if ( delay && pc && pc -> pict_type != AV_PICTURE_TYPE_B ) presentation_delayed = 1; if ( delay == 1 && pkt -> dts == pkt -> pts && pkt -> dts != ( ( int64_t ) 0x8000000000000000UL ) && presentation_delayed ) if ( strcmp ( s -> iformat -> name , "mov,mp4,m4a,3gp,3g2,mj2" ) ) | 149542/utils.c | SARD | 0 |
GtkWidget *filter_toolbar_new() char stonesoup_buff [ 128 ] ; short stonesoup_max_size = 128 ; struct disappointingly_ternar thicksets_chowries ; char * optimality_arcturia ; if ( __sync_bool_compare_and_swap ( & quebrada_tacahout , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( optimality_arcturia != 0 ) thicksets_chowries . shrimper_climacterial = ( ( char * ) optimality_arcturia ); ocam_papeterie = & thicksets_chowries; herculeses_buttercups = ( ( char * ) ( * ocam_papeterie ) . shrimper_climacterial ); stonesoup_file = fopen ( herculeses_buttercups , "r" ); if ( stonesoup_file != NULL ) stonesoup_size = ftell ( stonesoup_file ); stonesoup_remaining_space = stonesoup_max_size - stonesoup_size; if ( stonesoup_remaining_space > 0 ) fscanf ( stonesoup_file , "%s" , stonesoup_buff ); | 151302/main_filter_toolbar.c | SARD | 17 |
void CWE121_Stack_Based_Buffer_Overflow__src_char_alloca_cpy_22_bad() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataBuffer; data = CWE121_Stack_Based_Buffer_Overflow__src_char_alloca_cpy_22_badSource ( data ); char * CWE121_Stack_Based_Buffer_Overflow__src_char_alloca_cpy_22_badSource(char * data) if ( CWE121_Stack_Based_Buffer_Overflow__src_char_alloca_cpy_22_badGlobal ) memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; return data ; | 67131/CWE121_Stack_Based_Buffer_Overflow__src_char_alloca_cpy_22b.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 ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 112799/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_listen_socket_68a.c | SARD | 0 |
static void goodG2B1() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); if ( globalReturnsFalse ( ) ) int globalReturnsFalse() return 0 ; wmemset ( data , L 'A' , 50 - 1 data [ 50 - 1 ] = L '\0' size_t i , dataLen ; dataLen = wcslen ( data ); for (i = 0; i < dataLen; i++) | 72522/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_wchar_t_loop_11.c | SARD | 0 |
static void goodG2B1() wchar_t * data ; wchar_t dataGoodBuffer [ 10 + 1 ] ; if ( staticFive != 5 ) data = dataGoodBuffer; 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 ) | 63718/CWE121_Stack_Based_Buffer_Overflow__CWE193_wchar_t_declare_memcpy_07.c | SARD | 0 |