func
stringlengths 181
23.6k
| path
stringlengths 12
123
| source
stringclasses 2
values | label
int64 0
40
|
---|---|---|---|
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) badSink_b ( data ); void badSink_b(char * data) badSink_c ( data ); void badSink_c(char * data) badSink_d ( data ); void badSink_d(char * data) inputFile . open ( ( char * ) data ); | 96577/CWE36_Absolute_Path_Traversal__char_listen_socket_ifstream_53a.cpp | SARD | 0 |
void CWE401_Memory_Leak__malloc_realloc_twoIntsStruct_09_bad() if ( GLOBAL_CONST_TRUE ) twoIntsStruct * data = ( twoIntsStruct * ) malloc ( 100 * sizeof ( twoIntsStruct ) ) ; data [ 0 ] . intOne = 0; data [ 0 ] . intTwo = 0; data = ( twoIntsStruct * ) realloc ( data , ( 130000 ) * sizeof ( twoIntsStruct ) ); if ( data != NULL ) data [ 0 ] . intOne = 1; data [ 0 ] . intTwo = 1; free ( data ); | 99714/CWE401_Memory_Leak__malloc_realloc_twoIntsStruct_09.c | SARD | 29 |
void bad() char * data ; data = NULL; if ( GLOBAL_CONST_FIVE == 5 ) data = new char [ 10 ]; char source [ 10 + 1 ] = SRC_STRING ; strncpy ( data , source , strlen ( source ) + 1 ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); delete [ ] data | 68012/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE193_char_ncpy_13.cpp | SARD | 3 |
void CWE78_OS_Command_Injection__char_console_w32_spawnvp_34_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; data [ dataLen ] = '\0'; myUnion . unionFirst = data; char * data = myUnion . unionSecond ; | 118830/CWE78_OS_Command_Injection__char_console_w32_spawnvp_34.c | SARD | 0 |
static void goodG2B1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( GLOBAL_CONST_FIVE != 5 ) strcpy ( data , "fixedstringtest" ); if ( GLOBAL_CONST_FIVE == 5 ) 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 ); | 79926/CWE134_Uncontrolled_Format_String__char_environment_w32_vsnprintf_13.c | SARD | 0 |
static void goodG2B1() wchar_t * data ; switch ( 5 ) wmemset ( data , L 'A' , 100 - 1 data [ 100 - 1 ] = L '\0' size_t i , destLen ; wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' destLen = wcslen ( dest ); for (i = 0; i < destLen; i++) | 76392/CWE126_Buffer_Overread__malloc_wchar_t_loop_15.c | SARD | 0 |
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 ) ; if ( 100 - dataLen > 1 ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) data [ dataLen - 1 ] = L '\0' data [ dataLen ] = L '\0' size_t dataLen = wcslen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) | 109229/CWE606_Unchecked_Loop_Condition__wchar_t_console_12.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncpy_07_bad() wchar_t * data ; if ( staticFive == 5 ) data = ( wchar_t * ) malloc ( 50 * sizeof ( wchar_t ) ); wcsncpy ( data , source , 100 - 1 ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 72134/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncpy_07.c | SARD | 3 |
void CWE122_Heap_Based_Buffer_Overflow__sizeof_struct_08_bad() twoIntsStruct * data ; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; data = ( twoIntsStruct * ) malloc ( sizeof ( data ) ); data -> intOne = 1; data -> intTwo = 2; printStructLine ( data ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); free ( data ); | 73329/CWE122_Heap_Based_Buffer_Overflow__sizeof_struct_08.c | SARD | 3 |
static void goodG2B() wchar_t * data ; data = NULL; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; data = ( wchar_t * ) malloc ( ( 10 + 1 ) * sizeof ( wchar_t ) ); data = ( wchar_t * ) malloc ( ( 10 + 1 ) * sizeof ( wchar_t ) ); wchar_t source [ 10 + 1 ] = SRC_STRING ; memcpy ( data , source , ( wcslen ( source ) + 1 ) * sizeof ( wchar_t ) ); free ( data ); | 71083/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_wchar_t_memcpy_12.c | SARD | 0 |
static void rtl8139_io_writel(void *opaque, uint8_t addr, uint32_t val) switch ( addr ) rtl8139_io_writeb ( opaque , addr , val & 0xff ); static void rtl8139_io_writeb(void *opaque, uint8_t addr, uint32_t val) RTL8139State * s = opaque ; switch ( addr ) if ( val == 'R' ) if ( val == 'H' ) s -> clock_enabled = 0; s -> TxThresh = val; if ( val & ( 1 << 6 ) ) rtl8139_cplus_transmit ( s ); static void rtl8139_cplus_transmit(RTL8139State *s) while ( rtl8139_cplus_transmit_one ( s ) ) static int rtl8139_cplus_transmit_one(RTL8139State *s) if ( ! rtl8139_transmitter_enabled ( s ) ) if ( ! rtl8139_cp_transmitter_enabled ( s ) ) uint32_t val , txdw0 , txdw1 , txbufLO , txbufHI ; txdw0 = le32_to_cpu ( val ); if ( ! ( txdw0 & CP_TX_OWN ) ) if ( txdw0 & CP_TX_FS ) s -> cplus_txbuffer_offset = 0; int txsize = txdw0 & CP_TX_BUFFER_SIZE_MASK ; if ( ! s -> cplus_txbuffer ) s -> cplus_txbuffer_len = CP_TX_BUFFER_SIZE; s -> cplus_txbuffer = g_malloc ( s -> cplus_txbuffer_len ); s -> cplus_txbuffer_offset = 0; if ( s -> cplus_txbuffer_offset + txsize >= s -> cplus_txbuffer_len ) txsize = s -> cplus_txbuffer_len - s -> cplus_txbuffer_offset; s -> cplus_txbuffer_offset += txsize; if ( txdw0 & CP_TX_EOR ) s -> currCPlusTxDesc = 0; if ( s -> currCPlusTxDesc >= 64 ) s -> currCPlusTxDesc = 0; txdw0 &= ~CP_RX_OWN; txdw0 &= ~CP_TX_STATUS_UNF; txdw0 &= ~CP_TX_STATUS_TES; txdw0 &= ~CP_TX_STATUS_OWC; txdw0 &= ~CP_TX_STATUS_LNKF; txdw0 &= ~CP_TX_STATUS_EXC; if ( txdw0 & CP_TX_LS ) uint8_t * saved_buffer = s -> cplus_txbuffer ; if ( txdw0 & ( CP_TX_IPCS | CP_TX_UDPCS | CP_TX_TCPCS | CP_TX_LGSEN ) ) ip_header * ip = NULL ; int hlen = 0 ; uint8_t ip_protocol = 0 ; uint8_t * eth_payload_data = NULL ; int proto = be16_to_cpu ( * ( uint16_t * ) ( saved_buffer + 12 ) ) ; if ( proto == ETH_P_IP ) eth_payload_data = saved_buffer + ETH_HLEN; ip = ( ip_header * ) eth_payload_data; if ( IP_HEADER_VERSION ( ip ) != IP_HEADER_VERSION_4 ) ip = NULL; hlen = IP_HEADER_LENGTH ( ip ); ip_protocol = ip -> ip_p; if ( ip ) if ( ( txdw0 & CP_TX_LGSEN ) && ip_protocol == IP_PROTO_TCP ) if ( txdw0 & ( CP_TX_TCPCS | CP_TX_UDPCS ) ) uint8_t saved_ip_header [ 60 ] ; memcpy ( saved_ip_header , eth_payload_data , hlen ); memcpy ( data_to_checksum , saved_ip_header + 12 , 8 ); ip_pseudo_header * p_tcpip_hdr = ( ip_pseudo_header * ) data_to_checksum ; p_tcpip_hdr -> zeros = 0; p_tcpip_hdr -> ip_proto = IP_PROTO_TCP; p_tcpip_hdr -> ip_payload = cpu_to_be16 ( ip_data_len ); tcp_header * p_tcp_hdr = ( tcp_header * ) ( data_to_checksum + 12 ) ; p_tcp_hdr -> th_sum = 0; int tcp_checksum = ip_checksum ( data_to_checksum , ip_data_len + 12 ) ; DPRINTF ( "+++ C+ mode TCP checksum %04x\n" , tcp_checksum ); p_tcp_hdr -> th_sum = tcp_checksum; ip_pseudo_header * p_udpip_hdr = ( ip_pseudo_header * ) data_to_checksum ; p_udpip_hdr -> zeros = 0; p_udpip_hdr -> ip_proto = IP_PROTO_UDP; p_udpip_hdr -> ip_payload = cpu_to_be16 ( ip_data_len ); udp_header * p_udp_hdr = ( udp_header * ) ( data_to_checksum + 12 ) ; p_udp_hdr -> uh_sum = 0; int udp_checksum = ip_checksum ( data_to_checksum , ip_data_len + 12 ) ; DPRINTF ( "+++ C+ mode UDP checksum %04x\n" , udp_checksum ); p_udp_hdr -> uh_sum = udp_checksum; memcpy ( eth_payload_data , saved_ip_header , hlen ); | CVE-2016-8910/qemu_2.3.0_CVE-2016-8910_rtl8139.c | NVD | 0 |
static void goodG2B2() wchar_t * data ; wchar_t * dataGoodBuffer = ( wchar_t * ) ALLOCA ( 100 * sizeof ( wchar_t ) ) ; if ( STATIC_CONST_FIVE == 5 ) data = dataGoodBuffer; data [ 0 ] = L '\0' wchar_t source [ 100 ] ; wmemset ( source , L 'C' , 100 - 1 source [ 100 - 1 ] = L '\0' memcpy ( data , source , 100 * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 65077/CWE121_Stack_Based_Buffer_Overflow__CWE805_wchar_t_alloca_memcpy_06.c | SARD | 0 |
static void goodB2G2() if ( globalFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( data != 0 ) printIntLine ( 100 / data ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 95263/CWE369_Divide_by_Zero__int_listen_socket_divide_14.c | SARD | 0 |
static void goodG2B() char * cryptoKey ; char cryptoKeyBuffer [ 100 ] = "" ; cryptoKey = cryptoKeyBuffer; size_t cryptoKeyLen = strlen ( cryptoKey ) ; if ( 100 - cryptoKeyLen > 1 ) if ( fgets ( cryptoKey + cryptoKeyLen , ( int ) ( 100 - cryptoKeyLen ) , stdin ) == NULL ) cryptoKey [ cryptoKeyLen ] = '\0'; cryptoKeyLen = strlen ( cryptoKey ); if ( cryptoKeyLen > 0 ) cryptoKey [ cryptoKeyLen - 1 ] = '\0'; baseObject -> action ( cryptoKey ); void CWE321_Hard_Coded_Cryptographic_Key__w32_char_82_goodG2B::action(char * cryptoKey) if ( ! CryptHashData ( hHash , ( BYTE * ) cryptoKey , strlen ( cryptoKey ) * sizeof ( char ) , 0 ) ) | 94335/CWE321_Hard_Coded_Cryptographic_Key__w32_char_82a.cpp | SARD | 0 |
int main(int argc, char *argv[]) unsigned i ; if ( fork ( ) ) for (i=0;i<3;++i) pid = fork ( ); if ( pid == 0 ) pid = getpid ( ); handler ( pid ); void handler(int curPid) struct stat fileStat ; fprintf ( stdout , "(%d) Start handler...\n" , curPid ); if ( stat ( fName , & fileStat ) ) if ( fileStat . st_size > 2048 ) fprintf ( stdout , "(%d) Stop handler...\n" , curPid ); | 149231/race_stat_basic-bad.c | SARD | 0 |
void tile_swap_out(Tile *tile) tile_swap_command ( tile , SWAP_OUT ); static void tile_swap_command(Tile *tile,gint command) if ( gimp_swap_file -> fd == - 1 ) if ( gimp_swap_file -> fd == - 1 ) switch ( command ) tile_swap_default_out ( gimp_swap_file , tile ); static void tile_swap_default_out(SwapFile *swap_file,Tile *tile) gint bytes ; gint nleft ; gint64 offset ; gint64 newpos ; bytes = 64 * 64 * ( tile -> bpp ); if ( tile -> swap_offset == ( - 1 ) ) newpos = tile_swap_find_offset ( swap_file , bytes ); newpos = tile -> swap_offset; if ( swap_file -> cur_position != newpos ) offset = lseek ( swap_file -> fd , newpos , 0 ); if ( offset == ( - 1 ) ) swap_file -> cur_position = newpos; nleft = tile -> size; while ( nleft > 0 ) gint err = ( write ( swap_file -> fd , ( tile -> data + tile -> size - nleft ) , nleft ) ) ; if ( err <= 0 ) g_log ( "Gimp-Base" , G_LOG_LEVEL_MESSAGE , "unable to write tile data to disk: %s (%d/%d bytes written)" , g_strerror ( * __errno_location ( ) ) , err , nleft ); nleft -= err; | 152156/tile-swap.c | SARD | 0 |
void bad() wchar_t * data ; wchar_t * & dataRef = data ; data = NULL; static wchar_t dataBuffer [ 100 ] ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer; wchar_t * data = dataRef ; free ( data ); | 108796/CWE590_Free_Memory_Not_on_Heap__free_wchar_t_static_33.cpp | SARD | 1 |
static token lex() unsigned int c ; int backslash = 0 ; charclass ccl ; int i ; for (i = 0; i < 2; ++i) if ( __ctype_get_mb_cur_max ( ) > 1 ) if ( ! lexleft ) if ( ( ( void * ) 0 ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) wctok = ( c = ( to_uchar ( * ( lexptr ++ ) ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wctok = _wc; c = ( wctob ( wctok ) ); while ( 0 ) if ( ( ( int ) c ) == - 1 ) wint_t wc ; if ( ! lexleft ) if ( ( ( void * ) 0 ) != 0 ) wchar_t _wc ; cur_mb_len = ( mbrtowc ( & _wc , lexptr , lexleft , & mbs ) ); if ( cur_mb_len <= 0 ) wc = c = ( to_uchar ( * ( lexptr ++ ) ) ); lexptr += cur_mb_len; lexleft -= cur_mb_len; wc = _wc; c = ( wctob ( wc ) ); while ( 0 ) while ( 0 ) switch ( c ) if ( backslash ) backslash = 1; if ( ! backslash || syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) return lasttok = ( CSET + charclass_index ( ccl ) ) ; static size_t charclass_index(const int s[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) size_t i ; for (i = 0; i < dfa -> cindex; ++i) if ( equal ( s , dfa -> charclasses [ i ] ) ) 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 ; | 153171/dfa.c | SARD | 0 |
static void goodB2G() if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; count = atoi ( inputBuffer ); while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); if ( count > 0 && count <= 2000 ) SLEEP ( count ); if ( count > 0 && count <= 2000 ) SLEEP ( count ); | 98588/CWE400_Resource_Exhaustion__connect_socket_sleep_12.c | SARD | 0 |
static void goodG2B1() char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; dest [ i ] = data [ i ]; dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77287/CWE127_Buffer_Underread__char_alloca_loop_06.c | SARD | 0 |
gboolean gimp_display_shell_get_show_sample_points(GimpDisplayShell *shell) int depickle_proalliance = 7 ; int flubs_stirpes ; char * academize_unambition [ 10 ] = { 0 } ; char * omagra_daffodil ; if ( __sync_bool_compare_and_swap ( & dissolutely_oxydactyl , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) if ( omagra_daffodil != 0 ) monotron_scantle = ( ( int ) ( strlen ( omagra_daffodil ) ) ); parfumeur_tibetan = ( ( char * ) ( malloc ( monotron_scantle + 1 ) ) ); memset ( parfumeur_tibetan , 0 , monotron_scantle + 1 ); memcpy ( parfumeur_tibetan , omagra_daffodil , monotron_scantle ); academize_unambition [ 5 ] = parfumeur_tibetan; flubs_stirpes = 5; coryphasia_bromeikon = & flubs_stirpes; semiporcelain_variedness = * ( academize_unambition + * coryphasia_bromeikon ); aouads_brian ( depickle_proalliance , semiporcelain_variedness ); void aouads_brian(int reaware_comparability,char *selenous_grit) struct stonesoup_data * stonesoupData ; reaware_comparability --; if ( reaware_comparability > 0 ) tauting_ungreased = ( ( char * ) selenous_grit ); stonesoupData = malloc ( sizeof ( struct stonesoup_data ) ); if ( stonesoupData ) stonesoupData -> data = malloc ( sizeof ( char ) * ( strlen ( tauting_ungreased ) + 1 ) ); stonesoupData -> file1 = malloc ( sizeof ( char ) * ( strlen ( tauting_ungreased ) + 1 ) ); stonesoupData -> file2 = malloc ( sizeof ( char ) * ( strlen ( tauting_ungreased ) + 1 ) ); if ( stonesoupData -> data && stonesoupData -> file1 && stonesoupData -> file2 ) if ( ( sscanf ( tauting_ungreased , "%d %s %s %s" , & ( stonesoupData -> qsize ) , stonesoupData -> file1 , stonesoupData -> file2 , stonesoupData -> data ) == 4 ) && ( strlen ( stonesoupData -> data ) != 0 ) ) stonesoupData -> data_size = strlen ( stonesoupData -> data ); free ( stonesoupData ); | 150258/gimpdisplayshell-appearance.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_connect_socket_fprintf_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 ) 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'; while ( 0 ) CWE134_Uncontrolled_Format_String__char_connect_socket_fprintf_51b_badSink ( data ); void CWE134_Uncontrolled_Format_String__char_connect_socket_fprintf_51b_badSink(char * data) fprintf ( stdout , data ); | 79127/CWE134_Uncontrolled_Format_String__char_connect_socket_fprintf_51b.c | SARD | 15 |
static void goodB2G() int count ; count = - 1; CWE400_Resource_Exhaustion__rand_fwrite_84_goodB2G * goodB2GObject = new CWE400_Resource_Exhaustion__rand_fwrite_84_goodB2G ( count ) ; CWE400_Resource_Exhaustion__rand_fwrite_84_goodB2G::CWE400_Resource_Exhaustion__rand_fwrite_84_goodB2G(int countCopy) count = countCopy; count = RAND32 ( ); delete goodB2GObject CWE400_Resource_Exhaustion__rand_fwrite_84_goodB2G::~CWE400_Resource_Exhaustion__rand_fwrite_84_goodB2G() const char * filename = "output_good.txt" ; if ( count > 0 && count <= 20 ) pFile = fopen ( filename , "w+" ); if ( pFile ) fclose ( pFile ); | 99152/CWE400_Resource_Exhaustion__rand_fwrite_84_goodB2G.cpp | SARD | 0 |
void av_pkt_dump2(FILE *f,AVPacket *pkt,int dump_payload,AVStream *st) pkt_dump_internal ( ( ( void * ) 0 ) , f , 0 , pkt , dump_payload , st -> time_base ); static void pkt_dump_internal(void *avcl,FILE *f,int level,AVPacket *pkt,int dump_payload,AVRational time_base) if ( pkt -> dts == ( ( int64_t ) 0x8000000000000000UL ) ) if ( ! f ) fprintf ( f , "%0.3f" , ( pkt -> dts ) * av_q2d ( time_base ) ); while ( 0 ) if ( ! f ) fprintf ( f , " pts=" ); if ( ! f ) fprintf ( f , "N/A" ); | 149542/utils.c | SARD | 0 |
CWE78_OS_Command_Injection__char_listen_socket_w32_spawnv_83_bad::CWE78_OS_Command_Injection__char_listen_socket_w32_spawnv_83_bad(char * dataCopy) data = dataCopy; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 120293/CWE78_OS_Command_Injection__char_listen_socket_w32_spawnv_83_bad.cpp | SARD | 0 |
static void build_state_zero(struct dfa *d) d -> tralloc = 1; d -> trcount = 0; d -> realtrans = ( ( sizeof ( ( * d -> realtrans ) ) == 1 ? xzalloc ( ( d -> tralloc + 1 ) ) : xcalloc ( ( d -> tralloc + 1 ) , sizeof ( ( * d -> realtrans ) ) ) ) ); while ( 0 ) d -> trans = d -> realtrans + 1; d -> fails = ( ( sizeof ( ( * d -> fails ) ) == 1 ? xzalloc ( ( d -> tralloc ) ) : xcalloc ( ( d -> tralloc ) , sizeof ( ( * d -> fails ) ) ) ) ); while ( 0 ) d -> success = ( ( sizeof ( ( * d -> success ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> success ) ) ) ) ); while ( 0 ) d -> newlines = ( ( sizeof ( ( * d -> newlines ) ) == 1 ? xmalloc ( ( d -> tralloc ) ) : xnmalloc ( ( d -> tralloc ) , sizeof ( ( * d -> newlines ) ) ) ) ); while ( 0 ) build_state ( 0 , d ); static void build_state(state_num s,struct dfa *d) state_num * trans ; state_num i ; if ( d -> trcount >= 1024 ) for (i = 0; i < d -> tralloc; ++i) d -> trans [ i ] = d -> fails [ i ] = ( ( void * ) 0 ); d -> trcount = 0; d -> success [ s ] = 0; if ( ( ( ( 4 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 4; if ( ( ( ( 2 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 2; if ( ( ( ( 1 & 1 ? ( * d ) . states [ s ] . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? ( * d ) . states [ s ] . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? ( * d ) . states [ s ] . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) d -> success [ s ] |= 1; trans = ( ( sizeof ( ( * trans ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * trans ) ) ) ) ); while ( 0 ) dfastate ( s , d , trans ); void dfastate(state_num s,struct dfa *d,token trans[]) leaf_set * grps ; charclass * labels ; size_t ngrps = 0 ; position pos ; charclass matches ; int matchesf ; charclass intersect ; int intersectf ; charclass leftovers ; int leftoversf ; size_t i ; size_t j ; size_t k ; grps = ( ( sizeof ( ( * grps ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * grps ) ) ) ) ); while ( 0 ) labels = ( ( sizeof ( ( * labels ) ) == 1 ? xmalloc ( ( 1 << 8 ) ) : xnmalloc ( ( 1 << 8 ) , sizeof ( ( * labels ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . elems . nelem; ++i) pos = d -> states [ s ] . elems . elems [ i ]; if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) ) if ( d -> tokens [ pos . index ] >= CSET ) if ( pos . constraint != 0x777 ) if ( ! ( ( ( ( 4 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 4 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 4 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~newline [ j ]; if ( ! ( ( ( ( 2 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 2 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 2 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= ~letters [ j ]; if ( ! ( ( ( ( 1 & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( 1 & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( 1 & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) for (j = 0; j < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++j) matches [ j ] &= letters [ j ] | newline [ j ]; if ( j == ( ( 1 << 8 ) + 8 * sizeof ( int ) - 1 ) / ( 8 * sizeof ( int ) ) ) for (j = 0; j < ngrps; ++j) if ( d -> tokens [ pos . index ] >= 0 && d -> tokens [ pos . index ] < ( 1 << 8 ) && ! tstbit ( d -> tokens [ pos . index ] , labels [ j ] ) ) intersectf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) ( intersect [ k ] = matches [ k ] & labels [ j ] [ k ] ) ? ( intersectf = 1 ) : 0; if ( ! intersectf ) leftoversf = matchesf = 0; for (k = 0; k < ((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int )); ++k) int match = matches [ k ] ; int label = labels [ j ] [ k ] ; ( leftovers [ k ] = ~match & label ) ? ( leftoversf = 1 ) : 0; ( matches [ k ] = match & ~label ) ? ( matchesf = 1 ) : 0; if ( leftoversf ) grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = grps [ j ] . nelem; grps [ j ] . elems [ grps [ j ] . nelem ++ ] = pos . index; if ( ! matchesf ) if ( j == ngrps ) zeroset ( matches ); grps [ ngrps ] . elems = ( ( sizeof ( ( * grps [ ngrps ] . elems ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * grps [ ngrps ] . elems ) ) ) ) ); while ( 0 ) grps [ ngrps ] . nelem = 1; grps [ ngrps ] . elems [ 0 ] = pos . index; static void zeroset(charclass s) memset ( s , 0 , sizeof ( charclass ) ); | 152758/dfa.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_file_vfprintf_44_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 ); funcPtr ( data , data ); | 80133/CWE134_Uncontrolled_Format_String__char_file_vfprintf_44.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_environment_w32_vsnprintf_13_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( GLOBAL_CONST_FIVE == 5 ) size_t dataLen = strlen ( data ) ; strncat ( data + dataLen , environment , 100 - dataLen - 1 ); badVaSinkB ( data , data ); static void badVaSinkB(char * data, ...) va_start ( args , data ); vsnprintf ( dest , 100 - 1 , data , args ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 79926/CWE134_Uncontrolled_Format_String__char_environment_w32_vsnprintf_13.c | SARD | 15 |
void CWE78_OS_Command_Injection__char_environment_system_03_bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; if ( 5 == 5 ) size_t dataLen = strlen ( data ) ; char * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) strncat ( data + dataLen , environment , 100 - dataLen - 1 ); if ( SYSTEM ( data ) <= 0 ) | 119049/CWE78_OS_Command_Injection__char_environment_system_03.c | SARD | 15 |
ArrayType::Setter(JSContext* cx, HandleObject obj, HandleId idval, bool strict, MutableHandleValue vp) if ( ! CData :: IsCData ( obj ) ) JSObject * typeObj = CData :: GetCType ( obj ) ; if ( CType :: GetTypeCode ( typeObj ) != TYPE_array ) size_t index ; size_t length = GetLength ( typeObj ) ; bool ok = jsidToSize ( cx , idval , true , & index ) ; int32_t dummy ; if ( ! ok && JSID_IS_STRING ( idval ) && ! StringToInteger ( cx , JSID_TO_STRING ( idval ) , & dummy ) ) if ( ! ok || index >= length ) JSObject * baseType = GetBaseType ( typeObj ) ; char * data = static_cast < char * > ( CData :: GetData ( obj ) ) + elementSize * index return ImplicitConvert ( cx , vp , baseType , data , false , nullptr ) ; static ImplicitConvert(JSContext* HandleValue JSObject* void* bool bool* freePointer) RootedObject targetType ( cx , targetType_ ) ; JSObject * sourceData = nullptr ; JSObject * sourceType = nullptr ; RootedObject valObj ( cx , nullptr ) ; if ( val . isObject ( ) ) valObj = & val . toObject ( ); if ( CData :: IsCData ( valObj ) ) sourceData = valObj; sourceType = CData :: GetCType ( sourceData ); if ( CType :: TypesEqual ( sourceType , targetType ) ) if ( CDataFinalizer :: IsCDataFinalizer ( valObj ) ) sourceData = valObj; sourceType = CDataFinalizer :: GetCType ( cx , sourceData ); CDataFinalizer :: Private * p = ( CDataFinalizer :: Private * ) JS_GetPrivate ( sourceData ) ; if ( ! p ) if ( CType :: TypesEqual ( sourceType , targetType ) ) TypeCode targetCode = CType :: GetTypeCode ( targetType ) ; switch ( targetCode ) if ( val . isNull ( ) ) JS :: Rooted < JSObject * > baseType ( cx , PointerType :: GetBaseType ( targetType ) ) ; if ( sourceData ) TypeCode sourceCode = CType :: GetTypeCode ( sourceType ) ; bool voidptrTarget = CType :: GetTypeCode ( baseType ) == TYPE_void_t ; if ( sourceCode == TYPE_pointer && voidptrTarget ) if ( sourceCode == TYPE_array ) JSObject * elementType = ArrayType :: GetBaseType ( sourceType ) ; if ( voidptrTarget || CType :: TypesEqual ( baseType , elementType ) ) * static_cast < void * * > ( buffer ) = sourceBuffer if ( isArgument && val . isString ( ) ) if ( val . isObject ( ) && JS_IsArrayBufferObject ( valObj ) ) if ( val . isObject ( ) && JS_IsArrayBufferViewObject ( valObj ) ) if ( ! CanConvertTypedArrayItemTo ( baseType , valObj , cx ) ) if ( ! isArgument ) void * ptr ; JS :: AutoCheckCannotGC nogc ; ptr = JS_GetArrayBufferViewData ( valObj , nogc ); if ( ! ptr ) * static_cast < void * * > ( buffer ) = ptr RootedObject baseType ( cx , ArrayType :: GetBaseType ( targetType ) ) ; size_t targetLength = ArrayType :: GetLength ( targetType ) ; if ( val . isString ( ) ) if ( val . isObject ( ) && JS_IsArrayObject ( cx , valObj ) ) uint32_t sourceLength ; if ( ! JS_GetArrayLength ( cx , valObj , & sourceLength ) || targetLength != size_t ( sourceLength ) ) size_t elementSize = CType :: GetSize ( baseType ) ; auto intermediate = cx -> make_pod_array < char > ( arraySize ) if ( ! intermediate ) for (uint32_t i = 0; i < sourceLength; ++i) RootedValue item ( cx ) ; if ( ! JS_GetElement ( cx , valObj , i , & item ) ) char * data = intermediate . get ( ) + elementSize * i ; if ( ! ImplicitConvert ( cx , item , baseType , data , false , nullptr ) ) static ImplicitConvert(JSContext* HandleValue JSObject* void* bool bool* freePointer) RootedObject targetType ( cx , targetType_ ) ; JSObject * sourceData = nullptr ; JSObject * sourceType = nullptr ; RootedObject valObj ( cx , nullptr ) ; if ( val . isObject ( ) ) valObj = & val . toObject ( ); if ( CData :: IsCData ( valObj ) ) sourceData = valObj; sourceType = CData :: GetCType ( sourceData ); if ( CType :: TypesEqual ( sourceType , targetType ) ) if ( CDataFinalizer :: IsCDataFinalizer ( valObj ) ) sourceData = valObj; sourceType = CDataFinalizer :: GetCType ( cx , sourceData ); CDataFinalizer :: Private * p = ( CDataFinalizer :: Private * ) JS_GetPrivate ( sourceData ) ; if ( ! p ) if ( CType :: TypesEqual ( sourceType , targetType ) ) TypeCode targetCode = CType :: GetTypeCode ( targetType ) ; switch ( targetCode ) bool result ; if ( ! jsvalToBool ( cx , val , & result ) ) * static_cast < bool * > ( buffer ) = result type result ; type result ; type result ; if ( ! jsvalToFloat ( cx , val , & result ) ) * static_cast < type * > ( buffer ) = result if ( val . isNull ( ) ) * static_cast < void * * > ( buffer ) = nullptr JS :: Rooted < JSObject * > baseType ( cx , PointerType :: GetBaseType ( targetType ) ) ; if ( sourceData ) TypeCode sourceCode = CType :: GetTypeCode ( sourceType ) ; bool voidptrTarget = CType :: GetTypeCode ( baseType ) == TYPE_void_t ; if ( sourceCode == TYPE_pointer && voidptrTarget ) if ( sourceCode == TYPE_array ) JSObject * elementType = ArrayType :: GetBaseType ( sourceType ) ; if ( voidptrTarget || CType :: TypesEqual ( baseType , elementType ) ) * static_cast < void * * > ( buffer ) = sourceBuffer if ( isArgument && val . isString ( ) ) if ( val . isObject ( ) && JS_IsArrayBufferObject ( valObj ) ) if ( val . isObject ( ) && JS_IsArrayBufferViewObject ( valObj ) ) if ( ! CanConvertTypedArrayItemTo ( baseType , valObj , cx ) ) if ( ! isArgument ) void * ptr ; JS :: AutoCheckCannotGC nogc ; ptr = JS_GetArrayBufferViewData ( valObj , nogc ); if ( ! ptr ) * static_cast < void * * > ( buffer ) = ptr RootedObject baseType ( cx , ArrayType :: GetBaseType ( targetType ) ) ; size_t targetLength = ArrayType :: GetLength ( targetType ) ; if ( val . isString ( ) ) if ( val . isObject ( ) && JS_IsArrayObject ( cx , valObj ) ) uint32_t sourceLength ; if ( ! JS_GetArrayLength ( cx , valObj , & sourceLength ) || targetLength != size_t ( sourceLength ) ) size_t elementSize = CType :: GetSize ( baseType ) ; size_t arraySize = elementSize * targetLength ; auto intermediate = cx -> make_pod_array < char > ( arraySize ) if ( ! intermediate ) RootedValue item ( cx ) ; if ( ! JS_GetElement ( cx , valObj , i , & item ) ) char * data = intermediate . get ( ) + elementSize * i ; if ( ! ImplicitConvert ( cx , item , baseType , data , false , nullptr ) ) memcpy ( buffer , intermediate . get ( ) , arraySize ); | CVE-2015-2726/Firefox_38.8.0esr_CVE_2015_2726_js_src_ctypes_CTypes.cpp | NVD | 0 |
static void goodG2B() int data ; CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_malloc_34_unionType myUnion ; data = - 1; data = 100 - 1; myUnion . unionFirst = data; int data = myUnion . unionSecond ; if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; free ( dataBuffer ); | 87461/CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_malloc_34.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_file_fprintf_66_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 80000/CWE134_Uncontrolled_Format_String__char_file_fprintf_66a.c | SARD | 0 |
static void goodG2B1() char * data ; char dataBuffer [ 100 ] ; data = dataBuffer; if ( globalReturnsFalse ( ) ) int globalReturnsFalse() return 0 ; memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; size_t i , dataLen ; dataLen = strlen ( data ); for (i = 0; i < dataLen; i++) | 65810/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_loop_11.c | SARD | 0 |
static void goodB2G() char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); goodB2GSink_b ( data ); void goodB2GSink_b(int data) goodB2GSink_c ( data ); void goodB2GSink_c(int data) goodB2GSink_d ( data ); void goodB2GSink_d(int data) if ( data >= 0 && data < ( 10 ) ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); delete [ ] buffer | 67599/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE129_fgets_53a.cpp | SARD | 0 |
static void goodG2B1() char * data ; data = NULL; if ( STATIC_CONST_FIVE != 5 ) data = ( char * ) malloc ( 100 * sizeof ( char ) ); memset ( data , 'A' , 100 - 1 ); data [ 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 ); free ( data ); | 76335/CWE126_Buffer_Overread__malloc_char_memmove_06.c | SARD | 0 |
static void goodG2B() char * data ; CWE134_Uncontrolled_Format_String__char_environment_w32_vsnprintf_34_unionType myUnion ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; strcpy ( data , "fixedstringtest" ); myUnion . unionFirst = data; char * data = myUnion . unionSecond ; goodG2BVaSink ( data , data ); static void goodG2BVaSink(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 ); | 79937/CWE134_Uncontrolled_Format_String__char_environment_w32_vsnprintf_34.c | SARD | 0 |
void CWE427_Uncontrolled_Search_Path_Element__char_connect_socket_52_bad() char * data ; char dataBuffer [ 250 ] = "PATH=" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 250 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 102886/CWE427_Uncontrolled_Search_Path_Element__char_connect_socket_52a.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 ) ); static int *check_matching_with_multibyte_ops(struct dfa *d,state_num s,size_t idx) size_t i ; int * rarray ; rarray = ( ( sizeof ( ( * rarray ) ) == 1 ? xmalloc ( d -> states [ s ] . mbps . nelem ) : xnmalloc ( d -> states [ s ] . mbps . nelem , sizeof ( ( * rarray ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> states[s] . mbps . nelem; ++i) position pos = d -> states [ s ] . mbps . elems [ i ] ; switch ( d -> tokens [ pos . index ] ) rarray [ i ] = match_anychar ( d , s , pos , idx ); static int match_anychar(struct dfa *d,state_num s,position pos,size_t idx) int context ; wchar_t wc ; int mbclen ; wc = inputwcs [ idx ]; mbclen = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) return 0 ; if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) return 0 ; context = wchar_context ( wc ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; if ( ! ( ( ( ( context & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( context & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( context & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) return 0 ; return mbclen ; rarray [ i ] = match_mb_charset ( d , s , pos , idx ); static int match_mb_charset(struct dfa *d,state_num s,position pos,size_t idx) size_t i ; int match ; int match_len ; int op_len ; char buffer [ 128 ] ; struct mb_char_classes * work_mbc ; int context ; wchar_t wc ; wc = inputwcs [ idx ]; if ( wc == ( ( wchar_t ) eolbyte ) ) if ( ! ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 ) ) return 0 ; if ( wc == ( ( wchar_t ) '\0' ) ) if ( syntax_bits & ( ( unsigned long ) 1 ) << 1 << 1 << 1 << 1 << 1 << 1 << 1 ) return 0 ; context = wchar_context ( wc ); static int wchar_context(wint_t wc) if ( wc == ( ( wchar_t ) eolbyte ) || wc == 0 ) return 4 ; if ( wc == '_' || iswalnum ( wc ) ) return 2 ; return 1 ; if ( ! ( ( ( ( context & 1 ? pos . constraint & 0xf : 0 ) ) | ( ( context & 2 ? pos . constraint >> 4 & 0xf : 0 ) ) | ( ( context & 4 ? pos . constraint >> 8 & 0xf : 0 ) ) ) & d -> states [ s ] . context ) ) return 0 ; work_mbc = & d -> mbcsets [ d -> multibyte_prop [ pos . index ] >> 2 ]; match = ! work_mbc -> invert; match_len = ( mblen_buf [ idx ] == 0 ? 1 : mblen_buf [ idx ] ); if ( wc < 1 << 8 && work_mbc -> cset != ( - 1 ) && tstbit ( ( ( unsigned char ) wc ) , d -> charclasses [ work_mbc -> cset ] ) ) static int tstbit(unsigned int b,const int c[((1 << 8) + 8 * sizeof(int ) - 1) / (8 * sizeof(int ))]) return c [ b / ( 8 * sizeof ( int ) ) ] & 1 << b % ( 8 * sizeof ( int ) ) ; for (i = 0; i < work_mbc -> nch_classes; i++) if ( iswctype ( ( ( wint_t ) wc ) , work_mbc -> ch_classes [ i ] ) ) strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , match_len ); buffer [ match_len ] = '\0'; for (i = 0; i < work_mbc -> nequivs; i++) op_len = ( strlen ( work_mbc -> equivs [ i ] ) ); strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> equivs [ i ] , buffer ) == 0 ) match_len = op_len; for (i = 0; i < work_mbc -> ncoll_elems; i++) op_len = ( strlen ( work_mbc -> coll_elems [ i ] ) ); strncpy ( buffer , ( ( const char * ) buf_begin ) + idx , op_len ); buffer [ op_len ] = '\0'; if ( strcoll ( work_mbc -> coll_elems [ i ] , buffer ) == 0 ) match_len = op_len; for (i = 0; i < work_mbc -> nranges; i++) if ( work_mbc -> range_sts [ i ] <= wc && wc <= work_mbc -> range_ends [ i ] ) for (i = 0; i < work_mbc -> nchars; i++) if ( wc == work_mbc -> chars [ i ] ) match = ! match; return match ? match_len : 0 ; return rarray ; for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); while ( * pp - p1 < maxlen ) transit_state_consume_1char ( d , s1 , pp , ( ( void * ) 0 ) , & mbclen , & follows ); wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static status_transit_state transit_state_consume_1char(struct dfa *d,state_num s,const unsigned char **pp,int *match_lens,int *mbclen,position_set *pps) state_num s1 ; s1 = s; copy ( ( & d -> states [ s1 ] . elems ) , pps ); static void copy(const position_set *src,position_set *dst) if ( dst -> alloc <= src -> nelem ) size_t new_n_alloc = src -> nelem + ( ! dst -> elems ) ; dst -> elems = ( x2nrealloc ( ( dst -> elems ) , & new_n_alloc , sizeof ( ( * dst -> elems ) ) ) ); dst -> alloc = new_n_alloc; while ( 0 ) memcpy ( ( dst -> elems ) , ( src -> elems ) , sizeof ( dst -> elems [ 0 ] ) * src -> nelem ); dst -> nelem = src -> nelem; | 149425/dfa.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_console_w32_vsnprintf_02_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( 1 ) size_t dataLen = strlen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) data [ dataLen ] = '\0'; if ( 1 ) badVaSinkB ( data , data ); static void badVaSinkB(char * data, ...) char dest [ 100 ] = "" ; va_list args ; vsnprintf ( dest , 100 - 1 , data , args ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 79627/CWE134_Uncontrolled_Format_String__char_console_w32_vsnprintf_02.c | SARD | 15 |
proto_item_append_text(proto_item *pi, const char *format, ...) fi = PITEM_FINFO ( pi ); if ( fi == NULL ) if ( ! PROTO_ITEM_IS_HIDDEN ( pi ) ) if ( fi -> rep == NULL ) proto_item_fill_label ( fi , fi -> rep -> representation ); proto_item_fill_label(field_info *fi, gchar *label_str) header_field_info * hfinfo ; guint8 * bytes ; if ( ! fi ) hfinfo = fi -> hfinfo; switch ( hfinfo -> type ) bytes = ( guint8 * ) fvalue_get ( & fi -> value ); if ( bytes ) switch ( hfinfo -> display ) str = ( char * ) bytestring_to_str ( NULL , bytes , fvalue_length ( & fi -> value ) , '.' ); str = ( char * ) bytestring_to_str ( NULL , bytes , fvalue_length ( & fi -> value ) , '-' ); str = ( char * ) bytestring_to_str ( NULL , bytes , fvalue_length ( & fi -> value ) , ':' ); str = ( char * ) bytestring_to_str ( NULL , bytes , fvalue_length ( & fi -> value ) , ' ' ); if ( prefs . display_byte_fields_with_spaces ) str = ( char * ) bytestring_to_str ( NULL , bytes , fvalue_length ( & fi -> value ) , ' ' ); str = ( char * ) bytes_to_str ( NULL , bytes , fvalue_length ( & fi -> value ) ); label_fill ( label_str , 0 , hfinfo , str ); static label_fill(char *label_str, gsize pos, const header_field_info *hfinfo, const char *text) gsize name_pos ; name_pos = pos = label_concat ( label_str , pos , hfinfo -> name ); pos = label_concat ( label_str , pos , ": " ); pos = label_concat ( label_str , pos , text ? text : "(null)" ); if ( pos >= ITEM_LABEL_LENGTH ) label_mark_truncated ( label_str , name_pos ); static label_mark_truncated(char *label_str, gsize name_pos) static const char trunc_str [ ] = " [truncated]" ; const size_t trunc_len = sizeof ( trunc_str ) - 1 ; if ( name_pos < ITEM_LABEL_LENGTH - trunc_len ) memmove ( label_str + name_pos + trunc_len , label_str + name_pos , ITEM_LABEL_LENGTH - name_pos - trunc_len ); memcpy ( label_str + name_pos , trunc_str , trunc_len ); last_char = g_utf8_prev_char ( & label_str [ ITEM_LABEL_LENGTH ] ); * last_char = '\0'; g_strlcpy ( label_str + name_pos , trunc_str , ITEM_LABEL_LENGTH - name_pos ); | CVE-2016-4006/Wireshark_2.0.2_CVE_2016_4006_epan_proto.c | NVD | 0 |
static void goodG2B() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; CWE126_Buffer_Overread__malloc_char_memmove_51b_goodG2BSink ( data ); void CWE126_Buffer_Overread__malloc_char_memmove_51b_goodG2BSink(char * data) 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 ); free ( data ); | 76359/CWE126_Buffer_Overread__malloc_char_memmove_51a.c | SARD | 0 |
void goodG2BSink(char * dataArray[]) char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memmove ( dest , data , 100 * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 78400/CWE127_Buffer_Underread__new_char_memmove_66b.cpp | SARD | 0 |
static void goodG2B() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; baseObject -> action ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_memcpy_82_goodG2B::action(char * data) memcpy ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 71309/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_memcpy_82a.cpp | SARD | 0 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgets ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) data [ dataLen ] = '\0'; CWE134_Uncontrolled_Format_String__char_file_snprintf_64b_goodB2GSink ( & data ); void CWE134_Uncontrolled_Format_String__char_file_snprintf_64b_goodB2GSink(void * dataVoidPtr) char * * dataPtr = ( char * * ) dataVoidPtr ; char * data = ( * dataPtr ) ; SNPRINTF ( dest , 100 - 1 , "%s" , data ); | 80094/CWE134_Uncontrolled_Format_String__char_file_snprintf_64a.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 *seldomcy_gweducks) int stereomonoscope_vinomethylic = 7 ; if ( seldomcy_gweducks != 0 ) antisudoral_unswept = ( ( void * ) seldomcy_gweducks ); balai_hotpot = vulpinite_diseconomy ( antisudoral_unswept ); void *vulpinite_diseconomy(void *cytissorus_brutalising) return cytissorus_brutalising ; monotrochal_unannoyingly ( stereomonoscope_vinomethylic , balai_hotpot ); void monotrochal_unannoyingly(int unpumpable_uspoke,void *beflatter_dunarea) int stonesoup_size = 0 ; unpumpable_uspoke --; if ( unpumpable_uspoke > 0 ) stonesoup_second_buff = malloc ( ( stonesoup_size + 1 ) * sizeof ( char ) ); if ( stonesoup_second_buff == 0 ) strcpy ( stonesoup_second_buff , cosmosophy_membranously ); stonesoup_476_global_variable = strlen ( stonesoup_second_buff ); if ( stonesoup_second_buff != 0 ) free ( stonesoup_second_buff ); | 149794/utils.c | SARD | 2 |
static void goodG2B1() char * data ; data = NULL; if ( staticReturnsFalse ( ) ) static int staticReturnsFalse() return 0 ; data = ( char * ) ALLOCA ( 100 * sizeof ( char ) ); strcpy ( data , "A String" ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 99208/CWE401_Memory_Leak__char_calloc_08.c | SARD | 0 |
void bad() int i ; wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = BASEPATH ; data = dataBuffer; for(i = 0; i < 1; i++) size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( FILENAME_MAX - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgetws ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , pFile ) == NULL ) fclose ( pFile ); | 91564/CWE23_Relative_Path_Traversal__wchar_t_file_ifstream_17.cpp | SARD | 0 |
Buffer ReleaseAndReadBuffer(Buffer buffer,Relation relation,BlockNumber blockNum) ForkNumber forkNum = MAIN_FORKNUM ; volatile BufferDesc * bufHdr ; if ( ( ( void ) ( ( bool ) 1 ) ) , buffer != 0 ) if ( buffer < 0 ) bufHdr = ( & LocalBufferDescriptors [ - buffer - 1 ] ); if ( bufHdr -> tag . blockNum == blockNum && ( bufHdr -> tag . rnode . relNode == relation -> rd_node . relNode && bufHdr -> tag . rnode . dbNode == relation -> rd_node . dbNode && bufHdr -> tag . rnode . spcNode == relation -> rd_node . spcNode ) && bufHdr -> tag . forkNum == forkNum ) bufHdr = ( & BufferDescriptors [ buffer - 1 ] ); if ( bufHdr -> tag . blockNum == blockNum && ( bufHdr -> tag . rnode . relNode == relation -> rd_node . relNode && bufHdr -> tag . rnode . dbNode == relation -> rd_node . dbNode && bufHdr -> tag . rnode . spcNode == relation -> rd_node . spcNode ) && bufHdr -> tag . forkNum == forkNum ) return ReadBuffer ( relation , blockNum ) ; Buffer ReadBuffer(Relation reln,BlockNumber blockNum) return ReadBufferExtended ( reln , MAIN_FORKNUM , blockNum , RBM_NORMAL , ( ( void * ) 0 ) ) ; Buffer ReadBufferExtended(Relation reln,ForkNumber forkNum,BlockNumber blockNum,ReadBufferMode mode,BufferAccessStrategy strategy) Buffer buf ; if ( reln -> pgstat_info != ( ( void * ) 0 ) ) reln -> pgstat_info -> t_counts . t_blocks_fetched ++; while ( 0 ) buf = ReadBuffer_common ( reln -> rd_smgr , reln -> rd_rel -> relpersistence , forkNum , blockNum , mode , strategy , & hit ); static Buffer ReadBuffer_common(SMgrRelation smgr,char relpersistence,ForkNumber forkNum,BlockNumber blockNum,ReadBufferMode mode,BufferAccessStrategy strategy,bool *hit) volatile BufferDesc * bufHdr ; Block bufBlock ; bool found ; bool isExtend ; bool isLocalBuf = ( smgr -> smgr_rnode . backend != - 1 ) ; isExtend = ( blockNum == ( ( BlockNumber ) 0xFFFFFFFF ) ); if ( isExtend ) blockNum = smgrnblocks ( smgr , forkNum ); if ( isLocalBuf ) bufHdr = ( LocalBufferAlloc ( smgr , forkNum , blockNum , & found ) ); bufHdr = BufferAlloc ( smgr , relpersistence , forkNum , blockNum , strategy , & found ); if ( found ) if ( ! isExtend ) bufBlock = ( isLocalBuf ? LocalBufferBlockPointers [ - ( bufHdr -> buf_id + 2 ) ] : ( ( Block ) ( BufferBlocks + ( ( Size ) ( bufHdr -> buf_id ) ) * 8192 ) ) ); if ( isLocalBuf ) bufHdr -> flags &= ~ ( 1 << 1 ); bufHdr -> flags &= ~ ( 1 << 1 ); * ( ( volatile slock_t * ) ( & bufHdr -> buf_hdr_lock ) ) = 0; while ( ! StartBufferIO ( bufHdr , ( ( bool ) 1 ) ) ) bufBlock = ( isLocalBuf ? LocalBufferBlockPointers [ - ( bufHdr -> buf_id + 2 ) ] : ( ( Block ) ( BufferBlocks + ( ( Size ) ( bufHdr -> buf_id ) ) * 8192 ) ) ); if ( isExtend ) void * _vstart = ( void * ) ( ( char * ) bufBlock ) ; int _val = 0 ; Size _len = 8192 ; if ( ( ( ( intptr_t ) _vstart ) & sizeof ( long ) - 1 ) == 0 && ( _len & sizeof ( long ) - 1 ) == 0 && _val == 0 && _len <= 1024 && 1024 != 0 ) memset ( _vstart , _val , _len ); while ( 0 ) | 150551/bufmgr.c | SARD | 0 |
void bad() char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; strncpy ( dest , data , strlen ( dest ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 78421/CWE127_Buffer_Underread__new_char_ncpy_12.cpp | SARD | 3 |
static void goodG2B2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; strcpy ( data , "fixedstringtest" ); goodG2B2VaSinkB ( data , data ); static void goodG2B2VaSinkB(char * data, ...) va_start ( args , data ); vsnprintf ( dest , 100 - 1 , data , args ); printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 79348/CWE134_Uncontrolled_Format_String__char_connect_socket_w32_vsnprintf_11.c | SARD | 0 |
static void goodG2B() size_t data ; data = 0; data = 20; CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_52b_goodG2BSink ( data ); void CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_52b_goodG2BSink(size_t data) CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_52c_goodG2BSink ( data ); void CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_52c_goodG2BSink(size_t data) char * myString ; if ( data > strlen ( HELLO_STRING ) ) myString = ( char * ) malloc ( data * sizeof ( char ) ); strcpy ( myString , HELLO_STRING ); printLine ( myString ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( myString ); | 117013/CWE789_Uncontrolled_Mem_Alloc__malloc_char_connect_socket_52c.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); dataArray [ 2 ] = data; badSink ( dataArray ); void badSink(char * dataArray[]) char * data = dataArray [ 2 ] ; fileDesc = OPEN ( data , O_RDWR | O_CREAT , S_IREAD | S_IWRITE ); if ( fileDesc != - 1 ) CLOSE ( fileDesc ); | 95720/CWE36_Absolute_Path_Traversal__char_connect_socket_open_66a.cpp | SARD | 0 |
void deletion_dour(int hardheads_mousses,union prereveal_philomel spires_narthecium) hardheads_mousses --; if ( hardheads_mousses > 0 ) deletion_dour ( hardheads_mousses , spires_narthecium ); void deletion_dour(int hardheads_mousses,union prereveal_philomel spires_narthecium) hardheads_mousses --; if ( hardheads_mousses > 0 ) deletion_dour ( hardheads_mousses , spires_narthecium ); void deletion_dour(int hardheads_mousses,union prereveal_philomel spires_narthecium) hardheads_mousses --; if ( hardheads_mousses > 0 ) deletion_dour ( hardheads_mousses , spires_narthecium ); void deletion_dour(int hardheads_mousses,union prereveal_philomel spires_narthecium) hardheads_mousses --; if ( hardheads_mousses > 0 ) if ( spires_narthecium . beeson_joyous != 0 ) free ( ( ( char * ) spires_narthecium . beeson_joyous ) ); | 151787/resowner.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__wchar_t_console_w32_vsnprintf_07_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( staticFive == 5 ) size_t dataLen = wcslen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) data [ dataLen - 1 ] = L '\0' data [ dataLen ] = L '\0' if ( staticFive == 5 ) badVaSinkB ( data , data ); static void badVaSinkB(wchar_t * data, ...) wchar_t dest [ 100 ] = L "" va_list args ; _vsnwprintf ( dest , 100 - 1 , data , args ); | 81072/CWE134_Uncontrolled_Format_String__wchar_t_console_w32_vsnprintf_07.c | SARD | 15 |
void bad() char * data ; char dataBuffer [ 250 ] = "PATH=" ; data = dataBuffer; badSource ( data ); void badSource(char * &data) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) 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 ) * ( 250 - 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 ) | 102890/CWE427_Uncontrolled_Search_Path_Element__char_connect_socket_62b.cpp | SARD | 0 |
static void goodG2B() int data ; data = - 1; data = 7; CWE122_Heap_Based_Buffer_Overflow__c_CWE129_large_82_base * baseObject = new CWE122_Heap_Based_Buffer_Overflow__c_CWE129_large_82_goodG2B baseObject -> action ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE129_large_82_goodG2B::action(int data) int i ; int * buffer = ( int * ) malloc ( 10 * sizeof ( int ) ) ; for (i = 0; i < 10; i++) buffer [ i ] = 0; if ( data >= 0 ) buffer [ data ] = 1; free ( buffer ); | 70637/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_large_82_goodG2B.cpp | SARD | 0 |
void CWE194_Unexpected_Sign_Extension__negative_malloc_11_bad() short data ; data = 0; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; data = - 1; if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; free ( dataBuffer ); | 87064/CWE194_Unexpected_Sign_Extension__negative_malloc_11.c | SARD | 20 |
static void good1() if ( staticFive != 5 ) wchar_t * password = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; password [ 0 ] = L '\0' if ( fgetws ( password , 100 , stdin ) == NULL ) password [ 0 ] = L '\0' passwordLen = wcslen ( password ); if ( passwordLen > 0 ) password [ passwordLen - 1 ] = L '\0' password = realloc ( password , 200 * sizeof ( wchar_t ) ); wcscpy ( password , L "Nothing to see here" ) free ( password ); | 92058/CWE244_Heap_Inspection__w32_wchar_t_realloc_07.c | SARD | 0 |
static void goodG2B2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( 1 ) strcpy ( data , "fixedstringtest" ); goodG2B2VaSinkB ( data , data ); static void goodG2B2VaSinkB(char * data, ...) va_start ( args , data ); vprintf ( data , args ); | 79867/CWE134_Uncontrolled_Format_String__char_environment_vprintf_02.c | SARD | 0 |
void CWE78_OS_Command_Injection__wchar_t_listen_socket_w32_spawnlp_41_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 ); | 122623/CWE78_OS_Command_Injection__wchar_t_listen_socket_w32_spawnlp_41.c | SARD | 0 |
void CWE194_Unexpected_Sign_Extension__listen_socket_memcpy_67b_goodG2BSink(CWE194_Unexpected_Sign_Extension__listen_socket_memcpy_67_structType myStruct) 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 ); | 86949/CWE194_Unexpected_Sign_Extension__listen_socket_memcpy_67b.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_file_execlp_34_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'; myUnion . unionFirst = data; char * data = myUnion . unionSecond ; | 119454/CWE78_OS_Command_Injection__char_file_execlp_34.c | SARD | 0 |
qcms_profile* qcms_profile_from_memory(const void *mem, size_t size) uint32_t length ; struct mem_source source ; struct mem_source * src = & source ; struct tag_index index ; qcms_profile * profile ; source . buf = mem; source . size = size; source . valid = true; if ( size < 4 ) length = read_u32 ( src , 0 ); if ( length <= size ) source . size = length; if ( source . size <= 64 || source . size >= MAX_PROFILE_SIZE ) profile = qcms_profile_create ( ); if ( ! profile ) if ( ! src -> valid ) index = read_tag_table ( profile , src ); if ( find_tag ( index , TAG_CHAD ) ) profile -> chromaticAdaption = read_tag_s15Fixed16ArrayType ( src , index , TAG_CHAD ); profile -> chromaticAdaption . invalid = true; if ( profile -> color_space == RGB_SIGNATURE ) if ( find_tag ( index , TAG_B2A0 ) ) if ( read_u32 ( src , find_tag ( index , TAG_B2A0 ) -> offset ) == LUT8_TYPE || read_u32 ( src , find_tag ( index , TAG_B2A0 ) -> offset ) == LUT16_TYPE ) if ( read_u32 ( src , find_tag ( index , TAG_B2A0 ) -> offset ) == LUT_MBA_TYPE ) profile -> mBA = read_tag_lutmABType ( src , index , TAG_B2A0 ); static struct lutmABType *read_tag_lutmABType(struct mem_source *src, struct tag_index index, uint32_t tag_id) struct tag * tag = find_tag ( index , tag_id ) ; uint32_t offset = tag -> offset ; uint32_t matrix_offset ; uint32_t clut_offset ; uint32_t clut_size = 1 ; uint32_t type = read_u32 ( src , offset ) ; uint8_t num_in_channels , num_out_channels ; struct lutmABType * lut ; uint32_t i ; if ( type != LUT_MAB_TYPE && type != LUT_MBA_TYPE ) num_in_channels = read_u8 ( src , offset + 8 ); num_out_channels = read_u8 ( src , offset + 8 ); if ( num_in_channels > MAX_CHANNELS || num_out_channels > MAX_CHANNELS ) if ( num_in_channels != 3 || num_out_channels != 3 ) clut_offset = read_u32 ( src , offset + 24 ); matrix_offset = read_u32 ( src , offset + 16 ); if ( clut_offset ) clut_offset += offset; if ( matrix_offset ) matrix_offset += offset; if ( clut_offset ) for (i = 0; i < num_in_channels; i++) clut_size *= read_u8 ( src , clut_offset + i ); clut_size = 0; clut_size = clut_size * num_out_channels; if ( clut_size > MAX_CLUT_SIZE ) lut = malloc ( sizeof ( struct lutmABType ) + ( clut_size ) * sizeof ( float ) ); if ( ! lut ) memset ( lut , 0 , sizeof ( struct lutmABType ) ); lut -> clut_table = & lut -> clut_table_data [ 0 ]; for (i = 0; i < num_in_channels; i++) lut -> num_grid_points [ i ] = read_u8 ( src , clut_offset + i ); lut -> reversed = ( type == LUT_MBA_TYPE ); lut -> num_in_channels = num_in_channels; lut -> num_out_channels = num_out_channels; if ( matrix_offset ) lut -> e00 = read_s15Fixed16Number ( src , matrix_offset + 4 * 0 ); lut -> e01 = read_s15Fixed16Number ( src , matrix_offset + 4 * 1 ); lut -> e02 = read_s15Fixed16Number ( src , matrix_offset + 4 * 2 ); lut -> e10 = read_s15Fixed16Number ( src , matrix_offset + 4 * 3 ); lut -> e11 = read_s15Fixed16Number ( src , matrix_offset + 4 * 4 ); lut -> e12 = read_s15Fixed16Number ( src , matrix_offset + 4 * 5 ); lut -> e20 = read_s15Fixed16Number ( src , matrix_offset + 4 * 6 ); static s15Fixed16Number read_s15Fixed16Number(struct mem_source *mem, size_t offset) return read_u32 ( mem , offset ) ; static uint32_t read_u32(struct mem_source *mem, size_t offset) if ( offset > mem -> size - 4 ) be32 k ; memcpy ( & k , mem -> buf + offset , sizeof ( k ) ); return be32_to_cpu ( k ) ; | CVE-2015-0811/Firefox_36.0b9_CVE_2015_0811_gfx_qcms_iccread.c | NVD | 0 |
static void goodG2B1() twoIntsStruct * data ; data = NULL; if ( STATIC_CONST_FALSE ) data = ( twoIntsStruct * ) malloc ( 100 * sizeof ( twoIntsStruct ) ); twoIntsStruct source [ 100 ] ; size_t i ; for (i = 0; i < 100; i++) source [ i ] . intOne = 0; source [ i ] . intTwo = 0; memcpy ( data , source , 100 * sizeof ( twoIntsStruct ) ); printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); free ( data ); | 71843/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_struct_memcpy_04.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_src_wchar_t_cpy_63_bad() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); CWE122_Heap_Based_Buffer_Overflow__c_src_wchar_t_cpy_63b_badSink ( & data ); void CWE122_Heap_Based_Buffer_Overflow__c_src_wchar_t_cpy_63b_badSink(wchar_t * * dataPtr) wchar_t * data = * dataPtr ; wcscpy ( dest , data ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 73171/CWE122_Heap_Based_Buffer_Overflow__c_src_wchar_t_cpy_63a.c | SARD | 0 |
int file_read(void *buf,unsigned int len,FILE_T file) unsigned int n ; if ( len == 0 ) if ( file -> seek ) file -> seek = 0; if ( gz_skip ( file , file -> skip ) == - 1 ) static int gz_skip(FILE_T state,gint64 len) unsigned int n ; while ( len ) if ( state -> have ) n = ( ( ( gint64 ) ( state -> have ) ) > len ? ( ( unsigned int ) len ) : state -> have ); state -> have -= n; state -> next += n; state -> pos += n; len -= n; if ( state -> err ) return - 1 ; if ( state -> eof && state -> avail_in == 0 ) if ( fill_out_buffer ( state ) == - 1 ) return - 1 ; return 0 ; if ( file -> have ) n = ( file -> have > len ? len : file -> have ); file -> next += n; file -> have -= n; if ( file -> err ) if ( file -> eof && file -> avail_in == 0 ) if ( fill_out_buffer ( file ) == - 1 ) len -= n; file -> pos += n; while ( len ) static int fill_out_buffer(FILE_T state) if ( state -> compression == 0 ) if ( gz_head ( state ) == - 1 ) if ( state -> have ) if ( state -> compression == 1 ) if ( state -> compression == 2 ) zlib_read ( state , state -> out , state -> size << 1 ); static void zlib_read(FILE_T state,unsigned char *buf,unsigned int count) z_streamp strm = & state -> strm ; unsigned char * buf2 = buf ; unsigned int count2 = count ; strm -> avail_out = count; strm -> next_out = buf; if ( state -> avail_in == 0 && fill_in_buffer ( state ) == - 1 ) if ( state -> avail_in == 0 ) strm -> avail_in = state -> avail_in; strm -> next_in = state -> next_in; ret = inflate ( strm , 5 ); state -> avail_in = strm -> avail_in; state -> next_in = strm -> next_in; if ( ret == - 2 ) if ( ret == 2 ) if ( ret == - 4 ) if ( ret == - 3 ) strm -> adler = crc32 ( strm -> adler , buf2 , count2 - strm -> avail_out ); if ( state -> fast_seek_cur ) struct zlib_cur_seek_point * cur = ( struct zlib_cur_seek_point * ) ( state -> fast_seek_cur ) ; unsigned int ready = count2 - strm -> avail_out ; if ( ready < 32768 ) unsigned int left = 32768 - cur -> pos ; if ( ready >= left ) memcpy ( ( cur -> window + cur -> pos ) , buf2 , left ); if ( ready != left ) memcpy ( ( cur -> window ) , ( buf2 + left ) , ( ready - left ) ); cur -> pos = ready - left; cur -> have += ready; memcpy ( ( cur -> window + cur -> pos ) , buf2 , ready ); cur -> pos += ready; cur -> have += ready; if ( cur -> have >= 32768 ) cur -> have = 32768; memcpy ( ( cur -> window ) , ( buf2 + ( ready - 32768 ) ) , 32768 ); cur -> pos = 0; cur -> have = 32768; if ( cur -> have >= 32768 && ret != 1 && strm -> data_type & 128 && ! ( strm -> data_type & 64 ) ) zlib_fast_seek_add ( state , cur , strm -> data_type & 7 , state -> raw_pos - ( strm -> avail_in ) , state -> pos + ( count - strm -> avail_out ) ); buf2 = buf2 + count2 - strm -> avail_out; count2 = strm -> avail_out; while ( strm -> avail_out && ret != 1 ) static void zlib_fast_seek_add(FILE_T file,struct zlib_cur_seek_point *point,int bits,gint64 in_pos,gint64 out_pos) struct fast_seek_point * item = ( struct fast_seek_point * ) file -> fast_seek -> pdata [ file -> fast_seek -> len - 1 ] ; if ( item -> out + 1048576L < out_pos ) struct fast_seek_point * val = ( struct fast_seek_point * ) ( g_malloc_n ( 1 , sizeof ( struct fast_seek_point ) ) ) ; val -> in = in_pos; val -> out = out_pos; val -> compression = 2; val -> data . zlib . bits = bits; if ( point -> pos != 0 ) memcpy ( val -> data . zlib . window , ( point -> window ) , 32768 ); val -> data . zlib . adler = file -> strm . adler; val -> data . zlib . total_out = file -> strm . total_out; g_ptr_array_add ( file -> fast_seek , val ); | 151288/file_wrappers.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_listen_socket_w32_spawnvp_44_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 120322/CWE78_OS_Command_Injection__char_listen_socket_w32_spawnvp_44.c | SARD | 0 |
int avio_close_dyn_buf(AVIOContext *s,uint8_t **pbuffer) static const char padbuf [ 16 ] = { ( 0 ) } ; if ( ! s -> max_packet_size ) avio_write ( s , padbuf , ( sizeof ( padbuf ) ) ); void avio_write(AVIOContext *s,const unsigned char *buf,int size) if ( s -> direct && ! s -> update_checksum ) while ( size > 0 ) int len = ( s -> buf_end - s -> buf_ptr > size ? size : s -> buf_end - s -> buf_ptr ) ; memcpy ( ( s -> buf_ptr ) , buf , len ); s -> buf_ptr += len; if ( s -> buf_ptr >= s -> buf_end ) flush_buffer ( s ); buf += len; size -= len; | 152169/aviobuf.c | SARD | 0 |
void CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_04_bad() wchar_t * data ; data = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ); data [ 0 ] = L '\0' size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 112954/CWE761_Free_Pointer_Not_at_Start_of_Buffer__wchar_t_file_04.c | SARD | 0 |
void parse_dir_colors() char * s ; if ( Hflag ) if ( getenv ( "TERM" ) == ( ( void * ) 0 ) ) s = getenv ( "TREE_COLORS" ); if ( s == ( ( void * ) 0 ) ) if ( ( s == ( ( void * ) 0 ) || strlen ( s ) == 0 ) && force_color ) if ( s == ( ( void * ) 0 ) || ! force_color && ( nocolor || ! isatty ( 1 ) ) ) colors = strcpy ( ( xmalloc ( strlen ( s ) + 1 ) ) , s ); arg = split ( colors , ":" , & n ); char **split(char *str,char *delim,int *nwrds) w [ * nwrds = 0 ] = strtok ( str , delim ); while ( w [ * nwrds ] ) if ( * nwrds == n - 2 ) w = ( xrealloc ( w , sizeof ( char * ) * ( n += 256 ) ) ); w [ ++ * nwrds ] = strtok ( ( ( void * ) 0 ) , delim ); w [ * nwrds ] = ( ( void * ) 0 ); return w ; for (i = 0; arg[i]; i++) c = split ( arg [ i ] , "=" , & n ); char **split(char *str,char *delim,int *nwrds) w [ * nwrds = 0 ] = strtok ( str , delim ); while ( w [ * nwrds ] ) if ( * nwrds == n - 2 ) w = ( xrealloc ( w , sizeof ( char * ) * ( n += 256 ) ) ); w [ ++ * nwrds ] = strtok ( ( ( void * ) 0 ) , delim ); w [ * nwrds ] = ( ( void * ) 0 ); return w ; switch ( cmd ( c [ 0 ] ) ) int cmd(char *s) if ( ! strcmp ( cmds [ i ] . cmd , s ) ) if ( s [ 0 ] == '*' ) if ( c [ 1 ] ) norm_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) file_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) dir_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) if ( strcasecmp ( "target" , c [ 1 ] ) == 0 ) link_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) fifo_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) door_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) block_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) char_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) orphan_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) sock_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) suid_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) sgid_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) stickyow_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) otherwr_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) sticky_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) exec_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) missing_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) leftcode = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) rightcode = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) endcode = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( c [ 1 ] ) e -> ext = strcpy ( ( xmalloc ( strlen ( ( c [ 0 ] + 1 ) ) + 1 ) ) , ( c [ 0 ] + 1 ) ); e -> term_flg = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); e -> nxt = ext; ext = e; free ( c ); free ( arg ); if ( ! leftcode ) if ( ! rightcode ) if ( ! norm_flgs ) if ( ! endcode ) sprintf ( buf , "%s%s%s" , leftcode , norm_flgs , rightcode ); endcode = strcpy ( ( xmalloc ( strlen ( buf ) + 1 ) ) , buf ); free ( colors ); | 150419/color.c | SARD | 0 |
static void goodG2B() char * data ; data = NULL; CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cat_84_goodG2B * goodG2BObject = new CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cat_84_goodG2B ( data ) ; CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cat_84_goodG2B::CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cat_84_goodG2B(char * dataCopy) data = dataCopy; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; delete goodG2BObject CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cat_84_goodG2B::~CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cat_84_goodG2B() char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strcat ( data , source ); free ( data ); | 72847/CWE122_Heap_Based_Buffer_Overflow__c_dest_char_cat_84_goodG2B.cpp | SARD | 0 |
void CWE510_Trapdoor__network_listen_17_bad() int j ; for(j = 0; j < 1; j++) WSADATA wsaData ; struct sockaddr_in service ; 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 ( 30000 ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , 5 ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); | 105235/CWE510_Trapdoor__network_listen_17.c | SARD | 34 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfaanalyze ( d , searchflag ); void dfaanalyze(struct dfa *d,int searchflag) int * nullable ; size_t * nfirstpos ; position * firstpos ; size_t * nlastpos ; position * lastpos ; position_set merged ; position * o_firstpos ; position * o_lastpos ; size_t i ; size_t j ; position * pos ; d -> searchflag = searchflag; nullable = ( ( sizeof ( ( * nullable ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nullable ) ) ) ) ); while ( 0 ) nfirstpos = ( ( sizeof ( ( * nfirstpos ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nfirstpos ) ) ) ) ); while ( 0 ) firstpos = ( ( sizeof ( ( * firstpos ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * firstpos ) ) ) ) ); while ( 0 ) o_firstpos = firstpos , firstpos += d -> nleaves; nlastpos = ( ( sizeof ( ( * nlastpos ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nlastpos ) ) ) ) ); while ( 0 ) lastpos = ( ( sizeof ( ( * lastpos ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * lastpos ) ) ) ) ); while ( 0 ) o_lastpos = lastpos , lastpos += d -> nleaves; d -> follows = ( ( sizeof ( ( * d -> follows ) ) == 1 ? xzalloc ( d -> tindex ) : xcalloc ( d -> tindex , sizeof ( ( * d -> follows ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> tindex; ++i) switch ( d -> tokens [ i ] ) * ( nullable ++ ) = 1; * ( nfirstpos ++ ) = * ( nlastpos ++ ) = 0; pos = lastpos; if ( d -> tokens [ i ] != PLUS ) nullable [ - 1 ] = 1; pos = lastpos + nlastpos [ - 1 ]; for (j = 0; j < nlastpos[- 2]; ++j) copy ( ( & merged ) , & d -> follows [ pos [ j ] . index ] ); if ( nullable [ - 2 ] ) nfirstpos [ - 2 ] += nfirstpos [ - 1 ]; firstpos += nfirstpos [ - 1 ]; if ( nullable [ - 1 ] ) nlastpos [ - 2 ] += nlastpos [ - 1 ]; pos = lastpos + nlastpos [ - 2 ]; for (j = nlastpos[- 1]; j-- > 0; ) pos [ j ] = lastpos [ j ]; lastpos += nlastpos [ - 2 ]; nlastpos [ - 2 ] = nlastpos [ - 1 ]; nullable [ - 2 ] = nullable [ - 1 ] && nullable [ - 2 ]; nfirstpos [ - 2 ] += nfirstpos [ - 1 ]; nlastpos [ - 2 ] += nlastpos [ - 1 ]; nullable [ - 2 ] = nullable [ - 1 ] || nullable [ - 2 ]; * ( nullable ++ ) = d -> tokens [ i ] == BACKREF; * ( nfirstpos ++ ) = * ( nlastpos ++ ) = 1; firstpos -> index = lastpos -> index = i; firstpos -> constraint = lastpos -> constraint = 0x777; static void copy(const position_set *src,position_set *dst) if ( dst -> alloc <= src -> nelem ) size_t new_n_alloc = src -> nelem + ( ! dst -> elems ) ; dst -> elems = ( x2nrealloc ( ( dst -> elems ) , & new_n_alloc , sizeof ( ( * dst -> elems ) ) ) ); dst -> alloc = new_n_alloc; while ( 0 ) memcpy ( ( dst -> elems ) , ( src -> elems ) , sizeof ( dst -> elems [ 0 ] ) * src -> nelem ); dst -> nelem = src -> nelem; | 150157/dfa.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; if ( 5 == 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 ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 96596/CWE36_Absolute_Path_Traversal__char_listen_socket_ofstream_03.cpp | SARD | 0 |
void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_listen_socket_45_bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 110532/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_listen_socket_45.c | SARD | 0 |
static void goodB2G2() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( 1 ) size_t dataLen = strlen ( data ) ; recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; goodB2G2VaSinkG ( data , data ); static void goodB2G2VaSinkG(char * data, ...) va_start ( args , data ); | 80443/CWE134_Uncontrolled_Format_String__char_listen_socket_vprintf_02.c | SARD | 0 |
static void goodG2B1() char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memcpy ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 71271/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_memcpy_08.c | SARD | 0 |
void emulating_sufiism(struct quakerly_scitamineae *resatisfy_puzzled) unsphered_clintonite ( resatisfy_puzzled ); void unsphered_clintonite(struct quakerly_scitamineae *retransplanting_mortuaries) choreograph_reponder ( retransplanting_mortuaries ); void choreograph_reponder(struct quakerly_scitamineae *erasers_alnage) osphresiology_ashcans ( erasers_alnage ); void osphresiology_ashcans(struct quakerly_scitamineae *livid_kahaleel) struct stonesoup_data * stonesoupData ; magnetization_unplaced = ( ( char * ) ( * ( livid_kahaleel - 5 ) ) . vmd_noncreditor ); stonesoupData = malloc ( sizeof ( struct stonesoup_data ) ); if ( stonesoupData ) stonesoupData -> data = malloc ( sizeof ( char ) * ( strlen ( magnetization_unplaced ) + 1 ) ); stonesoupData -> file1 = malloc ( sizeof ( char ) * ( strlen ( magnetization_unplaced ) + 1 ) ); stonesoupData -> file2 = malloc ( sizeof ( char ) * ( strlen ( magnetization_unplaced ) + 1 ) ); if ( stonesoupData -> data ) if ( ( sscanf ( magnetization_unplaced , "%d %s %s %s" , & ( stonesoupData -> qsize ) , stonesoupData -> file1 , stonesoupData -> file2 , stonesoupData -> data ) == 4 ) && ( strlen ( stonesoupData -> data ) != 0 ) && ( strlen ( stonesoupData -> file1 ) != 0 ) && ( strlen ( stonesoupData -> file2 ) != 0 ) ) | 150221/utils.c | SARD | 0 |
void CWE124_Buffer_Underwrite__CWE839_connect_socket_34_bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) myUnion . unionFirst = data; int data = myUnion . unionSecond ; if ( data < 10 ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 73573/CWE124_Buffer_Underwrite__CWE839_connect_socket_34.c | SARD | 3 |
void CWE124_Buffer_Underwrite__CWE839_listen_socket_04_bad() if ( STATIC_CONST_TRUE ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); if ( data < 10 ) buffer [ data ] = 1; printIntLine ( buffer [ i ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 73697/CWE124_Buffer_Underwrite__CWE839_listen_socket_04.c | SARD | 3 |
static void goodG2B() int64_t * data ; int64_t * dataGoodBuffer = ( int64_t * ) ALLOCA ( 100 * sizeof ( int64_t ) ) ; data = dataGoodBuffer; CWE121_Stack_Based_Buffer_Overflow__CWE805_int64_t_alloca_memcpy_51b_goodG2BSink ( data ); void CWE121_Stack_Based_Buffer_Overflow__CWE805_int64_t_alloca_memcpy_51b_goodG2BSink(int64_t * data) int64_t source [ 100 ] = { 0 } ; memcpy ( data , source , 100 * sizeof ( int64_t ) ); printLongLongLine ( data [ 0 ] ); void printLongLongLine (int64_t longLongIntNumber) printf ( "%lld\n" , longLongIntNumber ); | 64377/CWE121_Stack_Based_Buffer_Overflow__CWE805_int64_t_alloca_memcpy_51b.c | SARD | 0 |
static void goodG2B1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticReturnsFalse ( ) ) static int staticReturnsFalse() return 0 ; strcpy ( data , "fixedstringtest" ); if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; 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 ); | 80497/CWE134_Uncontrolled_Format_String__char_listen_socket_w32_vsnprintf_08.c | SARD | 0 |
static void goodG2B2() wchar_t * data ; data = NULL; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; wchar_t * dataBuffer = new wchar_t [ 100 ] ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer; wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' wcsncpy ( dest , data , wcslen ( dest ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 78660/CWE127_Buffer_Underread__new_wchar_t_ncpy_11.cpp | SARD | 0 |
void CWE416_Use_After_Free__malloc_free_struct_08_bad() twoIntsStruct * data ; if ( staticReturnsTrue ( ) ) static int staticReturnsTrue() return 1 ; data = ( twoIntsStruct * ) malloc ( 100 * sizeof ( twoIntsStruct ) ); data [ i ] . intOne = 1; data [ i ] . intTwo = 2; free ( data ); printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); | 102300/CWE416_Use_After_Free__malloc_free_struct_08.c | SARD | 3 |
static void goodG2B1() int data ; data = - 1; if ( 5 != 5 ) data = 100 - 1; char source [ 100 ] ; char dest [ 100 ] = "" ; memset ( source , 'A' , 100 - 1 ); source [ 100 - 1 ] = '\0'; if ( data < 100 ) memcpy ( dest , source , data ); dest [ data ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 87872/CWE195_Signed_to_Unsigned_Conversion_Error__fscanf_memcpy_03.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 ) | 150080/stream.c | SARD | 0 |
static void goodG2B() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncat_52b_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncat_52b_goodG2BSink(char * data) CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncat_52c_goodG2BSink ( data ); void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncat_52c_goodG2BSink(char * data) strncat ( data , source , 100 ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 71390/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncat_52a.c | SARD | 0 |
static void good1() WSADATA wsaData ; struct sockaddr_in service ; 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 ( 20000 ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , 5 ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) if ( send ( acceptSocket , DEFAULT_MESSAGE , strlen ( DEFAULT_MESSAGE ) , 0 ) == SOCKET_ERROR ) while ( 0 ) | 105184/CWE510_Trapdoor__hostname_based_logic_18.c | SARD | 0 |
static void goodG2B() list < wchar_t * > dataList ; goodG2BSink ( dataList ); void goodG2BSink(list<wchar_t *> dataList) wchar_t * data = dataList . back ( ) ; 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 ); | 72170/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_wchar_t_ncpy_73b.cpp | SARD | 0 |
void rerental_stours(int nonbookishness_bedragglement,struct fouqu_palpebral **********agpaite_commune) amelia_formularise ( nonbookishness_bedragglement , agpaite_commune ); void amelia_formularise(int unbeheld_disqualifying,struct fouqu_palpebral **********scote_mayoralties) unbeheld_disqualifying --; if ( unbeheld_disqualifying > 0 ) rerental_stours ( unbeheld_disqualifying , scote_mayoralties ); void rerental_stours(int nonbookishness_bedragglement,struct fouqu_palpebral **********agpaite_commune) amelia_formularise ( nonbookishness_bedragglement , agpaite_commune ); void amelia_formularise(int unbeheld_disqualifying,struct fouqu_palpebral **********scote_mayoralties) unbeheld_disqualifying --; if ( unbeheld_disqualifying > 0 ) if ( ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * scote_mayoralties ) ) ) ) ) ) ) ) ) ) . pourboires_aeruginous != 0 ) free ( ( ( char * ) ( * ( * ( * ( * ( * ( * ( * ( * ( * ( * scote_mayoralties ) ) ) ) ) ) ) ) ) ) . pourboires_aeruginous ) ); | 153161/cryptlib.c | SARD | 0 |
static void goodB2G() wchar_t * data ; data = ( wchar_t * ) calloc ( 20 , sizeof ( wchar_t ) ); * dataPtr1 = data; if ( data != NULL ) wcscpy ( data , L "Initialize" ) printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 111815/CWE690_NULL_Deref_From_Return__wchar_t_calloc_32.c | SARD | 0 |
int ff_read_packet(AVFormatContext *s,AVPacket *pkt) char * hexaseme_egide ; if ( __sync_bool_compare_and_swap ( & guernseyed_xiphiplastron , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) stonesoup_read_taint ( & hexaseme_egide , "INAMISSIBLENESS_CUSTOMING" ); void stonesoup_read_taint(char** stonesoup_tainted_buff, char* stonesoup_env_var_name) if ( getenv ( "STONESOUP_DISABLE_WEAKNESS" ) == NULL || strcmp ( getenv ( "STONESOUP_DISABLE_WEAKNESS" ) , "1" ) != 0 ) stonesoup_tainted_file_name = getenv ( stonesoup_env_var_name ); stonesoup_tainted_file = fopen ( stonesoup_tainted_file_name , "rb" ); if ( stonesoup_tainted_file != 0 ) stonesoup_lsize = ftell ( stonesoup_tainted_file ); * stonesoup_tainted_buff = ( ( char * ) ( malloc ( sizeof ( char ) * ( stonesoup_lsize + 1 ) ) ) ); if ( * stonesoup_tainted_buff != 0 ) stonesoup_result = fread ( * stonesoup_tainted_buff , 1 , stonesoup_lsize , stonesoup_tainted_file ); ( * stonesoup_tainted_buff ) [ stonesoup_lsize ] = '\0'; * stonesoup_tainted_buff = NULL; | 153769/utils.c | SARD | 0 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfaanalyze ( d , searchflag ); void dfaanalyze(struct dfa *d,int searchflag) int * nullable ; size_t * nfirstpos ; position * firstpos ; size_t * nlastpos ; position * lastpos ; position_set merged ; position * o_firstpos ; position * o_lastpos ; size_t i ; size_t j ; position * pos ; d -> searchflag = searchflag; nullable = ( ( sizeof ( ( * nullable ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nullable ) ) ) ) ); while ( 0 ) nfirstpos = ( ( sizeof ( ( * nfirstpos ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nfirstpos ) ) ) ) ); while ( 0 ) firstpos = ( ( sizeof ( ( * firstpos ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * firstpos ) ) ) ) ); while ( 0 ) o_firstpos = firstpos , firstpos += d -> nleaves; nlastpos = ( ( sizeof ( ( * nlastpos ) ) == 1 ? xmalloc ( d -> depth ) : xnmalloc ( d -> depth , sizeof ( ( * nlastpos ) ) ) ) ); while ( 0 ) lastpos = ( ( sizeof ( ( * lastpos ) ) == 1 ? xmalloc ( d -> nleaves ) : xnmalloc ( d -> nleaves , sizeof ( ( * lastpos ) ) ) ) ); while ( 0 ) o_lastpos = lastpos , lastpos += d -> nleaves; d -> follows = ( ( sizeof ( ( * d -> follows ) ) == 1 ? xzalloc ( d -> tindex ) : xcalloc ( d -> tindex , sizeof ( ( * d -> follows ) ) ) ) ); while ( 0 ) for (i = 0; i < d -> tindex; ++i) switch ( d -> tokens [ i ] ) * ( nullable ++ ) = 1; * ( nfirstpos ++ ) = * ( nlastpos ++ ) = 0; pos = lastpos; if ( d -> tokens [ i ] != PLUS ) nullable [ - 1 ] = 1; pos = lastpos + nlastpos [ - 1 ]; for (j = 0; j < nlastpos[- 2]; ++j) copy ( ( & merged ) , & d -> follows [ pos [ j ] . index ] ); if ( nullable [ - 2 ] ) nfirstpos [ - 2 ] += nfirstpos [ - 1 ]; firstpos += nfirstpos [ - 1 ]; if ( nullable [ - 1 ] ) nlastpos [ - 2 ] += nlastpos [ - 1 ]; pos = lastpos + nlastpos [ - 2 ]; for (j = nlastpos[- 1]; j-- > 0; ) pos [ j ] = lastpos [ j ]; lastpos += nlastpos [ - 2 ]; nlastpos [ - 2 ] = nlastpos [ - 1 ]; nullable [ - 2 ] = nullable [ - 1 ] && nullable [ - 2 ]; nfirstpos [ - 2 ] += nfirstpos [ - 1 ]; nlastpos [ - 2 ] += nlastpos [ - 1 ]; nullable [ - 2 ] = nullable [ - 1 ] || nullable [ - 2 ]; * ( nullable ++ ) = d -> tokens [ i ] == BACKREF; * ( nfirstpos ++ ) = * ( nlastpos ++ ) = 1; firstpos -> index = lastpos -> index = i; firstpos -> constraint = lastpos -> constraint = 0x777; static void copy(const position_set *src,position_set *dst) if ( dst -> alloc <= src -> nelem ) size_t new_n_alloc = src -> nelem + ( ! dst -> elems ) ; dst -> elems = ( x2nrealloc ( ( dst -> elems ) , & new_n_alloc , sizeof ( ( * dst -> elems ) ) ) ); dst -> alloc = new_n_alloc; while ( 0 ) memcpy ( ( dst -> elems ) , ( src -> elems ) , sizeof ( dst -> elems [ 0 ] ) * src -> nelem ); dst -> nelem = src -> nelem; | 151914/dfa.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncpy_21_bad() char * data ; data = NULL; data = badSource ( data ); static char * badSource(char * data) if ( badStatic ) data = ( char * ) malloc ( 50 * sizeof ( char ) ); data [ 0 ] = '\0'; return data ; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncpy ( data , source , 100 - 1 ); data [ 100 - 1 ] = '\0'; free ( data ); | 71426/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncpy_21.c | SARD | 3 |
static void goodB2G() 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 ; if ( data != NULL ) 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 | 0 |
char *dfaexec(struct dfa *d,const char *begin,char *end,int allow_nl,size_t *count,int *backref) state_num s ; state_num s1 ; const unsigned char * p ; state_num * * trans ; state_num * t ; unsigned char eol = eolbyte ; s = s1 = 0; p = ( ( const unsigned char * ) begin ); trans = d -> trans; * end = eol; if ( d -> mb_cur_max > 1 ) while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) if ( p > buf_end ) s1 = s; if ( s == 0 ) if ( ( ( char * ) p ) >= end ) if ( d -> states [ s ] . mbps . nelem == 0 ) s = t [ * ( p ++ ) ]; if ( backref ) s = transit_state ( d , s , & p ); trans = d -> trans; while ( ( t = trans [ s ] ) != ( ( void * ) 0 ) ) s1 = t [ * ( p ++ ) ]; if ( ( t = trans [ s1 ] ) == ( ( void * ) 0 ) ) state_num tmp = s ; s = s1; s1 = tmp; s = t [ * ( p ++ ) ]; if ( s >= 0 && ( ( char * ) p ) <= end && d -> fails [ s ] ) if ( d -> success [ s ] & sbit [ * p ] ) s1 = s; if ( d -> mb_cur_max > 1 ) s = transit_state ( d , s , & p ); trans = d -> trans; s = d -> fails [ s ] [ * ( p ++ ) ]; if ( ( ( char * ) p ) > end ) if ( s >= 0 ) trans = d -> trans; if ( p [ - 1 ] == eol && allow_nl ) s = d -> newlines [ s1 ]; s = 0; static state_num transit_state(struct dfa *d,state_num s,const unsigned char **pp) int mbclen ; int maxlen = 0 ; size_t i ; int * match_lens = ( ( void * ) 0 ) ; size_t nelem = d -> states [ s ] . mbps . nelem ; position_set follows ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) transit_state_consume_1char ( d , s , pp , match_lens , & mbclen , & follows ); static status_transit_state transit_state_consume_1char(struct dfa *d,state_num s,const unsigned char **pp,int *match_lens,int *mbclen,position_set *pps) int k ; state_num s1 ; state_num s2 ; int * work_mbls ; * mbclen = ( mblen_buf [ * pp - buf_begin ] == 0 ? 1 : mblen_buf [ * pp - buf_begin ] ); s1 = s; for (k = 0; k < *mbclen; k++) s2 = s1; rs = transit_state_singlebyte ( d , s2 , ( * pp ) ++ , & s1 ); static status_transit_state transit_state_singlebyte(struct dfa *d,state_num s,const unsigned char *p,state_num *next_state) state_num * t ; state_num works = s ; status_transit_state rval = TRANSIT_STATE_IN_PROGRESS ; while ( rval == TRANSIT_STATE_IN_PROGRESS ) if ( ( t = d -> trans [ works ] ) != ( ( void * ) 0 ) ) works = t [ * p ]; rval = TRANSIT_STATE_DONE; if ( works < 0 ) works = 0; if ( works < 0 ) works = 0; if ( d -> fails [ works ] ) works = d -> fails [ works ] [ * p ]; rval = TRANSIT_STATE_DONE; return rval ; if ( match_lens == ( ( void * ) 0 ) && d -> states [ s ] . mbps . nelem != 0 ) work_mbls = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); static int *check_matching_with_multibyte_ops(struct dfa *d,state_num s,size_t idx) 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 ; | 150042/dfa.c | SARD | 0 |
void CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_malloc_16_bad() while ( 1 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; printLine ( dataBuffer ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( dataBuffer ); | 87453/CWE195_Signed_to_Unsigned_Conversion_Error__connect_socket_malloc_16.c | SARD | 20 |
void relocatability_cambogia(int desertness_noncabinet,tophetic_favourableness psychedelics_generalise) importunacy_psalmodize ( desertness_noncabinet , psychedelics_generalise ); void importunacy_psalmodize(int zagging_ureterectomies,tophetic_favourableness possess_ungrabbing) zagging_ureterectomies --; if ( zagging_ureterectomies > 0 ) relocatability_cambogia ( zagging_ureterectomies , possess_ungrabbing ); void relocatability_cambogia(int desertness_noncabinet,tophetic_favourableness psychedelics_generalise) importunacy_psalmodize ( desertness_noncabinet , psychedelics_generalise ); void importunacy_psalmodize(int zagging_ureterectomies,tophetic_favourableness possess_ungrabbing) zagging_ureterectomies --; if ( zagging_ureterectomies > 0 ) if ( possess_ungrabbing != 0 ) free ( ( ( char * ) possess_ungrabbing ) ); | 153766/tile-swap.c | SARD | 0 |
static void goodG2B1() short data ; data = 0; if ( GLOBAL_CONST_FALSE ) 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 ); | 87350/CWE194_Unexpected_Sign_Extension__rand_memmove_09.c | SARD | 0 |
void CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memcpy_34_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 ); | 87701/CWE195_Signed_to_Unsigned_Conversion_Error__fgets_memcpy_34.c | SARD | 20 |