func
stringlengths 181
23.6k
| path
stringlengths 12
123
| source
stringclasses 2
values | label
int64 0
40
|
---|---|---|---|
void bad() wchar_t * data ; data = NULL; data = badSource ( data ); static wchar_t * badSource(wchar_t * data) data = new wchar_t [ 10 ]; return data ; wchar_t source [ 10 + 1 ] = SRC_STRING ; memmove ( data , source , ( wcslen ( source ) + 1 ) * sizeof ( wchar_t ) ); printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) delete [ ] data | 68217/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE193_wchar_t_memmove_42.cpp | SARD | 3 |
void CWE325_Missing_Required_Cryptographic_Step__w32_CryptCreateHash_07_bad() if ( staticFive == 5 ) BYTE payload [ 100 ] ; DWORD payloadLen = strlen ( PAYLOAD ) ; HCRYPTPROV hCryptProv = ( HCRYPTPROV ) NULL ; HCRYPTHASH hHash = ( HCRYPTHASH ) NULL ; HCRYPTKEY hKey = ( HCRYPTKEY ) NULL ; char hashData [ 100 ] = HASH_INPUT ; memcpy ( payload , PAYLOAD , payloadLen ); if ( ! CryptAcquireContext ( & hCryptProv , NULL , MS_ENH_RSA_AES_PROV , PROV_RSA_AES , 0 ) ) if ( ! CryptHashData ( hHash , ( BYTE * ) hashData , strlen ( hashData ) , 0 ) ) if ( ! CryptDeriveKey ( hCryptProv , CALG_AES_256 , hHash , 0 , & hKey ) ) if ( ! CryptEncrypt ( hKey , 0 , 1 , 0 , payload , & payloadLen , sizeof ( payload ) ) ) while ( 0 ) | 94392/CWE325_Missing_Required_Cryptographic_Step__w32_CryptCreateHash_07.c | SARD | 8 |
static void vmsvga_value_write(void *opaque, uint32_t address, uint32_t value) struct vmsvga_state_s * s = opaque ; switch ( s -> index ) if ( value == SVGA_ID_2 || value == SVGA_ID_1 || value == SVGA_ID_0 ) s -> svgaid = value; s -> enable = ! ! value; s -> invalidated = 1; if ( value <= SVGA_MAX_WIDTH ) s -> new_width = value; s -> invalidated = 1; if ( value <= SVGA_MAX_HEIGHT ) s -> new_height = value; s -> invalidated = 1; if ( value != 32 ) s -> config = 0; s -> invalidated = 1; if ( value ) s -> fifo = ( uint32_t * ) s -> fifo_ptr; if ( ( CMD ( min ) | CMD ( max ) | CMD ( next_cmd ) | CMD ( stop ) ) & 3 ) if ( CMD ( min ) < ( uint8_t * ) s -> cmd -> fifo - ( uint8_t * ) s -> fifo ) if ( CMD ( max ) > SVGA_FIFO_SIZE ) if ( CMD ( max ) < CMD ( min ) + 10 * 1024 ) s -> config = ! ! value; s -> syncing = 1; vmsvga_fifo_run ( s ); static void vmsvga_fifo_run(struct vmsvga_state_s *s) uint32_t cmd , colour ; int args , len ; int x , y , dx , dy , width , height ; struct vmsvga_cursor_definition_s cursor ; len = vmsvga_fifo_length ( s ); static inline int vmsvga_fifo_length(struct vmsvga_state_s *s) int num ; if ( ! s -> config || ! s -> enable ) return 0 ; num = CMD ( next_cmd ) - CMD ( stop ); if ( num < 0 ) num += CMD ( max ) - CMD ( min ); return num >> 2 ; while ( len > 0 ) switch ( cmd = vmsvga_fifo_read ( s ) ) static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; static inline uint32_t vmsvga_fifo_read_raw(struct vmsvga_state_s *s) uint32_t cmd = s -> fifo [ CMD ( stop ) >> 2 ] ; return cmd ; len -= 5; len -= 6; if ( len < 0 ) colour = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; x = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; y = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; width = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; height = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; if ( vmsvga_fill_rect ( s , colour , x , y , width , height ) == 0 ) args = 0; len -= 7; if ( len < 0 ) x = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; y = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; dx = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; dy = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; width = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; height = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; if ( vmsvga_copy_rect ( s , x , y , dx , dy , width , height ) == 0 ) args = 0; len -= 8; if ( len < 0 ) cursor . id = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; cursor . hot_x = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; cursor . hot_y = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; cursor . width = x = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; cursor . height = y = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; cursor . bpp = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; args = SVGA_BITMAP_SIZE ( x , y ) + SVGA_PIXMAP_SIZE ( x , y , cursor . bpp ); if ( SVGA_BITMAP_SIZE ( x , y ) > sizeof cursor . mask || SVGA_PIXMAP_SIZE ( x , y , cursor . bpp ) > sizeof cursor . image ) len -= args; if ( len < 0 ) for (args = 0; args < SVGA_BITMAP_SIZE(x, y); args++) cursor . mask [ args ] = vmsvga_fifo_read_raw ( s ); static inline uint32_t vmsvga_fifo_read_raw(struct vmsvga_state_s *s) uint32_t cmd = s -> fifo [ CMD ( stop ) >> 2 ] ; return cmd ; for (args = 0; args < SVGA_PIXMAP_SIZE(x, y, cursor.bpp); args++) len -= 6; if ( len < 0 ) x = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; y = vmsvga_fifo_read ( s ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; args = x * y; args = 6; args = 7; len -= 4; if ( len < 0 ) args = 7 + ( vmsvga_fifo_read ( s ) >> 2 ); static inline uint32_t vmsvga_fifo_read(struct vmsvga_state_s *s) return le32_to_cpu ( vmsvga_fifo_read_raw ( s ) ) ; args = 12; args = 0; len -= args; if ( len < 0 ) while ( args -- ) static inline int vmsvga_copy_rect(struct vmsvga_state_s int x0, int y0, int x1, int y1, int w, int h) DisplaySurface * surface = qemu_console_surface ( s -> vga . con ) ; if ( ! vmsvga_verify_rect ( surface , "vmsvga_copy_rect/src" , x0 , y0 , w , h ) ) if ( ! vmsvga_verify_rect ( surface , "vmsvga_copy_rect/dst" , x1 , y1 , w , h ) ) static inline bool vmsvga_verify_rect(DisplaySurface const char int x, int y, int w, int h) if ( x < 0 ) if ( x > SVGA_MAX_WIDTH ) if ( w < 0 ) if ( w > SVGA_MAX_WIDTH ) if ( x + w > surface_width ( surface ) ) fprintf ( stderr , "%s: width was > %d (x: %d, w: %d)\n" , name , surface_width ( surface ) , x , w ); | CVE-2016-7170/qemu_2.3.0_CVE-2016-7170_vmware_vga.c | NVD | 0 |
void bad() char * data ; data = NULL; data = NULL; data = ( char * ) realloc ( data , 100 * sizeof ( char ) ); badSink_b ( data ); void badSink_b(char * data) badSink_c ( data ); void badSink_c(char * data) badSink_d ( data ); void badSink_d(char * data) badSink_e ( data ); void badSink_e(char * data) delete [ ] data | 113225/CWE762_Mismatched_Memory_Management_Routines__delete_array_char_realloc_54a.cpp | SARD | 0 |
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = L "" data = dataBuffer; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; size_t dataLen = wcslen ( data ) ; if ( FILENAME_MAX - dataLen > 1 ) if ( fgetws ( data + dataLen , ( int ) ( FILENAME_MAX - dataLen ) , stdin ) != NULL ) | 97132/CWE36_Absolute_Path_Traversal__wchar_t_console_open_11.cpp | SARD | 0 |
void bad() char * dataBuffer = ( char * ) malloc ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer - 8; memmove ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 74404/CWE124_Buffer_Underwrite__malloc_char_memmove_33.cpp | SARD | 3 |
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = L "" data = dataBuffer; if ( STATIC_CONST_FIVE == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); | 96743/CWE36_Absolute_Path_Traversal__wchar_t_connect_socket_fopen_06.cpp | SARD | 0 |
static void goodB2G() int data ; data = - 1; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) int i ; int * buffer = ( int * ) malloc ( 10 * sizeof ( int ) ) ; for (i = 0; i < 10; i++) buffer [ i ] = 0; if ( data >= 0 && data < ( 10 ) ) buffer [ data ] = 1; free ( buffer ); | 70465/CWE122_Heap_Based_Buffer_Overflow__c_CWE129_connect_socket_18.c | SARD | 0 |
static void goodG2B() char * data ; CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_cpy_34_unionType myUnion ; data = NULL; data = ( char * ) malloc ( ( 10 + 1 ) * sizeof ( char ) ); myUnion . unionFirst = data; char * data = myUnion . unionSecond ; char source [ 10 + 1 ] = SRC_STRING ; strcpy ( data , source ); free ( data ); | 70759/CWE122_Heap_Based_Buffer_Overflow__c_CWE193_char_cpy_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 ); if ( match_lens == ( ( void * ) 0 ) && d -> states [ s ] . mbps . nelem != 0 ) work_mbls = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); work_mbls = match_lens; if ( match_lens == ( ( void * ) 0 ) && work_mbls != ( ( void * ) 0 ) ) free ( work_mbls ); | 150433/dfa.c | SARD | 0 |
FunctionType::Call(JSContext* unsigned jsval* vp) CallArgs args = CallArgsFromVp ( argc , vp ) ; RootedObject obj ( cx , & args . callee ( ) ) ; if ( ! CData :: IsCData ( obj ) ) RootedObject typeObj ( cx , CData :: GetCType ( obj ) ) ; if ( CType :: GetTypeCode ( typeObj ) != TYPE_pointer ) typeObj = PointerType :: GetBaseType ( typeObj ); if ( CType :: GetTypeCode ( typeObj ) != TYPE_function ) FunctionInfo * fninfo = GetFunctionInfo ( typeObj ) ; uint32_t argcFixed = fninfo -> mArgTypes . length ( ) ; if ( ( ! fninfo -> mIsVariadic && args . length ( ) != argcFixed ) || ( fninfo -> mIsVariadic && args . length ( ) < argcFixed ) ) jsval slot = JS_GetReservedSlot ( obj , SLOT_REFERENT ) ; if ( ! slot . isUndefined ( ) && Library :: IsLibrary ( & slot . toObject ( ) ) ) PRLibrary * library = Library :: GetLibrary ( & slot . toObject ( ) ) ; if ( ! library ) AutoValueAutoArray values ; AutoValueAutoArray strings ; if ( ! values . resize ( args . length ( ) ) ) for (unsigned i = 0; i < argcFixed; ++i) if ( ! ConvertArgument ( cx , args [ i ] , fninfo -> mArgTypes [ i ] , & values [ i ] , & strings ) ) if ( fninfo -> mIsVariadic ) if ( ! fninfo -> mFFITypes . resize ( args . length ( ) ) ) RootedObject obj ( cx ) ; RootedObject type ( cx ) ; for (uint32_t i = argcFixed; i < args.length(); ++i) if ( args [ i ] . isPrimitive ( ) || ! CData :: IsCData ( obj = & args [ i ] . toObject ( ) ) ) if ( ! ( type = CData :: GetCType ( obj ) ) || ! ( type = PrepareType ( cx , OBJECT_TO_JSVAL ( type ) ) ) || ! ConvertArgument ( cx , args [ i ] , type , & values [ i ] , & strings ) || ! ( fninfo -> mFFITypes [ i ] = CType :: GetFFIType ( cx , type ) ) ) static ConvertArgument(JSContext* HandleValue JSObject* AutoValue* AutoValueAutoArray* strings) if ( ! value -> SizeToType ( cx , type ) ) if ( ! ImplicitConvert ( cx , arg , type , value -> mData , true , & freePointer ) ) 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 ( ) ) JSString * sourceString = val . toString ( ) ; JSLinearString * sourceLinear = sourceString -> ensureLinear ( cx ) ; if ( ! sourceLinear ) switch ( CType :: GetTypeCode ( baseType ) ) size_t nbytes = GetDeflatedUTF8StringLength ( cx , sourceLinear ) ; if ( nbytes == ( size_t ) - 1 ) if ( targetLength < nbytes ) char * charBuffer = static_cast < char * > buffer if ( val . isObject ( ) && ! sourceData ) AutoIdArray props ( cx , JS_Enumerate ( cx , valObj ) ) ; if ( ! props ) size_t structSize = CType :: GetSize ( targetType ) ; auto intermediate = cx -> make_pod_array < char > ( structSize ) if ( ! intermediate ) const FieldInfoHash * fields = StructType :: GetFieldInfo ( targetType ) ; if ( props . length ( ) != fields -> count ( ) ) RootedId id ( cx ) ; for (size_t i = 0; i < props.length(); ++i) id = props [ i ]; if ( ! JSID_IS_STRING ( id ) ) JSFlatString * name = JSID_TO_FLAT_STRING ( id ) ; const FieldInfo * field = StructType :: LookupField ( cx , targetType , name ) ; if ( ! field ) RootedValue prop ( cx ) ; if ( ! JS_GetPropertyById ( cx , valObj , id , & prop ) ) char * fieldData = intermediate . get ( ) + field -> mOffset ; if ( ! ImplicitConvert ( cx , prop , field -> mType , fieldData , false , nullptr ) ) memcpy ( buffer , intermediate . get ( ) , structSize ); | CVE-2015-2726/Firefox_38.8.0esr_CVE_2015_2726_js_src_ctypes_CTypes.cpp | NVD | 0 |
static void goodG2B1() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; if ( 0 ) data = dataBuffer; char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memcpy ( dest , data , 100 * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77323/CWE127_Buffer_Underread__char_alloca_memcpy_02.c | SARD | 0 |
static void goodG2B1() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; switch ( 5 ) wcscpy ( data , L "fixedstringtest" ) switch ( 7 ) goodG2B1VaSinkB ( data , data ); static void goodG2B1VaSinkB(wchar_t * data, ...) wchar_t dest [ 100 ] = L "" va_list args ; _vsnwprintf ( dest , 100 - 1 , data , args ); | 81080/CWE134_Uncontrolled_Format_String__wchar_t_console_w32_vsnprintf_15.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_console_w32_spawnv_16_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; while ( 1 ) 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'; | 118774/CWE78_OS_Command_Injection__char_console_w32_spawnv_16.c | SARD | 0 |
static void goodG2B() int data ; data = - 1; data = 20; CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_51b_goodG2BSink ( data ); void CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_51b_goodG2BSink(int data) size_t i ; int * intPointer ; intPointer = ( int * ) malloc ( data * sizeof ( int ) ); for (i = 0; i < (size_t)data; i++) intPointer [ i ] = 0; free ( intPointer ); | 110341/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_connect_socket_51b.c | SARD | 0 |
static void goodB2G2() int count ; count = - 1; if ( staticFive == 5 ) const char * filename = "output_good.txt" ; if ( count > 0 && count <= 20 ) pFile = fopen ( filename , "w+" ); if ( pFile == NULL ) if ( strlen ( SENTENCE ) != fwrite ( SENTENCE , sizeof ( char ) , strlen ( SENTENCE ) , pFile ) ) if ( pFile ) fclose ( pFile ); | 98823/CWE400_Resource_Exhaustion__fscanf_fwrite_07.c | SARD | 0 |
static void goodB2G() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); data [ 0 ] = '\0'; size_t dataLen = strlen ( data ) ; char * environment = GETENV ( ENV_VARIABLE ) ; if ( environment != NULL ) strncat ( data + dataLen , environment , 100 - dataLen - 1 ); CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_environment_52b_goodB2GSink ( data ); void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_environment_52b_goodB2GSink(char * data) CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_environment_52c_goodB2GSink ( data ); void CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_environment_52c_goodB2GSink(char * data) size_t i ; for (i=0; i < strlen(data); i++) if ( data [ i ] == SEARCH_CHAR ) | 112645/CWE761_Free_Pointer_Not_at_Start_of_Buffer__char_environment_52c.c | SARD | 0 |
void CWE367_TOC_TOU__access_16_bad() while ( 1 ) char filename [ 100 ] = "" ; if ( fgets ( filename , 100 , stdin ) == NULL ) filename [ 0 ] = '\0'; if ( strlen ( filename ) > 0 ) filename [ strlen ( filename ) - 1 ] = '\0'; if ( ACCESS ( filename , W_OK ) == - 1 ) fileDesc = OPEN ( filename , O_RDWR ); if ( fileDesc == - 1 ) if ( WRITE ( fileDesc , BAD_SINK_STRING , strlen ( BAD_SINK_STRING ) ) == - 1 ) if ( fileDesc != - 1 ) CLOSE ( fileDesc ); | 94653/CWE367_TOC_TOU__access_16.c | SARD | 16 |
static void good2() if ( STATIC_CONST_FIVE == 5 ) if ( ! stdThreadLockCreate ( & gGoodLock ) ) int stdThreadLockCreate(stdThreadLock *lock) stdThreadLock my_lock = NULL ; my_lock = ( stdThreadLock ) malloc ( sizeof ( * my_lock ) ); if ( my_lock == NULL ) return 0 ; return 1 ; if ( ! stdThreadCreate ( helperGood , NULL , & threadA ) ) int stdThreadCreate(stdThreadRoutine start, void *args, stdThread *thread) uintptr_t handle ; stdThread my_thread ; my_thread = ( stdThread ) malloc ( sizeof ( * my_thread ) ); if ( my_thread == NULL ) my_thread -> start = start; my_thread -> args = args; handle = _beginthreadex ( NULL , 0 , internal_start , my_thread , 0 , NULL ); if ( handle == 0 ) free ( my_thread ); | 94607/std_thread.c | SARD | 0 |
static void goodB2G1() switch ( 6 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( data >= 0 && data < ( 10 ) ) printIntLine ( buffer [ data ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 77064/CWE127_Buffer_Underread__CWE839_connect_socket_15.c | SARD | 0 |
static void AtStart_Cache() char * refugia_cursorial ; if ( __sync_bool_compare_and_swap ( & malariaproof_tunned , 0 , 1 ) ) if ( mkdir ( "/opt/stonesoup/workspace/lockDir" , 509U ) == 0 ) stonesoup_read_taint ( & refugia_cursorial , "HOMAGED_OOLOGY" ); 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 ) fclose ( stonesoup_tainted_file ); | 152171/xact.c | SARD | 0 |
void parse_dir_colors() char * colors ; char * s ; if ( Hflag ) if ( getenv ( "TERM" ) == ( ( void * ) 0 ) ) s = getenv ( "TREE_COLORS" ); if ( s == ( ( void * ) 0 ) ) s = getenv ( "LS_COLORS" ); if ( ( s == ( ( void * ) 0 ) || strlen ( s ) == 0 ) && force_color ) s = ":no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.bat=01;32:*.BAT=01;32:*.btm=01;32:*.BTM=01;32:*.cmd=01;32:*.CMD=01;32:*.com=01;32:*.COM=01;32:*.dll=01;32:*.DLL=01;32:*.exe=01;32:*.EXE=01;32:*.arj=01;31:*.bz2=01;31:*.deb=01;31:*.gz=01;31:*.lzh=01;31:*.rpm=01;31:*.tar=01;31:*.taz=01;31:*.tb2=01;31:*.tbz2=01;31:*.tbz=01;31:*.tgz=01;31:*.tz2=01;31:*.z=01;31:*.Z=01;31:*.zip=01;31:*.ZIP=01;31:*.zoo=01;31:*.asf=01;35:*.ASF=01;35:*.avi=01;35:*.AVI=01;35:*.bmp=01;35:*.BMP=01;35:*.flac=01;35:*.FLAC=01;35:*.gif=01;35:*.GIF=01;35:*.jpg=01;35:*.JPG=01;35:*.jpeg=01;35:*.JPEG=01;35:*.m2a=01;35:*.M2a=01;35:*.m2v=01;35:*.M2V=01;35:*.mov=01;35:*.MOV=01;35:*.mp3=01;35:*.MP3=01;35:*.mpeg=01;35:*.MPEG=01;35:*.mpg=01;35:*.MPG=01;35:*.ogg=01;35:*.OGG=01;35:*.ppm=01;35:*.rm=01;35:*.RM=01;35:*.tga=01;35:*.TGA=01;35:*.tif=01;35:*.TIF=01;35:*.wav=01;35:*.WAV=01;35:*.wmv=01;35:*.WMV=01;35:*.xbm=01;35:*.xpm=01;35:"; if ( s == ( ( void * ) 0 ) || ! force_color && ( nocolor || ! isatty ( 1 ) ) ) colors = strcpy ( ( xmalloc ( strlen ( s ) + 1 ) ) , s ); arg = split ( colors , ":" , & n ); char **split(char *str,char *delim,int *nwrds) 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 ); | 152046/color.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 ; const unsigned char * p1 = * pp ; wchar_t wc ; if ( nelem > 0 ) match_lens = check_matching_with_multibyte_ops ( d , s , ( * pp - buf_begin ) ); for (i = 0; i < nelem; i++) if ( match_lens [ i ] > maxlen ) maxlen = match_lens [ i ]; if ( nelem == 0 || maxlen == 0 ) wc = inputwcs [ * pp - mbclen - buf_begin ]; while ( * pp - p1 < maxlen ) wc = inputwcs [ * pp - mbclen - buf_begin ]; s1 = state_index ( d , ( & follows ) , wchar_context ( wc ) ); static state_num state_index(struct dfa *d,const position_set *s,int context) size_t hash = 0 ; state_num i ; state_num j ; for (i = 0; i < s -> nelem; ++i) hash ^= s -> elems [ i ] . index + s -> elems [ i ] . constraint; for (i = 0; i < d -> sindex; ++i) if ( hash != d -> states [ i ] . hash || s -> nelem != d -> states [ i ] . elems . nelem || context != d -> states [ i ] . context ) if ( j == s -> nelem ) if ( d -> salloc <= d -> sindex + 1 ) size_t new_n_alloc = ( d -> sindex + 1 + ( ! d -> states ) ) ; d -> states = ( x2nrealloc ( ( d -> states ) , & new_n_alloc , sizeof ( ( * d -> states ) ) ) ); d -> salloc = new_n_alloc; while ( 0 ) d -> states [ i ] . hash = hash; alloc_position_set ( & d -> states [ i ] . elems , s -> nelem ); static void alloc_position_set(position_set *s,size_t size) s -> elems = ( ( sizeof ( ( * s -> elems ) ) == 1 ? xmalloc ( size ) : xnmalloc ( size , sizeof ( ( * s -> elems ) ) ) ) ); while ( 0 ) s -> alloc = size; s -> nelem = 0; | 150627/dfa.c | SARD | 0 |
void gizeh_backslapping(int contraire_tesselating,char **capricorn_jason) contraire_tesselating --; if ( contraire_tesselating > 0 ) gizeh_backslapping ( contraire_tesselating , capricorn_jason ); void gizeh_backslapping(int contraire_tesselating,char **capricorn_jason) contraire_tesselating --; if ( contraire_tesselating > 0 ) gizeh_backslapping ( contraire_tesselating , capricorn_jason ); void gizeh_backslapping(int contraire_tesselating,char **capricorn_jason) contraire_tesselating --; if ( contraire_tesselating > 0 ) gizeh_backslapping ( contraire_tesselating , capricorn_jason ); void gizeh_backslapping(int contraire_tesselating,char **capricorn_jason) int stonesoup_len ; contraire_tesselating --; if ( contraire_tesselating > 0 ) sinuosely_overpolitic = ( ( char * ) capricorn_jason [ 11 ] ); stonesoup_len = atoi ( sinuosely_overpolitic ); if ( stonesoup_len < 4096 ) stonesoup_buffer = ( ( char * ) ( malloc ( 4096 * sizeof ( char ) ) ) ); if ( stonesoup_buffer != 0 ) memset ( stonesoup_buffer , 'a' , 4096 ); stonesoup_buffer [ 4095 ] = 0; free ( stonesoup_buffer ); | 151008/tile-swap.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__CWE131_memmove_31_bad() int * data ; data = NULL; data = ( int * ) malloc ( 10 ); int * dataCopy = data ; int * data = dataCopy ; int source [ 10 ] = { 0 } ; memmove ( data , source , 10 * sizeof ( int ) ); printIntLine ( data [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( data ); | 70372/CWE122_Heap_Based_Buffer_Overflow__CWE131_memmove_31.c | SARD | 3 |
void CWE427_Uncontrolled_Search_Path_Element__char_connect_socket_68_bad() char * data ; char dataBuffer [ 250 ] = "PATH=" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 250 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 102896/CWE427_Uncontrolled_Search_Path_Element__char_connect_socket_68a.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_connect_socket_w32_vsnprintf_12_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 79349/CWE134_Uncontrolled_Format_String__char_connect_socket_w32_vsnprintf_12.c | SARD | 0 |
void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_memcpy_12_bad() char * data ; char dataBuffer [ 100 ] ; data = dataBuffer; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; char dest [ 50 ] = "" ; memcpy ( dest , data , strlen ( data ) * sizeof ( char ) ); dest [ 50 - 1 ] = '\0'; | 65859/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_memcpy_12.c | SARD | 3 |
static void goodB2G1() size_t data ; data = 0; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) if ( globalReturnsFalse ( ) ) int globalReturnsFalse() return 0 ; wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) && data < 100 ) myString = ( wchar_t * ) malloc ( data * sizeof ( wchar_t ) ); wcscpy ( myString , HELLO_STRING ); printWLine ( myString ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( myString ); | 117377/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_listen_socket_11.c | SARD | 0 |
void heap_redo(XLogRecPtr lsn,XLogRecord *record) uint8 info = ( ( record -> xl_info ) & ~0x0F ) ; switch ( info & 0x70 ) heap_xlog_inplace ( lsn , record ); static void heap_xlog_inplace(XLogRecPtr lsn,XLogRecord *record) xl_heap_inplace * xlrec = ( xl_heap_inplace * ) ( ( ( char * ) record ) + ( ( ( intptr_t ) ( sizeof ( XLogRecord ) ) ) + ( 8 - 1 ) & ~ ( ( intptr_t ) ( 8 - 1 ) ) ) ) ; Buffer buffer ; Page page ; OffsetNumber offnum ; ItemId lp = ( ( void * ) 0 ) ; HeapTupleHeader htup ; uint32 newlen ; if ( ( record -> xl_info ) & 0x0008 >> 0 ) buffer = XLogReadBuffer ( xlrec -> target . node , ( ( ( ( void ) ( ( bool ) 1 ) ) , ( ( ( ( void ) ( ( bool ) 1 ) ) , ( ( BlockNumber ) ( ( ( & ( & xlrec -> target . tid ) -> ip_blkid ) -> bi_hi ) << 16 | ( ( uint16 ) ( ( & ( & xlrec -> target . tid ) -> ip_blkid ) -> bi_lo ) ) ) ) ) ) ) ) , ( ( bool ) 0 ) ); if ( ! ( ( ( ( void ) ( ( bool ) 1 ) ) , buffer != 0 ) ) ) page = ( ( Page ) ( ( Page ) ( ( ( ( void ) ( ( bool ) 1 ) ) , ( buffer < 0 ? LocalBufferBlockPointers [ - buffer - 1 ] : ( ( Block ) ( BufferBlocks + ( ( Size ) ( buffer - 1 ) ) * 8192 ) ) ) ) ) ) ); if ( lsn . xlogid < ( ( PageHeader ) page ) -> pd_lsn . xlogid || lsn . xlogid == ( ( PageHeader ) page ) -> pd_lsn . xlogid && lsn . xrecoff <= ( ( PageHeader ) page ) -> pd_lsn . xrecoff ) offnum = ( ( ( ( void ) ( ( bool ) 1 ) ) , ( & xlrec -> target . tid ) -> ip_posid ) ); if ( ( ( ( ( ( PageHeader ) page ) -> pd_lower ) <= ( ( size_t ) ( & ( ( PageHeaderData * ) 0 ) -> pd_linp ) ) ? 0 : ( ( ( ( PageHeader ) page ) -> pd_lower ) - ( ( size_t ) ( & ( ( PageHeaderData * ) 0 ) -> pd_linp ) ) ) / sizeof ( ItemIdData ) ) ) >= offnum ) lp = ( ( ItemId ) ( & ( ( PageHeader ) page ) -> pd_linp [ offnum - 1 ] ) ); htup = ( ( HeapTupleHeader ) ( ( ( ( ( void ) ( ( bool ) 1 ) ) , ( ( void ) ( ( bool ) 1 ) ) ) , ( ( Item ) ( ( ( char * ) page ) + lp -> lp_off ) ) ) ) ); newlen = ( ( record -> xl_len ) - ( ( ( size_t ) ( & ( ( xl_heap_inplace * ) 0 ) -> target ) ) + ( ( ( size_t ) ( & ( ( xl_heaptid * ) 0 ) -> tid ) ) + ( ( ( size_t ) ( & ( ( ItemPointerData * ) 0 ) -> ip_posid ) ) + sizeof ( OffsetNumber ) ) ) ) ); memcpy ( ( ( ( char * ) htup ) + htup -> t_hoff ) , ( ( ( char * ) xlrec ) + ( ( ( size_t ) ( & ( ( xl_heap_inplace * ) 0 ) -> target ) ) + ( ( ( size_t ) ( & ( ( xl_heaptid * ) 0 ) -> tid ) ) + ( ( ( size_t ) ( & ( ( ItemPointerData * ) 0 ) -> ip_posid ) ) + sizeof ( OffsetNumber ) ) ) ) ) , newlen ); | 151542/heapam.c | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncat_11_bad() char * data ; data = NULL; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; data = ( char * ) malloc ( 50 * sizeof ( char ) ); data [ 0 ] = '\0'; char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncat ( data , source , 100 ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 71370/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncat_11.c | SARD | 3 |
static void goodB2G() if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = atoi ( inputBuffer ); if ( data != 0 ) printIntLine ( 100 / data ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); if ( data != 0 ) printIntLine ( 100 / data ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 95069/CWE369_Divide_by_Zero__int_fgets_divide_12.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 *arnuad_unsoldered) char * icacorea_prebroadcasting [ 80 ] = { 0 } ; if ( arnuad_unsoldered != 0 ) icacorea_prebroadcasting [ 57 ] = arnuad_unsoldered; if ( icacorea_prebroadcasting [ 57 ] != 0 ) free ( ( ( char * ) icacorea_prebroadcasting [ 57 ] ) ); | 152481/stream.c | SARD | 0 |
void CWE127_Buffer_Underread__char_alloca_loop_07_bad() char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer - 8; dest [ i ] = data [ i ]; dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77288/CWE127_Buffer_Underread__char_alloca_loop_07.c | SARD | 3 |
void CWE126_Buffer_Overread__char_declare_memcpy_41_badSink(char * data) char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memcpy ( dest , data , strlen ( dest ) * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 76158/CWE126_Buffer_Overread__char_declare_memcpy_41.c | SARD | 3 |
void bad() size_t data ; data = 0; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = strtoul ( inputBuffer , NULL , 0 ); if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; wchar_t * myString ; if ( data > wcslen ( HELLO_STRING ) ) myString = new wchar_t [ data ]; wcscpy ( myString , HELLO_STRING ); printWLine ( myString ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) delete [ ] myString | 117761/CWE789_Uncontrolled_Mem_Alloc__new_wchar_t_fgets_11.cpp | SARD | 10 |
void CWE606_Unchecked_Loop_Condition__char_listen_socket_06_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( STATIC_CONST_FIVE == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; while ( 0 ) if ( STATIC_CONST_FIVE == 5 ) if ( sscanf ( data , "%d" , & n ) == 1 ) | 109127/CWE606_Unchecked_Loop_Condition__char_listen_socket_06.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 *matin_mirador) int easted_curnies ; if ( matin_mirador != 0 ) delirifacient_hoyleton = matin_mirador; easted_curnies = 1; lunatum_narthecium = & delirifacient_hoyleton; unprecipitous_baalite = ( ( triradial_delph * ) ( ( ( unsigned long ) lunatum_narthecium ) * easted_curnies * easted_curnies ) ) + 5; if ( * ( unprecipitous_baalite - 5 ) != 0 ) free ( ( ( char * ) ( * ( unprecipitous_baalite - 5 ) ) ) ); | 149448/timestamp.c | SARD | 0 |
void bad() int64_t * data ; data = NULL; data = new int64_t [ 50 ]; badSink ( & data ); void badSink(int64_t * * dataPtr) int64_t * data = * dataPtr ; int64_t source [ 100 ] = { 0 } ; memcpy ( data , source , 100 * sizeof ( int64_t ) ); printLongLongLine ( data [ 0 ] ); void printLongLongLine (int64_t longLongIntNumber) printf ( "%lld\n" , longLongIntNumber ); delete [ ] data | 68803/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_int64_t_memcpy_63b.cpp | SARD | 3 |
static void goodB2G1() twoIntsStruct * data ; if ( 5 == 5 ) data = ( twoIntsStruct * ) calloc ( 100 , sizeof ( twoIntsStruct ) ); data [ 0 ] . intOne = 0; data [ 0 ] . intTwo = 0; printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); free ( data ); | 100572/CWE401_Memory_Leak__twoIntsStruct_calloc_03.c | SARD | 0 |
void initlinedraw(int flag) static const char * latin1_3 [ ] = { ( "ISO-8859-1" ) , ( "ISO-8859-1:1987" ) , ( "ISO_8859-1" ) , ( "latin1" ) , ( "l1" ) , ( "IBM819" ) , ( "CP819" ) , ( "csISOLatin1" ) , ( "ISO-8859-3" ) , ( "ISO_8859-3:1988" ) , ( "ISO_8859-3" ) , ( "latin3" ) , ( "ls" ) , ( "csISOLatin3" ) , ( ( ( void * ) 0 ) ) } ; static const char * iso8859_789 [ ] = { ( "ISO-8859-7" ) , ( "ISO_8859-7:1987" ) , ( "ISO_8859-7" ) , ( "ELOT_928" ) , ( "ECMA-118" ) , ( "greek" ) , ( "greek8" ) , ( "csISOLatinGreek" ) , ( "ISO-8859-8" ) , ( "ISO_8859-8:1988" ) , ( "iso-ir-138" ) , ( "ISO_8859-8" ) , ( "hebrew" ) , ( "csISOLatinHebrew" ) , ( "ISO-8859-9" ) , ( "ISO_8859-9:1989" ) , ( "iso-ir-148" ) , ( "ISO_8859-9" ) , ( "latin5" ) , ( "l5" ) , ( "csISOLatin5" ) , ( ( ( void * ) 0 ) ) } ; static const char * shift_jis [ ] = { ( "Shift_JIS" ) , ( "MS_Kanji" ) , ( "csShiftJIS" ) , ( ( ( void * ) 0 ) ) } ; static const char * euc_jp [ ] = { ( "EUC-JP" ) , ( "Extended_UNIX_Code_Packed_Format_for_Japanese" ) , ( "csEUCPkdFmtJapanese" ) , ( ( ( void * ) 0 ) ) } ; static const char * euc_kr [ ] = { ( "EUC-KR" ) , ( "csEUCKR" ) , ( ( ( void * ) 0 ) ) } ; static const char * iso2022jp [ ] = { ( "ISO-2022-JP" ) , ( "csISO2022JP" ) , ( "ISO-2022-JP-2" ) , ( "csISO2022JP2" ) , ( ( ( void * ) 0 ) ) } ; static const char * ibm_pc [ ] = { ( "IBM437" ) , ( "cp437" ) , ( "437" ) , ( "csPC8CodePage437" ) , ( "IBM852" ) , ( "cp852" ) , ( "852" ) , ( "csPCp852" ) , ( "IBM863" ) , ( "cp863" ) , ( "863" ) , ( "csIBM863" ) , ( "IBM855" ) , ( "cp855" ) , ( "855" ) , ( "csIBM855" ) , ( "IBM865" ) , ( "cp865" ) , ( "865" ) , ( "csIBM865" ) , ( "IBM866" ) , ( "cp866" ) , ( "866" ) , ( "csIBM866" ) , ( ( ( void * ) 0 ) ) } ; static const char * ibm_ps2 [ ] = { ( "IBM850" ) , ( "cp850" ) , ( "850" ) , ( "csPC850Multilingual" ) , ( "IBM00858" ) , ( "CCSID00858" ) , ( "CP00858" ) , ( "PC-Multilingual-850+euro" ) , ( ( ( void * ) 0 ) ) } ; static const char * ibm_gr [ ] = { ( "IBM869" ) , ( "cp869" ) , ( "869" ) , ( "cp-gr" ) , ( "csIBM869" ) , ( ( ( void * ) 0 ) ) } ; static const char * gb [ ] = { ( "GB2312" ) , ( "csGB2312" ) , ( ( ( void * ) 0 ) ) } ; static const char * utf8 [ ] = { ( "UTF-8" ) , ( "utf8" ) , ( ( ( void * ) 0 ) ) } ; static const char * big5 [ ] = { ( "Big5" ) , ( "csBig5" ) , ( ( ( void * ) 0 ) ) } ; static const char * viscii [ ] = { ( "VISCII" ) , ( "csVISCII" ) , ( ( ( void * ) 0 ) ) } ; static const char * koi8ru [ ] = { ( "KOI8-R" ) , ( "csKOI8R" ) , ( "KOI8-U" ) , ( ( ( void * ) 0 ) ) } ; static const char * windows [ ] = { ( "ISO-8859-1-Windows-3.1-Latin-1" ) , ( "csWindows31Latin1" ) , ( "ISO-8859-2-Windows-Latin-2" ) , ( "csWindows31Latin2" ) , ( "windows-1250" ) , ( "windows-1251" ) , ( "windows-1253" ) , ( "windows-1254" ) , ( "windows-1255" ) , ( "windows-1256" ) , ( "windows-1256" ) , ( "windows-1257" ) , ( ( ( void * ) 0 ) ) } ; static const struct linedraw cstable [ ] = { { ( latin1_3 ) , ( "| " ) , ( "|--" ) , ( "·--" ) , ( "©" ) } , { ( iso8859_789 ) , ( "| " ) , ( "|--" ) , ( "·--" ) , ( "(c)" ) } , { ( shift_jis ) , ( "\204\240 " ) , ( "\204\245" ) , ( "\204\244" ) , ( "(c)" ) } , { ( euc_jp ) , ( "\250\242 " ) , ( "\250\247" ) , ( "\250\246" ) , ( "(c)" ) } , { ( euc_kr ) , ( "\246\242 " ) , ( "\246\247" ) , ( "\246\246" ) , ( "(c)" ) } , { ( iso2022jp ) , ( "\033$B(\"\033(B " ) , ( "\033$B('\033(B" ) , ( "\033$B(&\033(B" ) , ( "(c)" ) } , { ( ibm_pc ) , ( "\263 " ) , ( "\303\304\304" ) , ( "\300\304\304" ) , ( "(c)" ) } , { ( ibm_ps2 ) , ( "\263 " ) , ( "\303\304\304" ) , ( "\300\304\304" ) , ( "\227" ) } , { ( ibm_gr ) , ( "\263 " ) , ( "\303\304\304" ) , ( "\300\304\304" ) , ( "\270" ) } , { ( gb ) , ( "\251\246 " ) , ( "\251\300" ) , ( "\251\270" ) , ( "(c)" ) } , { ( utf8 ) , ( "\342\224\202\302\240\302\240" ) , ( "\342\224\234\342\224\200\342\224\200" ) , ( "\342\224\224\342\224\200\342\224\200" ) , ( "\302\251" ) } , { ( big5 ) , ( "\242x " ) , ( "\242u" ) , ( "\242|" ) , ( "(c)" ) } , { ( viscii ) , ( "| " ) , ( "|--" ) , ( "`--" ) , ( "\371" ) } , { ( koi8ru ) , ( "\201 " ) , ( "\206\200\200" ) , ( "\204\200\200" ) , ( "\277" ) } , { ( windows ) , ( "| " ) , ( "|--" ) , ( "`--" ) , ( "\251" ) } , { ( ( ( void * ) 0 ) ) , ( "| " ) , ( "|--" ) , ( "`--" ) , ( "(c)" ) } } ; const char * * s ; if ( flag ) fprintf ( stderr , "tree: missing argument to --charset, valid charsets include:\n" ); for (linedraw = cstable; linedraw -> name; ++linedraw) for (s = linedraw -> name; *s; ++s) fprintf ( stderr , " %s\n" , * s ); | 150089/color.c | SARD | 0 |
static void goodB2G() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; count = atoi ( inputBuffer ); while ( 0 ) * countPtr1 = count; if ( count > 0 && count <= 2000 ) SLEEP ( count ); | 99030/CWE400_Resource_Exhaustion__listen_socket_sleep_32.c | SARD | 0 |
static void goodB2G1() wchar_t * data ; if ( staticFive == 5 ) data = ( wchar_t * ) calloc ( 100 , sizeof ( wchar_t ) ); wcscpy ( data , L "A String" ) printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 100721/CWE401_Memory_Leak__wchar_t_calloc_07.c | SARD | 0 |
void bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; badSource ( data ); static void badSource(wchar_t * &data) size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , pFile ) == NULL ) fclose ( pFile ); | 121809/CWE78_OS_Command_Injection__wchar_t_file_execl_43.cpp | SARD | 0 |
static void PgstatCollectorMain(int argc,char *argv[]) pgstat_write_statsfile ( ( ( bool ) 1 ) ); static void pgstat_write_statsfile(bool permanent) PgStat_StatDBEntry * dbentry ; PgStat_StatTabEntry * tabentry ; FILE * fpout ; const char * tmpfile = ( permanent ? "global/pgstat.tmp" : pgstat_stat_tmpname ) ; int rc ; fpout = AllocateFile ( tmpfile , "w" ); if ( fpout == ( ( void * ) 0 ) ) while ( ( dbentry = ( ( PgStat_StatDBEntry * ) ( hash_seq_search ( & hstat ) ) ) ) != ( ( void * ) 0 ) ) while ( ( tabentry = ( ( PgStat_StatTabEntry * ) ( hash_seq_search ( & tstat ) ) ) ) != ( ( void * ) 0 ) ) rc = ( fwrite ( tabentry , sizeof ( PgStat_StatTabEntry ) , 1 , fpout ) ); | 151496/pgstat.c | SARD | 0 |
static void goodB2G1() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( staticFive == 5 ) size_t dataLen = wcslen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 81600/CWE134_Uncontrolled_Format_String__wchar_t_file_vprintf_07.c | SARD | 0 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfainit ( d ); void dfainit(struct dfa *d) memset ( d , 0 , sizeof ( ( * d ) ) ); d -> calloc = 1; d -> charclasses = ( ( sizeof ( ( * d -> charclasses ) ) == 1 ? xmalloc ( d -> calloc ) : xnmalloc ( d -> calloc , sizeof ( ( * d -> charclasses ) ) ) ) ); while ( 0 ) d -> talloc = 1; d -> tokens = ( ( sizeof ( ( * d -> tokens ) ) == 1 ? xmalloc ( d -> talloc ) : xnmalloc ( d -> talloc , sizeof ( ( * d -> tokens ) ) ) ) ); while ( 0 ) d -> mb_cur_max = ( __ctype_get_mb_cur_max ( ) ); if ( d -> mb_cur_max > 1 ) d -> nmultibyte_prop = 1; d -> multibyte_prop = ( ( sizeof ( ( * d -> multibyte_prop ) ) == 1 ? xmalloc ( d -> nmultibyte_prop ) : xnmalloc ( d -> nmultibyte_prop , sizeof ( ( * d -> multibyte_prop ) ) ) ) ); while ( 0 ) d -> mbcsets_alloc = 1; d -> mbcsets = ( ( sizeof ( ( * d -> mbcsets ) ) == 1 ? xmalloc ( d -> mbcsets_alloc ) : xnmalloc ( d -> mbcsets_alloc , sizeof ( ( * d -> mbcsets ) ) ) ) ); while ( 0 ) | 151260/dfa.c | SARD | 0 |
void CWE401_Memory_Leak__char_realloc_05_bad() char * data ; data = NULL; if ( staticTrue ) data = ( char * ) realloc ( data , 100 * sizeof ( char ) ); strcpy ( data , "A String" ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 99301/CWE401_Memory_Leak__char_realloc_05.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_file_w32_execvp_05_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticTrue ) size_t dataLen = strlen ( data ) ; FILE * pFile ; if ( 100 - dataLen > 1 ) pFile = fopen ( FILENAME , "r" ); if ( pFile != NULL ) fclose ( pFile ); | 119579/CWE78_OS_Command_Injection__char_file_w32_execvp_05.c | SARD | 0 |
static void goodG2B() wchar_t * data ; data = NULL; wchar_t * dataBuffer = ( wchar_t * ) malloc ( 100 * sizeof ( wchar_t ) ) ; wmemset ( dataBuffer , L 'A' , 100 - 1 dataBuffer [ 100 - 1 ] = L '\0' data = dataBuffer; CWE127_Buffer_Underread__malloc_wchar_t_memmove_53b_goodG2BSink ( data ); void CWE127_Buffer_Underread__malloc_wchar_t_memmove_53b_goodG2BSink(wchar_t * data) CWE127_Buffer_Underread__malloc_wchar_t_memmove_53c_goodG2BSink ( data ); void CWE127_Buffer_Underread__malloc_wchar_t_memmove_53c_goodG2BSink(wchar_t * data) CWE127_Buffer_Underread__malloc_wchar_t_memmove_53d_goodG2BSink ( data ); void CWE127_Buffer_Underread__malloc_wchar_t_memmove_53d_goodG2BSink(wchar_t * data) wchar_t dest [ 100 ] ; wmemset ( dest , L 'C' , 100 - 1 dest [ 100 - 1 ] = L '\0' memmove ( dest , data , 100 * sizeof ( wchar_t ) ); printWLine ( dest ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 78153/CWE127_Buffer_Underread__malloc_wchar_t_memmove_53d.c | SARD | 0 |
static int handle_soft_key_event_message(struct skinny_req *req, struct skinnysession *s) struct skinny_device * d = s -> device ; struct skinny_line * l ; struct skinny_subchannel * sub = NULL ; struct ast_channel * c ; int event ; int instance ; int callreference ; event = letohl ( req -> data . softkeyeventmessage . softKeyEvent ); instance = letohl ( req -> data . softkeyeventmessage . instance ); callreference = letohl ( req -> data . softkeyeventmessage . callreference ); if ( instance ) l = find_line_by_instance ( d , instance ); if ( callreference ) sub = find_subchannel_by_instance_reference ( d , instance , callreference ); sub = find_subchannel_by_instance_reference ( d , instance , d -> lastcallreference ); l = find_line_by_instance ( d , d -> lastlineinstance ); if ( ! l ) switch ( event ) c = skinny_new ( l , NULL , AST_STATE_DOWN , NULL , SKINNY_OUTGOING ); sub = c -> tech_pvt; if ( l -> dnd != 0 ) l -> dnd = 1; if ( ! sub || ! sub -> owner ) c = skinny_new ( l , NULL , AST_STATE_DOWN , NULL , SKINNY_OUTGOING ); c = sub -> owner; if ( ! c ) sub = c -> tech_pvt; l -> activesub = sub; if ( ! sub || ! sub -> owner ) c = skinny_new ( l , NULL , AST_STATE_DOWN , NULL , SKINNY_OUTGOING ); c = sub -> owner; if ( ! c ) sub = c -> tech_pvt; l -> activesub = sub; if ( ! sub || ! sub -> owner ) c = skinny_new ( l , NULL , AST_STATE_DOWN , NULL , SKINNY_OUTGOING ); c = sub -> owner; if ( ! c ) sub = c -> tech_pvt; if ( sub ) activatesub ( sub , SUBSTATE_CONNECTED ); static void activatesub(struct skinny_subchannel *sub, int state) struct skinny_line * l = sub -> line ; if ( sub == l -> activesub ) setsubstate ( sub , state ); static void setsubstate(struct skinny_subchannel *sub, int state) struct skinny_line * l = sub -> line ; struct skinny_subline * subline = sub -> subline ; struct skinny_device * d = l -> device ; struct ast_channel * c = sub -> owner ; int actualstate = state ; if ( sub -> substate == SUBSTATE_ONHOOK ) if ( state != SUBSTATE_RINGIN && sub -> aa_sched ) sub -> aa_sched = 0; sub -> aa_beep = 0; sub -> aa_mute = 0; if ( ( state == SUBSTATE_RINGIN ) && ( ( d -> hookstate == SKINNY_OFFHOOK ) || ( AST_LIST_NEXT ( AST_LIST_FIRST ( & l -> sub ) , list ) ) ) ) actualstate = SUBSTATE_CALLWAIT; if ( ( state == SUBSTATE_CONNECTED ) && ( ! subline ) && ( AST_LIST_FIRST ( & l -> sublines ) ) ) const char * slastation ; struct skinny_subline * tmpsubline ; slastation = pbx_builtin_getvar_helper ( c , "SLASTATION" ); if ( slastation ) subline = tmpsubline; if ( subline ) subline -> sub = sub; sub -> subline = subline; subline -> callid = sub -> callid; if ( subline ) switch ( actualstate ) if ( sub -> substate != SUBSTATE_CONNECTED ) sub -> substate = SUBSTATE_HOLD; if ( actualstate == sub -> substate ) switch ( actualstate ) l -> activesub = sub; sub -> substate = SUBSTATE_OFFHOOK; if ( sub -> related ) sub -> related -> related = NULL; if ( sub == l -> activesub ) l -> activesub = NULL; sub -> cxmode = SKINNY_CX_RECVONLY; sub -> substate = SUBSTATE_ONHOOK; if ( sub -> rtp ) sub -> rtp = NULL; if ( ast_strlen_zero ( sub -> exten ) || ! ast_exists_extension ( c , c -> context , sub -> exten , 1 , l -> cid_num ) ) sub -> substate = SUBSTATE_DIALING; if ( ! ( sub -> substate == SUBSTATE_DIALING || sub -> substate == SUBSTATE_PROGRESS ) ) sub -> substate = SUBSTATE_RINGOUT; sub -> substate = SUBSTATE_RINGIN; sub -> substate = SUBSTATE_CALLWAIT; sub -> substate = SUBSTATE_CONNECTED; if ( ! ( sub -> substate == SUBSTATE_DIALING || sub -> substate == SUBSTATE_PROGRESS || sub -> substate == SUBSTATE_RINGOUT ) ) sub -> substate = SUBSTATE_BUSY; if ( ! ( sub -> substate == SUBSTATE_DIALING || sub -> substate == SUBSTATE_PROGRESS || sub -> substate == SUBSTATE_RINGOUT ) ) ast_log ( LOG_WARNING , "Cannot set substate to SUBSTATE_CONGESTION from %s (on call-%d)\n" , substate2str ( sub -> substate ) , sub -> callid ); static char *substate2str(int ind) char * tmp ; switch ( ind ) if ( ! ( tmp = ast_threadstorage_get ( & substate2str_threadbuf , SUBSTATE2STR_BUFSIZE ) ) ) snprintf ( tmp , SUBSTATE2STR_BUFSIZE , "UNKNOWN-%d" , ind ); return tmp ; | 148809/chan_skinny.c | SARD | 0 |
void dfacomp(const char *s,size_t len,struct dfa *d,int searchflag) dfamust ( d ); static void dfamust(struct dfa *d) must * musts ; must * mp ; char * result ; size_t ri ; size_t i ; token t ; static must must0 ; struct dfamust * dm ; static char empty_string [ ] = "" ; result = empty_string; musts = ( ( sizeof ( ( * musts ) ) == 1 ? xmalloc ( d -> tindex + 1 ) : xnmalloc ( d -> tindex + 1 , sizeof ( ( * musts ) ) ) ) ); while ( 0 ) mp = musts; for (i = 0; i <= d -> tindex; ++i) mp [ i ] = must0; for (i = 0; i <= d -> tindex; ++i) mp [ i ] . in = ( xmalloc ( sizeof ( ( * mp [ i ] . in ) ) ) ); mp [ i ] . left = ( xmalloc ( 2 ) ); mp [ i ] . right = ( xmalloc ( 2 ) ); mp [ i ] . is = ( xmalloc ( 2 ) ); mp [ i ] . left [ 0 ] = mp [ i ] . right [ 0 ] = mp [ i ] . is [ 0 ] = '\0'; mp [ i ] . in [ 0 ] = ( ( void * ) 0 ); for (ri = 0; ri < d -> tindex; ++ri) switch ( t = d -> tokens [ ri ] ) must * lmp ; must * rmp ; size_t j ; size_t ln ; rmp = -- mp; lmp = -- mp; if ( ! ( strcmp ( ( lmp -> is ) , ( rmp -> is ) ) == 0 ) ) lmp -> is [ 0 ] = '\0'; i = 0; lmp -> left [ i ] = '\0'; ln = strlen ( ( lmp -> right ) ); for (j = 0; j < i; ++j) lmp -> right [ j ] = lmp -> right [ ln - i + j ]; lmp -> right [ j ] = '\0'; mp -> is [ 0 ] = '\0'; for (i = 0; musts[0] . in[i] != ((void *)0); ++i) if ( strlen ( musts [ 0 ] . in [ i ] ) > strlen ( result ) ) result = musts [ 0 ] . in [ i ]; must * lmp ; must * rmp ; rmp = -- mp; lmp = -- mp; lmp -> in = addlists ( lmp -> in , rmp -> in ); if ( lmp -> in == ( ( void * ) 0 ) ) if ( lmp -> right [ 0 ] != '\0' && rmp -> left [ 0 ] != '\0' ) char * tp ; tp = icpyalloc ( ( lmp -> right ) ); static char *icpyalloc(const char *string) return icatalloc ( ( ( void * ) 0 ) , string ) ; tp = icatalloc ( tp , ( rmp -> left ) ); lmp -> in = enlist ( lmp -> in , tp , strlen ( tp ) ); if ( lmp -> in == ( ( void * ) 0 ) ) if ( lmp -> is [ 0 ] != '\0' ) lmp -> left = icatalloc ( lmp -> left , ( rmp -> left ) ); if ( lmp -> left == ( ( void * ) 0 ) ) if ( rmp -> is [ 0 ] == '\0' ) lmp -> right [ 0 ] = '\0'; lmp -> right = icatalloc ( lmp -> right , ( rmp -> right ) ); if ( lmp -> right == ( ( void * ) 0 ) ) if ( lmp -> is [ 0 ] != '\0' && rmp -> is [ 0 ] != '\0' ) lmp -> is = icatalloc ( lmp -> is , ( rmp -> is ) ); if ( lmp -> is == ( ( void * ) 0 ) ) lmp -> is [ 0 ] = '\0'; if ( t < END ) if ( t == '\0' ) if ( t >= CSET || ! 1 || t == ANYCHAR || t == MBCSET ) mp -> is [ 0 ] = mp -> left [ 0 ] = mp -> right [ 0 ] = t; mp -> is [ 1 ] = mp -> left [ 1 ] = mp -> right [ 1 ] = '\0'; mp -> in = enlist ( mp -> in , mp -> is , ( ( size_t ) 1 ) ); if ( mp -> in == ( ( void * ) 0 ) ) if ( strlen ( result ) ) dm = ( ( sizeof ( ( * dm ) ) == 1 ? xmalloc ( 1 ) : xnmalloc ( 1 , sizeof ( ( * dm ) ) ) ) ); while ( 0 ) dm -> exact = exact; dm -> must = ( xmemdup ( result , strlen ( result ) + 1 ) ); dm -> next = d -> musts; d -> musts = dm; for (i = 0; i <= d -> tindex; ++i) | 150892/dfa.c | SARD | 0 |
static void goodG2B1() char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; strncat ( data , source , 100 ); printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 71379/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_char_ncat_22a.c | SARD | 0 |
static void goodB2G() HCRYPTPROV hCryptProv = 0 ; HCRYPTHASH hHash = 0 ; HCRYPTKEY hKey = 0 ; char hashData [ 100 ] = HASH_INPUT ; BYTE payload [ ( 100 - 1 ) * sizeof ( char ) ] ; DWORD payloadBytes ; if ( ! CryptAcquireContext ( & hCryptProv , NULL , MS_ENH_RSA_AES_PROV , PROV_RSA_AES , 0 ) ) if ( ! CryptCreateHash ( hCryptProv , CALG_SHA_256 , 0 , 0 , & hHash ) ) if ( ! CryptHashData ( hHash , ( BYTE * ) hashData , strlen ( hashData ) , 0 ) ) if ( ! CryptDeriveKey ( hCryptProv , CALG_AES_256 , hHash , 0 , & hKey ) ) if ( ! CryptDecrypt ( hKey , 0 , 1 , 0 , payload , & payloadBytes ) ) while ( 0 ) | 94118/CWE319_Cleartext_Tx_Sensitive_Info__w32_char_connect_socket_31.c | SARD | 0 |
static void good1() if ( staticFalse ) if ( ! stdThreadLockCreate ( & gGoodLock ) ) if ( ! stdThreadCreate ( helperGood , NULL , & threadA ) ) int stdThreadCreate(stdThreadRoutine start, void *args, stdThread *thread) uintptr_t handle ; stdThread my_thread ; my_thread = ( stdThread ) malloc ( sizeof ( * my_thread ) ); if ( my_thread == NULL ) my_thread -> start = start; my_thread -> args = args; handle = _beginthreadex ( NULL , 0 , internal_start , my_thread , 0 , NULL ); if ( handle == 0 ) free ( my_thread ); | 94606/std_thread.c | SARD | 0 |
static void goodG2B1() char * data ; char dataBuffer [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; if ( STATIC_CONST_FALSE ) data = dataBuffer; char dest [ 100 ] ; memset ( dest , 'C' , 100 - 1 ); dest [ 100 - 1 ] = '\0'; memmove ( dest , data , 100 * sizeof ( char ) ); dest [ 100 - 1 ] = '\0'; printLine ( dest ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 77565/CWE127_Buffer_Underread__char_declare_memmove_04.c | SARD | 0 |
void CWE400_Resource_Exhaustion__connect_socket_fwrite_45_bad() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 98557/CWE400_Resource_Exhaustion__connect_socket_fwrite_45.c | SARD | 0 |
nestegg_init(nestegg ** context, nestegg_io io, nestegg_log callback, int64_t max_offset) int r ; uint64_t id , version , docversion ; nestegg * ctx ; if ( ! ( io . read && io . seek && io . tell ) ) ctx = ne_alloc ( sizeof ( * ctx ) ); static void ne_alloc(size_t size) return calloc ( 1 , size ) ; if ( ! ctx ) ctx -> io = ne_alloc ( sizeof ( * ctx -> io ) ); static void ne_alloc(size_t size) return calloc ( 1 , size ) ; if ( ! ctx -> io ) * ctx -> io = io; ctx -> log = callback; ctx -> alloc_pool = ne_pool_init ( ); static struct pool_ctx ne_pool_init(void) return h_malloc ( sizeof ( struct pool_ctx ) ) ; if ( ! ctx -> alloc_pool ) if ( ! ctx -> log ) ctx -> log = ne_null_log_callback; r = ne_peek_element ( ctx , & id , NULL ); static ne_peek_element(nestegg * ctx, uint64_t * id, uint64_t * size) int r ; if ( ctx -> last_valid ) return 1 ; r = ne_read_id ( ctx -> io , & ctx -> last_id , NULL ); if ( r != 1 ) return r ; r = ne_read_vint ( ctx -> io , & ctx -> last_size , NULL ); if ( r != 1 ) return r ; return 1 ; if ( r != 1 ) if ( id != ID_EBML ) r = ne_parse ( ctx , NULL , max_offset ); static ne_parse(nestegg * ctx, struct ebml_element_desc * top_level, int64_t max_offset) int r ; int64_t * data_offset ; uint64_t id , size , peeked_id ; struct ebml_element_desc * element ; if ( ! ctx -> ancestor ) if ( max_offset > 0 && ne_io_tell ( ctx -> io ) >= max_offset ) r = ne_peek_element ( ctx , & id , & size ); if ( r != 1 ) peeked_id = id; element = ne_find_element ( id , ctx -> ancestor -> node ); if ( element ) if ( element -> flags & DESC_FLAG_SUSPEND ) r = ne_read_element ( ctx , & id , & size ); if ( r != 1 ) assert ( id == peeked_id ); if ( element -> flags & DESC_FLAG_OFFSET ) data_offset = ( int64_t * ) ( ctx -> ancestor -> data + element -> data_offset ); * data_offset = ne_io_tell ( ctx -> io ); if ( * data_offset < 0 ) if ( element -> type == TYPE_MASTER ) if ( element -> flags & DESC_FLAG_MULTI ) if ( ne_read_master ( ctx , element ) < 0 ) if ( ne_read_single_master ( ctx , element ) < 0 ) r = ne_read_simple ( ctx , element , size ); if ( r < 0 ) if ( ne_is_ancestor_element ( id , ctx -> ancestor -> previous ) ) if ( top_level && ctx -> ancestor -> node == top_level ) r = ne_read_element ( ctx , & id , & size ); if ( r != 1 ) r = ne_io_read_skip ( ctx -> io , size ); if ( r != 1 ) | CVE-2015-4511/Firefox_40.0b9_CVE_2015_4511__media_libnestegg_src_nestegg.c | NVD | 0 |
void parse_dir_colors() char * * arg ; char * * c ; char * colors ; char * s ; int i ; if ( Hflag ) if ( getenv ( "TERM" ) == ( ( void * ) 0 ) ) s = getenv ( "TREE_COLORS" ); if ( s == ( ( void * ) 0 ) ) s = getenv ( "LS_COLORS" ); if ( ( s == ( ( void * ) 0 ) || strlen ( s ) == 0 ) && force_color ) s = ":no=00:fi=00:di=01;34:ln=01;36:pi=40;33:so=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:ex=01;32:*.bat=01;32:*.BAT=01;32:*.btm=01;32:*.BTM=01;32:*.cmd=01;32:*.CMD=01;32:*.com=01;32:*.COM=01;32:*.dll=01;32:*.DLL=01;32:*.exe=01;32:*.EXE=01;32:*.arj=01;31:*.bz2=01;31:*.deb=01;31:*.gz=01;31:*.lzh=01;31:*.rpm=01;31:*.tar=01;31:*.taz=01;31:*.tb2=01;31:*.tbz2=01;31:*.tbz=01;31:*.tgz=01;31:*.tz2=01;31:*.z=01;31:*.Z=01;31:*.zip=01;31:*.ZIP=01;31:*.zoo=01;31:*.asf=01;35:*.ASF=01;35:*.avi=01;35:*.AVI=01;35:*.bmp=01;35:*.BMP=01;35:*.flac=01;35:*.FLAC=01;35:*.gif=01;35:*.GIF=01;35:*.jpg=01;35:*.JPG=01;35:*.jpeg=01;35:*.JPEG=01;35:*.m2a=01;35:*.M2a=01;35:*.m2v=01;35:*.M2V=01;35:*.mov=01;35:*.MOV=01;35:*.mp3=01;35:*.MP3=01;35:*.mpeg=01;35:*.MPEG=01;35:*.mpg=01;35:*.MPG=01;35:*.ogg=01;35:*.OGG=01;35:*.ppm=01;35:*.rm=01;35:*.RM=01;35:*.tga=01;35:*.TGA=01;35:*.tif=01;35:*.TIF=01;35:*.wav=01;35:*.WAV=01;35:*.wmv=01;35:*.WMV=01;35:*.xbm=01;35:*.xpm=01;35:"; if ( s == ( ( void * ) 0 ) || ! force_color && ( nocolor || ! isatty ( 1 ) ) ) colors = strcpy ( ( xmalloc ( strlen ( s ) + 1 ) ) , s ); arg = split ( colors , ":" , & n ); char **split(char *str,char *delim,int *nwrds) int n = 128 ; char * * w = ( xmalloc ( sizeof ( char * ) * n ) ) ; w [ * nwrds = 0 ] = strtok ( str , delim ); while ( w [ * nwrds ] ) if ( * nwrds == n - 2 ) w = ( xrealloc ( w , sizeof ( char * ) * ( n += 256 ) ) ); w [ ++ * nwrds ] = strtok ( ( ( void * ) 0 ) , delim ); w [ * nwrds ] = ( ( void * ) 0 ); return w ; for (i = 0; arg[i]; i++) c = split ( arg [ i ] , "=" , & n ); char **split(char *str,char *delim,int *nwrds) int n = 128 ; char * * w = ( xmalloc ( sizeof ( char * ) * n ) ) ; w [ * nwrds = 0 ] = strtok ( str , delim ); while ( w [ * nwrds ] ) if ( * nwrds == n - 2 ) w = ( xrealloc ( w , sizeof ( char * ) * ( n += 256 ) ) ); w [ ++ * nwrds ] = strtok ( ( ( void * ) 0 ) , delim ); w [ * nwrds ] = ( ( void * ) 0 ); return w ; switch ( cmd ( c [ 0 ] ) ) int cmd(char *s) static struct { char * cmd ; char cmdnum ; } cmds [ ] = { { ( "no" ) , ( COL_NORMAL ) } , { ( "fi" ) , ( COL_FILE ) } , { ( "di" ) , ( COL_DIR ) } , { ( "ln" ) , ( COL_LINK ) } , { ( "pi" ) , ( COL_FIFO ) } , { ( "do" ) , ( COL_DOOR ) } , { ( "bd" ) , ( COL_BLK ) } , { ( "cd" ) , ( COL_CHR ) } , { ( "or" ) , ( COL_ORPHAN ) } , { ( "so" ) , ( COL_SOCK ) } , { ( "su" ) , ( COL_SETUID ) } , { ( "sg" ) , ( COL_SETGID ) } , { ( "tw" ) , ( COL_STICKY_OTHER_WRITABLE ) } , { ( "ow" ) , ( COL_OTHER_WRITABLE ) } , { ( "st" ) , ( COL_STICKY ) } , { ( "ex" ) , ( COL_EXEC ) } , { ( "mi" ) , ( COL_MISSING ) } , { ( "lc" ) , ( COL_LEFTCODE ) } , { ( "rc" ) , ( COL_RIGHTCODE ) } , { ( "ec" ) , ( COL_ENDCODE ) } , { ( ( ( void * ) 0 ) ) , ( 0 ) } } ; int i ; for (i = 0; cmds[i] . cmdnum; i++) if ( ! strcmp ( cmds [ i ] . cmd , s ) ) return cmds [ i ] . cmdnum ; if ( s [ 0 ] == '*' ) return DOT_EXTENSION ; return ERROR ; if ( c [ 1 ] ) norm_flgs = strcpy ( ( xmalloc ( strlen ( c [ 1 ] ) + 1 ) ) , c [ 1 ] ); if ( ! norm_flgs ) sprintf ( buf , "%s%s%s" , leftcode , norm_flgs , rightcode ); endcode = strcpy ( ( xmalloc ( strlen ( buf ) + 1 ) ) , buf ); | 153244/color.c | SARD | 0 |
void bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); dataList . push_back ( data ); dataList . push_back ( data ); dataList . push_back ( data ); | 61982/CWE114_Process_Control__w32_char_connect_socket_73a.cpp | SARD | 0 |
static void goodG2B2() char dataBuffer [ 100 ] ; memset ( dataBuffer , 'A' , 100 - 1 ); dataBuffer [ 100 - 1 ] = '\0'; data = dataBuffer; memcpy ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 74028/CWE124_Buffer_Underwrite__char_declare_memcpy_07.c | SARD | 0 |
void CWE690_NULL_Deref_From_Return__long_calloc_31_bad() long * data ; data = ( long * ) calloc ( 1 , sizeof ( long ) ); long * dataCopy = data ; long * data = dataCopy ; data [ 0 ] = 5L; printLongLine ( data [ 0 ] ); void printLongLine (long longNumber) printf ( "%ld\n" , longNumber ); free ( data ); | 111478/CWE690_NULL_Deref_From_Return__long_calloc_31.c | SARD | 2 |
int main(int argc, char *argv[]) char * e ; e = getenv ( "CONTENT_TYPE" ); if ( e ) cgiContentType [ 0 ] = '\0'; if ( cgiStrEqNc ( cgiRequestMethod , "post" ) ) if ( cgiStrEqNc ( cgiContentType , "application/x-www-form-urlencoded" ) ) if ( cgiParsePostFormInput ( ) != cgiParseSuccess ) static cgiParseResultType cgiParsePostFormInput() char * input ; cgiParseResultType result ; if ( ! cgiContentLength ) return cgiParseSuccess ; input = ( char * ) malloc ( cgiContentLength ); if ( ! input ) return cgiParseMemory ; if ( ( ( int ) fread ( input , 1 , cgiContentLength , cgiIn ) ) != cgiContentLength ) return cgiParseIO ; result = cgiParseFormInput ( input , cgiContentLength ); static cgiParseResultType cgiParseFormInput(char *data, int length) int pos = 0 ; cgiFormEntry * n ; while ( pos != length ) int foundEq = 0 ; int foundAmp = 0 ; int start = pos ; int len = 0 ; char * attr ; char * value ; while ( pos != length ) if ( data [ pos ] == '=' ) foundEq = 1; pos ++; pos ++; len ++; if ( ! foundEq ) if ( cgiUnescapeChars ( & attr , data + start , len ) != cgiUnescapeSuccess ) return cgiParseMemory ; start = pos; len = 0; while ( pos != length ) if ( data [ pos ] == '&' ) foundAmp = 1; pos ++; pos ++; len ++; if ( cgiUnescapeChars ( & value , data + start , len ) != cgiUnescapeSuccess ) return cgiParseMemory ; n = ( cgiFormEntry * ) malloc ( sizeof ( cgiFormEntry ) ); if ( ! n ) return cgiParseMemory ; n -> attr = attr; n -> value = value; n -> valueLength = strlen ( n -> value ); n -> fileName = ( char * ) malloc ( 1 ); if ( ! n -> fileName ) return cgiParseMemory ; n -> fileName [ 0 ] = '\0'; n -> contentType = ( char * ) malloc ( 1 ); if ( ! n -> contentType ) return cgiParseMemory ; n -> contentType [ 0 ] = '\0'; n -> tfileName = ( char * ) malloc ( 1 ); if ( ! n -> tfileName ) return cgiParseMemory ; if ( ! foundAmp ) return cgiParseSuccess ; return result ; cgiHeaderStatus ( 500 , "Error reading form data" ); void cgiHeaderStatus(int status, char *statusMessage) fprintf ( cgiOut , "Status: %d %s\r\n\r\n" , status , statusMessage ); | 149094/cgic.c | SARD | 0 |
static void goodG2B() char * data ; char dataBuffer [ 100 ] ; data = dataBuffer; memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_snprintf_52b_goodG2BSink ( data ); void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_snprintf_52b_goodG2BSink(char * data) CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_snprintf_52c_goodG2BSink ( data ); void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_snprintf_52c_goodG2BSink(char * data) char dest [ 50 ] = "" ; SNPRINTF ( dest , strlen ( data ) , "%s" , data ); | 66070/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_declare_snprintf_52c.c | SARD | 0 |
static cgiParseResultType cgiParsePostMultipartInput() cgiParseResultType result ; int got ; char tfileName [ 1024 ] ; mpStreamPtr mpp = & mp ; if ( ! cgiContentLength ) result = afterNextBoundary ( mpp , 0 , 0 , 0 , 1 ); cgiParseResultType afterNextBoundary(mpStreamPtr mpp, FILE *outf, char int *bodyLengthP, int first) int outSpace = 256 ; cgiParseResultType result ; int boffset ; int got ; char d [ 2 ] ; char workingBoundaryData [ 1024 ] ; char * workingBoundary = workingBoundaryData ; int workingBoundaryLength ; if ( ( ! outf ) && ( outP ) ) out = ( char * ) malloc ( outSpace ); if ( ! out ) boffset = 0; sprintf ( workingBoundaryData , "\r\n--%s" , cgiMultipartBoundary ); if ( first ) workingBoundary = workingBoundaryData + 2; workingBoundaryLength = strlen ( workingBoundary ); while ( 1 ) got = mpRead ( mpp , d , 1 ); int mpRead(mpStreamPtr mpp, char *buffer, int len) int ilen = len ; int got = 0 ; if ( len > ( cgiContentLength - mpp -> offset ) ) len = cgiContentLength - mpp -> offset; while ( len ) if ( mpp -> readPos != mpp -> writePos ) * buffer ++ = mpp -> putback [ mpp -> readPos ++ ]; mpp -> readPos %= sizeof ( mpp -> putback ); got ++; len --; if ( len ) int fgot = fread ( buffer , 1 , len , cgiIn ) ; if ( fgot >= 0 ) return got + fgot ; if ( got > 0 ) return got ; return fgot ; if ( got ) return got ; if ( ilen ) return EOF ; return 0 ; if ( got != 1 ) result = cgiParseIO; if ( d [ 0 ] == workingBoundary [ boffset ] ) boffset ++; if ( boffset == workingBoundaryLength ) if ( boffset > 0 ) boffset = 0; got = mpRead ( mpp , d , 2 ); int mpRead(mpStreamPtr mpp, char *buffer, int len) int ilen = len ; int got = 0 ; if ( len > ( cgiContentLength - mpp -> offset ) ) len = cgiContentLength - mpp -> offset; while ( len ) if ( mpp -> readPos != mpp -> writePos ) * buffer ++ = mpp -> putback [ mpp -> readPos ++ ]; mpp -> readPos %= sizeof ( mpp -> putback ); got ++; len --; if ( len ) int fgot = fread ( buffer , 1 , len , cgiIn ) ; if ( fgot >= 0 ) return got + fgot ; if ( got > 0 ) return got ; return fgot ; if ( got ) return got ; if ( ilen ) return EOF ; return 0 ; if ( got != 2 ) result = cgiParseIO; return cgiParseSuccess ; result = cgiParseMemory; return result ; if ( result == cgiParseIO ) if ( result != cgiParseSuccess ) while ( 1 ) char d [ 1024 ] ; char fvalue [ 1024 ] ; char fname [ 1024 ] ; int bodyLength = 0 ; char ffileName [ 1024 ] ; char fcontentType [ 1024 ] ; fvalue [ 0 ] = 0; fname [ 0 ] = 0; ffileName [ 0 ] = 0; fcontentType [ 0 ] = 0; out = 0; outf = 0; got = mpRead ( mpp , d , 2 ); int mpRead(mpStreamPtr mpp, char *buffer, int len) int ilen = len ; int got = 0 ; if ( len > ( cgiContentLength - mpp -> offset ) ) len = cgiContentLength - mpp -> offset; while ( len ) if ( mpp -> readPos != mpp -> writePos ) * buffer ++ = mpp -> putback [ mpp -> readPos ++ ]; mpp -> readPos %= sizeof ( mpp -> putback ); got ++; len --; if ( len ) int fgot = fread ( buffer , 1 , len , cgiIn ) ; if ( fgot >= 0 ) return got + fgot ; if ( got > 0 ) return got ; return fgot ; if ( got ) return got ; if ( ilen ) return EOF ; return 0 ; if ( got < 2 ) if ( ( d [ 0 ] == '-' ) && ( d [ 1 ] == '-' ) ) if ( ! cgiStrEqNc ( fvalue , "form-data" ) ) static int cgiStrEqNc(char *s1, char *s2) while ( 1 ) if ( ! ( * s1 ) ) if ( ! ( * s2 ) ) return 1 ; return 0 ; if ( ! ( * s2 ) ) return 0 ; if ( isalpha ( * s1 ) ) if ( tolower ( * s1 ) != tolower ( * s2 ) ) return 0 ; if ( ( * s1 ) != ( * s2 ) ) return 0 ; s1 ++; s2 ++; result = afterNextBoundary ( mpp , 0 , 0 , 0 , 0 ); cgiParseResultType afterNextBoundary(mpStreamPtr mpp, FILE *outf, char int *bodyLengthP, int first) int outSpace = 256 ; cgiParseResultType result ; int boffset ; int got ; char d [ 2 ] ; char workingBoundaryData [ 1024 ] ; char * workingBoundary = workingBoundaryData ; int workingBoundaryLength ; if ( ( ! outf ) && ( outP ) ) out = ( char * ) malloc ( outSpace ); if ( ! out ) boffset = 0; sprintf ( workingBoundaryData , "\r\n--%s" , cgiMultipartBoundary ); if ( first ) workingBoundary = workingBoundaryData + 2; workingBoundaryLength = strlen ( workingBoundary ); while ( 1 ) got = mpRead ( mpp , d , 1 ); if ( got != 1 ) result = cgiParseIO; if ( d [ 0 ] == workingBoundary [ boffset ] ) boffset ++; if ( boffset == workingBoundaryLength ) if ( boffset > 0 ) boffset = 0; got = mpRead ( mpp , d , 2 ); if ( got != 2 ) result = cgiParseIO; return cgiParseSuccess ; result = cgiParseMemory; return result ; if ( result != cgiParseSuccess ) if ( strlen ( ffileName ) ) if ( getTempFileName ( tfileName ) != cgiParseSuccess ) static cgiParseResultType getTempFileName(char *tfileName) int outfd ; strcpy ( tfileName , cgicTempDir "/cgicXXXXXX" ) outfd = mkstemp ( tfileName ); if ( outfd == - 1 ) return cgiParseIO ; if ( chmod ( tfileName , 0600 ) != 0 ) return cgiParseIO ; return cgiParseSuccess ; outf = fopen ( tfileName , "w+b" ); outf = 0; tfileName [ 0 ] = '\0'; result = afterNextBoundary ( mpp , outf , & out , & bodyLength , 0 ); cgiParseResultType afterNextBoundary(mpStreamPtr mpp, FILE *outf, char int *bodyLengthP, int first) int outSpace = 256 ; cgiParseResultType result ; int boffset ; int got ; char d [ 2 ] ; char workingBoundaryData [ 1024 ] ; char * workingBoundary = workingBoundaryData ; int workingBoundaryLength ; if ( ( ! outf ) && ( outP ) ) out = ( char * ) malloc ( outSpace ); if ( ! out ) boffset = 0; sprintf ( workingBoundaryData , "\r\n--%s" , cgiMultipartBoundary ); if ( first ) workingBoundary = workingBoundaryData + 2; workingBoundaryLength = strlen ( workingBoundary ); while ( 1 ) got = mpRead ( mpp , d , 1 ); if ( got != 1 ) result = cgiParseIO; if ( d [ 0 ] == workingBoundary [ boffset ] ) boffset ++; if ( boffset == workingBoundaryLength ) if ( boffset > 0 ) boffset = 0; got = mpRead ( mpp , d , 2 ); if ( got != 2 ) result = cgiParseIO; return cgiParseSuccess ; result = cgiParseMemory; return result ; if ( result != cgiParseSuccess ) n = ( cgiFormEntry * ) malloc ( sizeof ( cgiFormEntry ) ); if ( ! n ) memset ( n , 0 , sizeof ( cgiFormEntry ) ); n -> attr = ( char * ) malloc ( strlen ( fname ) + 1 ); if ( ! n -> attr ) if ( out ) if ( outf ) n -> value = ( char * ) malloc ( 1 ); if ( ! n -> value ) n -> value [ 0 ] = '\0'; n -> valueLength = bodyLength; n -> next = 0; n -> fileName = ( char * ) malloc ( strlen ( ffileName ) + 1 ); if ( ! n -> fileName ) strcpy ( n -> fileName , ffileName ); n -> contentType = ( char * ) malloc ( strlen ( fcontentType ) + 1 ); if ( ! n -> contentType ) strcpy ( n -> contentType , fcontentType ); n -> tfileName = ( char * ) malloc ( strlen ( tfileName ) + 1 ); if ( ! n -> tfileName ) strcpy ( n -> tfileName , tfileName ); if ( n ) if ( n -> tfileName ) free ( n -> tfileName ); | 149176/cgic.c | SARD | 0 |
void CWE606_Unchecked_Loop_Condition__char_listen_socket_17_bad() int i , j ; char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; for(i = 0; i < 1; i++) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) if ( listenSocket != INVALID_SOCKET ) CLOSE_SOCKET ( listenSocket ); if ( acceptSocket != INVALID_SOCKET ) CLOSE_SOCKET ( acceptSocket ); if ( sscanf ( data , "%d" , & n ) == 1 ) | 109138/CWE606_Unchecked_Loop_Condition__char_listen_socket_17.c | SARD | 0 |
static void goodB2G1() size_t data ; data = 0; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = strtoul ( inputBuffer , NULL , 0 ); while ( 0 ) goodB2G1Sink ( data ); void goodB2G1Sink(size_t data) if ( goodB2G1Global ) if ( data > strlen ( HELLO_STRING ) && data < 100 ) | 117626/CWE789_Uncontrolled_Mem_Alloc__new_char_listen_socket_22b.cpp | SARD | 0 |
void CWE690_NULL_Deref_From_Return__wchar_t_malloc_32_bad() wchar_t * data ; data = ( wchar_t * ) malloc ( 20 * sizeof ( wchar_t ) ); * dataPtr1 = data; wcscpy ( data , L "Initialize" ) printWLine ( data ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) free ( data ); | 111863/CWE690_NULL_Deref_From_Return__wchar_t_malloc_32.c | SARD | 2 |
static void goodB2G2() int count ; count = - 1; char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) count = atoi ( inputBuffer ); CWE400_Resource_Exhaustion__fgets_fwrite_22_goodB2G2Sink ( count ); void CWE400_Resource_Exhaustion__fgets_fwrite_22_goodB2G2Sink(int count) if ( CWE400_Resource_Exhaustion__fgets_fwrite_22_goodB2G2Global ) const char * filename = "output_good.txt" ; if ( count > 0 && count <= 20 ) pFile = fopen ( filename , "w+" ); if ( pFile ) fclose ( pFile ); | 98692/CWE400_Resource_Exhaustion__fgets_fwrite_22b.c | SARD | 0 |
static void goodG2B() char * data ; char dataBuffer [ FILENAME_MAX ] = "" ; data = dataBuffer; strcat ( data , "c:\\temp\\file.txt" ); goodG2BSink ( data ); void goodG2BSink(char * data) hFile = CreateFileA ( data , ( GENERIC_WRITE | GENERIC_READ ) , 0 , NULL , OPEN_ALWAYS , FILE_ATTRIBUTE_NORMAL , NULL ); if ( hFile != INVALID_HANDLE_VALUE ) CloseHandle ( hFile ); | 96479/CWE36_Absolute_Path_Traversal__char_file_w32CreateFile_51a.cpp | SARD | 0 |
void CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_memmove_04_bad() char * data ; data = ( char * ) malloc ( 100 * sizeof ( char ) ); if ( STATIC_CONST_TRUE ) memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; memmove ( dest , data , strlen ( data ) * sizeof ( char ) ); dest [ 50 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( data ); | 72323/CWE122_Heap_Based_Buffer_Overflow__c_CWE806_char_memmove_04.c | SARD | 3 |
void bad() wchar_t * data ; wchar_t dataBuffer [ FILENAME_MAX ] = L "" data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = wcslen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( FILENAME_MAX - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) if ( connectSocket != INVALID_SOCKET ) CLOSE_SOCKET ( connectSocket ); | 96873/CWE36_Absolute_Path_Traversal__wchar_t_connect_socket_ofstream_67a.cpp | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_listen_socket_w32_vsnprintf_07_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticFive == 5 ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) listenSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( listenSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = INADDR_ANY; service . sin_port = htons ( TCP_PORT ); if ( bind ( listenSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) if ( listen ( listenSocket , LISTEN_BACKLOG ) == SOCKET_ERROR ) acceptSocket = accept ( listenSocket , NULL , NULL ); if ( acceptSocket == SOCKET_ERROR ) recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) 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 ); | 80496/CWE134_Uncontrolled_Format_String__char_listen_socket_w32_vsnprintf_07.c | SARD | 15 |
static void good1() if ( staticReturnsFalse ( ) ) static int staticReturnsFalse() return 0 ; double * * pointer = ( double * * ) malloc ( sizeof ( double * ) ) ; * pointer = data; double * data = * pointer ; printDoubleLine ( * data ); void printDoubleLine(double doubleNumber) printf ( "%g\n" , doubleNumber ); free ( pointer ); | 112107/CWE758_Undefined_Behavior__double_pointer_malloc_use_08.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__char_listen_socket_printf_21_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 , '\n' ); if ( replace ) * replace = '\0'; while ( 0 ) | 80316/CWE134_Uncontrolled_Format_String__char_listen_socket_printf_21.c | SARD | 0 |
static void goodB2G() size_t data ; data = 0; data = CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_fgets_61b_goodB2GSource ( data ); size_t CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_fgets_61b_goodB2GSource(size_t data) char inputBuffer [ CHAR_ARRAY_SIZE ] = "" ; if ( fgets ( inputBuffer , CHAR_ARRAY_SIZE , stdin ) != NULL ) data = strtoul ( inputBuffer , NULL , 0 ); return data ; if ( data > wcslen ( HELLO_STRING ) && data < 100 ) | 117304/CWE789_Uncontrolled_Mem_Alloc__malloc_wchar_t_fgets_61a.c | SARD | 0 |
void CWE78_OS_Command_Injection__char_listen_socket_popen_09_bad() char * data ; char data_buf [ 100 ] = FULL_COMMAND ; data = data_buf; if ( GLOBAL_CONST_TRUE ) size_t dataLen = strlen ( data ) ; recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; pipe = POPEN ( data , "wb" ); if ( pipe != NULL ) PCLOSE ( pipe ); | 119967/CWE78_OS_Command_Injection__char_listen_socket_popen_09.c | SARD | 15 |
void heap_redo(XLogRecPtr lsn,XLogRecord *record) uint8 info = ( ( record -> xl_info ) & ~0x0F ) ; switch ( info & 0x70 ) heap_xlog_insert ( lsn , record ); static void heap_xlog_insert(XLogRecPtr lsn,XLogRecord *record) xl_heap_insert * xlrec = ( xl_heap_insert * ) ( ( ( char * ) record ) + ( ( ( intptr_t ) ( sizeof ( XLogRecord ) ) ) + ( 8 - 1 ) & ~ ( ( intptr_t ) ( 8 - 1 ) ) ) ) ; Buffer buffer ; Page page ; struct { HeapTupleHeaderData hdr ; char data [ 8192 - ( ( ( intptr_t ) ( ( ( size_t ) ( & ( ( PageHeaderData * ) 0 ) -> pd_linp ) ) + sizeof ( ItemIdData ) ) ) + ( 8 - 1 ) & ~ ( ( intptr_t ) ( 8 - 1 ) ) ) ] ; } tbuf ; HeapTupleHeader htup ; BlockNumber blkno ; blkno = ( ( ( ( void ) ( ( bool ) 1 ) ) , ( ( ( ( void ) ( ( bool ) 1 ) ) , ( ( BlockNumber ) ( ( ( & ( & xlrec -> target . tid ) -> ip_blkid ) -> bi_hi ) << 16 | ( ( uint16 ) ( ( & ( & xlrec -> target . tid ) -> ip_blkid ) -> bi_lo ) ) ) ) ) ) ) ); if ( ( record -> xl_info ) & 0x0008 >> 0 ) if ( ( record -> xl_info ) & 0x0080 ) buffer = XLogReadBuffer ( xlrec -> target . node , blkno , ( ( bool ) 0 ) ); if ( ! ( ( ( ( void ) ( ( bool ) 1 ) ) , buffer != 0 ) ) ) page = ( ( Page ) ( ( Page ) ( ( ( ( void ) ( ( bool ) 1 ) ) , ( buffer < 0 ? LocalBufferBlockPointers [ - buffer - 1 ] : ( ( Block ) ( BufferBlocks + ( ( Size ) ( buffer - 1 ) ) * 8192 ) ) ) ) ) ) ); if ( lsn . xlogid < ( ( PageHeader ) page ) -> pd_lsn . xlogid || lsn . xlogid == ( ( PageHeader ) page ) -> pd_lsn . xlogid && lsn . xrecoff <= ( ( PageHeader ) page ) -> pd_lsn . xrecoff ) htup = & tbuf . hdr; void * _vstart = ( void * ) ( ( char * ) htup ) ; int _val = 0 ; Size _len = sizeof ( HeapTupleHeaderData ) ; 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 ) | 152957/heapam.c | SARD | 0 |
void CWE114_Process_Control__w32_char_connect_socket_54_bad() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char * replace ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; if ( replace ) * replace = '\0'; while ( 0 ) | 61972/CWE114_Process_Control__w32_char_connect_socket_54a.c | SARD | 0 |
static void good2() if ( 5 == 5 ) charVoid structCharVoid ; structCharVoid . voidSecond = ( void * ) SRC_STR; memcpy ( structCharVoid . charFirst , SRC_STR , sizeof ( structCharVoid . charFirst ) ); printWLine ( ( wchar_t * ) structCharVoid . charFirst ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) printWLine ( ( wchar_t * ) structCharVoid . voidSecond ); void printWLine (const wchar_t * line) if ( line != NULL ) wprintf ( L "%ls\n" , line ) | 67450/CWE121_Stack_Based_Buffer_Overflow__wchar_t_type_overrun_memcpy_03.c | SARD | 0 |
static void goodB2G2() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; size_t dataLen = wcslen ( data ) ; recvResult = recv ( acceptSocket , ( char * ) ( data + dataLen ) , sizeof ( wchar_t ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) | 81796/CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_snprintf_11.c | SARD | 0 |
static void goodG2B() char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; data [ i ] = source [ i ]; data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 74309/CWE124_Buffer_Underwrite__malloc_char_loop_34.c | SARD | 0 |
void CWE427_Uncontrolled_Search_Path_Element__char_console_12_bad() char * data ; char dataBuffer [ 250 ] = "PATH=" ; data = dataBuffer; if ( globalReturnsTrueOrFalse ( ) ) int globalReturnsTrueOrFalse() return ( rand ( ) % 2 ) ; size_t dataLen = strlen ( data ) ; if ( 250 - dataLen > 1 ) if ( fgets ( data + dataLen , ( int ) ( 250 - dataLen ) , stdin ) != NULL ) dataLen = strlen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == '\n' ) data [ dataLen - 1 ] = '\0'; data [ dataLen ] = '\0'; | 102915/CWE427_Uncontrolled_Search_Path_Element__char_console_12.c | SARD | 0 |
void CWE134_Uncontrolled_Format_String__wchar_t_console_printf_14_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; if ( globalFive == 5 ) size_t dataLen = wcslen ( data ) ; if ( 100 - dataLen > 1 ) if ( fgetws ( data + dataLen , ( int ) ( 100 - dataLen ) , stdin ) != NULL ) dataLen = wcslen ( data ); if ( dataLen > 0 && data [ dataLen - 1 ] == L '\n' ) | 80887/CWE134_Uncontrolled_Format_String__wchar_t_console_printf_14.c | SARD | 0 |
static void goodB2G() WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) CWE369_Divide_by_Zero__int_connect_socket_divide_64b_goodB2GSink ( & data ); void CWE369_Divide_by_Zero__int_connect_socket_divide_64b_goodB2GSink(void * dataVoidPtr) int * dataPtr = ( int * ) dataVoidPtr ; int data = ( * dataPtr ) ; if ( data != 0 ) printIntLine ( 100 / data ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 94998/CWE369_Divide_by_Zero__int_connect_socket_divide_64a.c | SARD | 0 |
CWE78_OS_Command_Injection__char_connect_socket_w32_spawnv_83_bad::CWE78_OS_Command_Injection__char_connect_socket_w32_spawnv_83_bad(char * dataCopy) data = dataCopy; size_t dataLen = strlen ( data ) ; recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; replace = strchr ( data , '\r' ); if ( replace ) * replace = '\0'; replace = strchr ( data , '\n' ); if ( replace ) * replace = '\0'; | 118325/CWE78_OS_Command_Injection__char_connect_socket_w32_spawnv_83_bad.cpp | SARD | 0 |
static void goodG2B2() twoIntsStruct * data ; data = NULL; if ( globalReturnsTrue ( ) ) int globalReturnsTrue() return 1 ; data = ( twoIntsStruct * ) malloc ( 100 * sizeof ( twoIntsStruct ) ); twoIntsStruct source [ 100 ] ; size_t i ; for (i = 0; i < 100; i++) source [ i ] . intOne = 0; source [ i ] . intTwo = 0; size_t i ; for (i = 0; i < 100; i++) data [ i ] = source [ i ]; free ( data ); | 71802/CWE122_Heap_Based_Buffer_Overflow__c_CWE805_struct_loop_11.c | SARD | 0 |
static void good2() if ( 5 == 5 ) twoIntsStruct * data = ( twoIntsStruct * ) malloc ( 100 * sizeof ( twoIntsStruct ) ) ; twoIntsStruct * tmpData ; data [ 0 ] . intOne = 0; data [ 0 ] . intTwo = 0; tmpData = ( twoIntsStruct * ) realloc ( data , ( 130000 ) * sizeof ( twoIntsStruct ) ); if ( tmpData != NULL ) data = tmpData; data [ 0 ] . intOne = 1; data [ 0 ] . intTwo = 1; printStructLine ( & data [ 0 ] ); void printStructLine (const twoIntsStruct * structTwoIntsStruct) printf ( "%d -- %d\n" , structTwoIntsStruct -> intOne , structTwoIntsStruct -> intTwo ); free ( data ); | 99708/CWE401_Memory_Leak__malloc_realloc_twoIntsStruct_03.c | SARD | 0 |
CWE123_Write_What_Where_Condition__connect_socket_83_bad::CWE123_Write_What_Where_Condition__connect_socket_83_bad(badStruct dataCopy) data = dataCopy; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) & data , sizeof ( data ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) while ( 0 ) | 73452/CWE123_Write_What_Where_Condition__connect_socket_83_bad.cpp | SARD | 0 |
void CWE124_Buffer_Underwrite__char_alloca_memmove_53d_badSink(char * data) char source [ 100 ] ; memset ( source , 'C' , 100 - 1 ); source [ 100 - 1 ] = '\0'; memmove ( data , source , 100 * sizeof ( char ) ); data [ 100 - 1 ] = '\0'; printLine ( data ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); | 73889/CWE124_Buffer_Underwrite__char_alloca_memmove_53d.c | SARD | 3 |
static void goodB2G() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; size_t dataLen = strlen ( data ) ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , ( char * ) ( data + dataLen ) , sizeof ( char ) * ( 100 - dataLen - 1 ) , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) data [ dataLen + recvResult / sizeof ( char ) ] = '\0'; while ( 0 ) CWE606_Unchecked_Loop_Condition__char_connect_socket_82_base * baseObject = new CWE606_Unchecked_Loop_Condition__char_connect_socket_82_goodB2G baseObject -> action ( data ); void CWE606_Unchecked_Loop_Condition__char_connect_socket_82_goodB2G::action(char * data) if ( sscanf ( data , "%d" , & n ) == 1 ) | 108975/CWE606_Unchecked_Loop_Condition__char_connect_socket_82_goodB2G.cpp | SARD | 0 |
static void goodB2G1() char * data ; char dataBuffer [ 100 ] = "" ; data = dataBuffer; if ( staticFive == 5 ) 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 ) if ( staticFive != 5 ) if ( sscanf ( data , "%d" , & n ) == 1 ) | 108936/CWE606_Unchecked_Loop_Condition__char_connect_socket_07.c | SARD | 0 |
void CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_memcpy_21_bad() char * data ; char * dataBuffer = ( char * ) ALLOCA ( 100 * sizeof ( char ) ) ; data = dataBuffer; data = badSource ( data ); static char * badSource(char * data) if ( badStatic ) memset ( data , 'A' , 100 - 1 ); data [ 100 - 1 ] = '\0'; return data ; char dest [ 50 ] = "" ; memcpy ( dest , data , strlen ( data ) * sizeof ( char ) ); dest [ 50 - 1 ] = '\0'; | 65578/CWE121_Stack_Based_Buffer_Overflow__CWE806_char_alloca_memcpy_21.c | SARD | 3 |
static void goodB2G1() 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 ) | 81757/CWE134_Uncontrolled_Format_String__wchar_t_listen_socket_printf_22a.c | SARD | 0 |
void CWE114_Process_Control__w32_wchar_t_listen_socket_16_bad() wchar_t * data ; wchar_t dataBuffer [ 100 ] = L "" data = dataBuffer; while ( 1 ) 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 ) | 62435/CWE114_Process_Control__w32_wchar_t_listen_socket_16.c | SARD | 0 |
static void goodG2B1() short data ; data = 0; if ( globalFalse ) data = 100 - 1; if ( data < 100 ) char * dataBuffer = ( char * ) malloc ( data ) ; memset ( dataBuffer , 'A' , data - 1 ); dataBuffer [ data - 1 ] = '\0'; printLine ( dataBuffer ); void printLine (const char * line) if ( line != NULL ) printf ( "%s\n" , line ); free ( dataBuffer ); | 86871/CWE194_Unexpected_Sign_Extension__listen_socket_malloc_10.c | SARD | 0 |
static void goodG2B1() int data ; data = - 1; if ( GLOBAL_CONST_FALSE ) data = 20; int * intPointer ; intPointer = ( int * ) malloc ( data * sizeof ( int ) ); intPointer [ i ] = 0; printIntLine ( intPointer [ 0 ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); free ( intPointer ); | 110464/CWE680_Integer_Overflow_to_Buffer_Overflow__malloc_fscanf_09.c | SARD | 0 |
void bad() wchar_t * data ; data = NULL; switch ( 6 ) data = new wchar_t [ 50 ]; data [ 0 ] = L '\0' 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 ) delete [ ] data | 69214/CWE122_Heap_Based_Buffer_Overflow__cpp_CWE805_wchar_t_ncpy_15.cpp | SARD | 3 |
static void goodB2G2() if ( STATIC_CONST_TRUE ) WSADATA wsaData ; int recvResult ; struct sockaddr_in service ; char inputBuffer [ CHAR_ARRAY_SIZE ] ; if ( WSAStartup ( MAKEWORD ( 2 , 2 ) , & wsaData ) != NO_ERROR ) connectSocket = socket ( AF_INET , SOCK_STREAM , IPPROTO_TCP ); if ( connectSocket == INVALID_SOCKET ) memset ( & service , 0 , sizeof ( service ) ); service . sin_family = AF_INET; service . sin_addr . s_addr = inet_addr ( IP_ADDRESS ); service . sin_port = htons ( TCP_PORT ); if ( connect ( connectSocket , ( struct sockaddr * ) & service , sizeof ( service ) ) == SOCKET_ERROR ) recvResult = recv ( connectSocket , inputBuffer , CHAR_ARRAY_SIZE - 1 , 0 ); if ( recvResult == SOCKET_ERROR || recvResult == 0 ) inputBuffer [ recvResult ] = '\0'; data = atoi ( inputBuffer ); while ( 0 ) if ( data >= 0 && data < ( 10 ) ) printIntLine ( buffer [ data ] ); void printIntLine (int intNumber) printf ( "%d\n" , intNumber ); | 75601/CWE126_Buffer_Overread__CWE129_connect_socket_04.c | SARD | 0 |
static void goodG2B() char * data ; char dataBuffer [ 100 ] ; data = dataBuffer; memset ( data , 'A' , 50 - 1 ); data [ 50 - 1 ] = '\0'; CWE121_Stack_Based_Buffer_Overflow__src_char_declare_cat_53b_goodG2BSink ( data ); void CWE121_Stack_Based_Buffer_Overflow__src_char_declare_cat_53b_goodG2BSink(char * data) CWE121_Stack_Based_Buffer_Overflow__src_char_declare_cat_53c_goodG2BSink ( data ); void CWE121_Stack_Based_Buffer_Overflow__src_char_declare_cat_53c_goodG2BSink(char * data) CWE121_Stack_Based_Buffer_Overflow__src_char_declare_cat_53d_goodG2BSink ( data ); void CWE121_Stack_Based_Buffer_Overflow__src_char_declare_cat_53d_goodG2BSink(char * data) char dest [ 50 ] = "" ; strcat ( dest , data ); | 67191/CWE121_Stack_Based_Buffer_Overflow__src_char_declare_cat_53d.c | SARD | 0 |